Skip to content

Commit

Permalink
refactor(client/cordova/android): remove dead reachability test code (#…
Browse files Browse the repository at this point in the history
…2054)

The logic has already been removed in #1663 , this PR cleans up the dead code for Android.
  • Loading branch information
jyyi1 authored Jul 19, 2024
1 parent 8d81ebe commit 2f4009f
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ interface IVpnTunnelService {
*/
boolean isTunnelActive(String tunnelId);

/**
* Determines whether a server is reachable via TCP.
*
* @param host IP or hostname string.
* @return port TCP port number.
*/
boolean isServerReachable(String host, int port);

/**
* Initializes the error reporting framework on the VPN service process.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ public boolean isTunnelActive(String tunnelId) {
return VpnTunnelService.this.isTunnelActive(tunnelId);
}

@Override
public boolean isServerReachable(String host, int port) {
return VpnTunnelService.this.isServerReachable(host, port);
}

@Override
public void initErrorReporting(String apiKey) {
VpnTunnelService.this.initErrorReporting(apiKey);
Expand Down Expand Up @@ -339,15 +334,6 @@ private synchronized boolean isTunnelActive(final String tunnelId) {
return tunnelConfig.id.equals(tunnelId);
}

private boolean isServerReachable(final String host, final int port) {
try {
Shadowsocks.checkServerReachable(host, port);
} catch (Exception e) {
return false;
}
return true;
}

/* Helper method to tear down an active tunnel. */
private void tearDownActiveTunnel() {
stopVpnTunnel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public enum Action {
STOP("stop"),
ON_STATUS_CHANGE("onStatusChange"),
IS_RUNNING("isRunning"),
IS_REACHABLE("isServerReachable"),
INIT_ERROR_REPORTING("initializeErrorReporting"),
REPORT_EVENTS("reportEvents"),
QUIT("quitApplication");
Expand Down Expand Up @@ -205,10 +204,6 @@ private void executeAsync(
callback.sendPluginResult(new PluginResult(PluginResult.Status.OK, isActive));

// Static actions
} else if (Action.IS_REACHABLE.is(action)) {
boolean isReachable =
this.vpnTunnelService.isServerReachable(args.getString(0), args.getInt(1));
callback.sendPluginResult(new PluginResult(PluginResult.Status.OK, isReachable));
} else if (Action.INIT_ERROR_REPORTING.is(action)) {
errorReportingApiKey = args.getString(0);
// Treat failures to initialize error reporting as unexpected by propagating exceptions.
Expand Down
12 changes: 0 additions & 12 deletions client/src/tun2socks/outline/shadowsocks/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package shadowsocks
import (
"fmt"
"net"
"strconv"
"time"

"github.com/Jigsaw-Code/outline-apps/client/src/tun2socks/outline"
Expand Down Expand Up @@ -125,14 +124,3 @@ func CheckConnectivity(client *Client) (int, error) {
errCode, err := connectivity.CheckConnectivity((*outline.Client)(client))
return errCode.Number(), err
}

// CheckServerReachable determines whether the server at `host:port` is reachable over TCP.
// Returns an error if the server is unreachable.
func CheckServerReachable(host string, port int) error {
conn, err := net.DialTimeout("tcp", net.JoinHostPort(host, strconv.Itoa(port)), reachabilityTimeout)
if err != nil {
return err
}
conn.Close()
return nil
}

0 comments on commit 2f4009f

Please sign in to comment.