Add explicit Android VPN LAN routes
This commit is contained in:
@@ -30,8 +30,8 @@ android {
|
|||||||
applicationId "su.cin.rapvpn"
|
applicationId "su.cin.rapvpn"
|
||||||
minSdk 26
|
minSdk 26
|
||||||
targetSdk 35
|
targetSdk 35
|
||||||
versionCode 195
|
versionCode 196
|
||||||
versionName "0.2.195"
|
versionName "0.2.196"
|
||||||
buildConfigField "String", "DEFAULT_BACKEND_URL", "\"${normalizeGradleString(defaultBackendUrl)}\""
|
buildConfigField "String", "DEFAULT_BACKEND_URL", "\"${normalizeGradleString(defaultBackendUrl)}\""
|
||||||
buildConfigField "String", "DEFAULT_CLUSTER_ID", "\"${normalizeGradleString(defaultClusterId)}\""
|
buildConfigField "String", "DEFAULT_CLUSTER_ID", "\"${normalizeGradleString(defaultClusterId)}\""
|
||||||
buildConfigField "String", "DEFAULT_ORGANIZATION_ID", "\"${normalizeGradleString(defaultOrganizationId)}\""
|
buildConfigField "String", "DEFAULT_ORGANIZATION_ID", "\"${normalizeGradleString(defaultOrganizationId)}\""
|
||||||
|
|||||||
@@ -441,6 +441,8 @@ public class RapDiagnosticService extends Service {
|
|||||||
result = runVPNPageProbe(params);
|
result = runVPNPageProbe(params);
|
||||||
} else if ("vpn_tcp_connect".equals(type) || "vpn_rdp_probe".equals(type)) {
|
} else if ("vpn_tcp_connect".equals(type) || "vpn_rdp_probe".equals(type)) {
|
||||||
result = runVPNTCPConnect(params.optString("host", "192.168.200.95"), params.optInt("port", 3389), params.optInt("timeout_ms", 7000));
|
result = runVPNTCPConnect(params.optString("host", "192.168.200.95"), params.optInt("port", 3389), params.optInt("timeout_ms", 7000));
|
||||||
|
} else if ("vpn_tcp_connect_default".equals(type)) {
|
||||||
|
result = runDefaultTCPConnect(params.optString("host", "192.168.200.95"), params.optInt("port", 3389), params.optInt("timeout_ms", 7000));
|
||||||
} else if ("vpn_dns_lookup".equals(type)) {
|
} else if ("vpn_dns_lookup".equals(type)) {
|
||||||
result = runVPNDNSLookup(params.optString("host", "2ip.ru"));
|
result = runVPNDNSLookup(params.optString("host", "2ip.ru"));
|
||||||
} else if ("open_url".equals(type)) {
|
} else if ("open_url".equals(type)) {
|
||||||
@@ -1595,6 +1597,30 @@ public class RapDiagnosticService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String runDefaultTCPConnect(String host, int port, int timeoutMs) {
|
||||||
|
if (port <= 0 || port > 65535) {
|
||||||
|
return "vpn_tcp_connect_default " + host + ":" + port + " -> invalid port";
|
||||||
|
}
|
||||||
|
if (timeoutMs < 1000) {
|
||||||
|
timeoutMs = 1000;
|
||||||
|
}
|
||||||
|
if (timeoutMs > 30000) {
|
||||||
|
timeoutMs = 30000;
|
||||||
|
}
|
||||||
|
long started = System.currentTimeMillis();
|
||||||
|
try {
|
||||||
|
InetAddress address = InetAddress.getByName(host);
|
||||||
|
try (Socket socket = new Socket()) {
|
||||||
|
socket.connect(new InetSocketAddress(address, port), timeoutMs);
|
||||||
|
long elapsed = System.currentTimeMillis() - started;
|
||||||
|
return "vpn_tcp_connect_default " + host + ":" + port + " -> connected address=" + address.getHostAddress() + " local=" + socket.getLocalAddress().getHostAddress() + " ms=" + elapsed;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
long elapsed = System.currentTimeMillis() - started;
|
||||||
|
return "vpn_tcp_connect_default " + host + ":" + port + " -> " + e.getClass().getSimpleName() + ": " + e.getMessage() + " ms=" + elapsed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Network waitForVPNNetwork(int timeoutMs) {
|
private Network waitForVPNNetwork(int timeoutMs) {
|
||||||
long deadline = System.currentTimeMillis() + Math.max(0, timeoutMs);
|
long deadline = System.currentTimeMillis() + Math.max(0, timeoutMs);
|
||||||
Network vpn;
|
Network vpn;
|
||||||
|
|||||||
@@ -3878,6 +3878,9 @@ public class RapVpnService extends VpnService {
|
|||||||
LinkedHashSet<String> routes = new LinkedHashSet<>();
|
LinkedHashSet<String> routes = new LinkedHashSet<>();
|
||||||
if (fullTunnel) {
|
if (fullTunnel) {
|
||||||
routes.add("0.0.0.0/0");
|
routes.add("0.0.0.0/0");
|
||||||
|
routes.add("10.0.0.0/8");
|
||||||
|
routes.add("172.16.0.0/12");
|
||||||
|
routes.add("192.168.0.0/16");
|
||||||
return routes;
|
return routes;
|
||||||
}
|
}
|
||||||
routes.addAll(splitRoutes);
|
routes.addAll(splitRoutes);
|
||||||
|
|||||||
Reference in New Issue
Block a user