@@ -28,14 +28,13 @@ import (
28
28
"github.com/Jigsaw-Code/outline-go-tun2socks/outline"
29
29
"github.com/Jigsaw-Code/outline-go-tun2socks/outline/connectivity"
30
30
"github.com/Jigsaw-Code/outline-go-tun2socks/outline/internal/utf8"
31
- "github.com/Jigsaw-Code/outline-go-tun2socks/outline/neterrors"
32
31
"github.com/Jigsaw-Code/outline-internal-sdk/transport"
33
32
"github.com/Jigsaw-Code/outline-internal-sdk/transport/shadowsocks"
34
33
"github.com/eycorsican/go-tun2socks/common/log"
35
34
)
36
35
37
36
// A client object that can be used to connect to a remote Shadowsocks proxy.
38
- type Client = outline.Client
37
+ type Client outline.Client
39
38
40
39
// NewClient creates a new Shadowsocks client from a non-nil configuration.
41
40
//
@@ -96,17 +95,35 @@ func newShadowsocksClient(host string, port int, cipherName, password string, pr
96
95
return nil , fmt .Errorf ("failed to create PacketListener: %w" , err )
97
96
}
98
97
99
- return & outline. Client {StreamDialer : streamDialer , PacketListener : packetListener }, nil
98
+ return & Client {StreamDialer : streamDialer , PacketListener : packetListener }, nil
100
99
}
101
100
101
+ // Error number constants exported through gomobile
102
+ const (
103
+ NoError = 0
104
+ Unexpected = 1
105
+ NoVPNPermissions = 2 // Unused
106
+ AuthenticationFailure = 3
107
+ UDPConnectivity = 4
108
+ Unreachable = 5
109
+ VpnStartFailure = 6 // Unused
110
+ IllegalConfiguration = 7 // Electron only
111
+ ShadowsocksStartFailure = 8 // Unused
112
+ ConfigureSystemProxyFailure = 9 // Unused
113
+ NoAdminPermissions = 10 // Unused
114
+ UnsupportedRoutingTable = 11 // Unused
115
+ SystemMisconfigured = 12 // Electron only
116
+ )
117
+
102
118
const reachabilityTimeout = 10 * time .Second
103
119
104
120
// CheckConnectivity determines whether the Shadowsocks proxy can relay TCP and UDP traffic under
105
121
// the current network. Parallelizes the execution of TCP and UDP checks, selects the appropriate
106
122
// error code to return accounting for transient network failures.
107
123
// Returns an error if an unexpected error ocurrs.
108
- func CheckConnectivity (client * Client ) (neterrors.Error , error ) {
109
- return connectivity .CheckConnectivity (client )
124
+ func CheckConnectivity (client * Client ) (int , error ) {
125
+ errCode , err := connectivity .CheckConnectivity ((* outline .Client )(client ))
126
+ return errCode .Number (), err
110
127
}
111
128
112
129
// CheckServerReachable determines whether the server at `host:port` is reachable over TCP.
0 commit comments