@@ -8,12 +8,11 @@ import (
8
8
"net/http"
9
9
"os"
10
10
"sync"
11
- "syscall"
12
-
13
- "gopkg.in/errgo.v1"
14
11
15
12
"github.com/pkg/errors"
16
13
"github.com/sirupsen/logrus"
14
+ "golang.org/x/sys/unix"
15
+ "gopkg.in/errgo.v1"
17
16
18
17
"github.com/Scalingo/go-utils/logger"
19
18
"github.com/Scalingo/sand/api/params"
@@ -83,13 +82,13 @@ func (c NetworksController) Connect(w http.ResponseWriter, r *http.Request, urlp
83
82
if localEndpoint .ID != "" {
84
83
err := netutils .ForwardConnection (ctx , socket , localEndpoint .TargetNetnsPath , ip , port )
85
84
if operr , ok := errors .Cause (err ).(* net.OpError ); ok {
86
- if syscallerr , ok := operr .Err .(* os.SyscallError ); ok && syscallerr .Err == syscall .ECONNREFUSED {
85
+ if syscallerr , ok := operr .Err .(* os.SyscallError ); ok && syscallerr .Err == unix .ECONNREFUSED {
87
86
// It happens that the target from the network connection (ip:port) is not
88
87
// actually bound in the network namespace, in this case a standard
89
88
// connection refused error is sent, this should not be an error, the
90
89
// connection to the SAND client should just be stopped normally
91
90
log .WithError (err ).Infof ("local endpoint %v not binding port" , localEndpoint )
92
- } else if syscallerr , ok := operr .Err .(* os.SyscallError ); ok && syscallerr .Err == syscall .EHOSTUNREACH {
91
+ } else if syscallerr , ok := operr .Err .(* os.SyscallError ); ok && syscallerr .Err == unix .EHOSTUNREACH {
93
92
// It's also possible that the targeted IP is not reachable anymore and it leads
94
93
// to a no route to host error. This error is not related to sand itself
95
94
log .WithError (err ).Infof ("local endpoint %v no route to host" , localEndpoint )
0 commit comments