Fix Android VPN traffic from external apps

This commit is contained in:
2026-05-14 23:35:43 +03:00
parent 04c46042d9
commit 4e694dc903
2 changed files with 11 additions and 7 deletions
+2 -2
View File
@@ -30,8 +30,8 @@ android {
applicationId "su.cin.rapvpn"
minSdk 26
targetSdk 35
versionCode 182
versionName "0.2.182"
versionCode 183
versionName "0.2.183"
buildConfigField "String", "DEFAULT_BACKEND_URL", "\"${normalizeGradleString(defaultBackendUrl)}\""
buildConfigField "String", "DEFAULT_CLUSTER_ID", "\"${normalizeGradleString(defaultClusterId)}\""
buildConfigField "String", "DEFAULT_ORGANIZATION_ID", "\"${normalizeGradleString(defaultOrganizationId)}\""
@@ -1771,11 +1771,15 @@ public class RapVpnService extends VpnService {
byte[] copy = new byte[length];
System.arraycopy(packet, 0, copy, 0, length);
if (!hasIPv4Source(copy, length)) {
long mismatch = uplinkSourceMismatchPackets.incrementAndGet();
Log.w(TAG, "vpn uplink source is not vpn address; dropping " + packetSummary(copy, length));
writeRuntimeDetail("source_drop", packetSummary(copy, length), "uplink", -1, mismatch, "SOURCE_MISMATCH");
recordUplinkDrop(length);
return;
String natKey = natKeyForOutboundReturn(copy, length);
if (natKey.isEmpty() || !rewriteIPv4SourceToVPN(copy, length, natKey)) {
long mismatch = uplinkSourceMismatchPackets.incrementAndGet();
Log.w(TAG, "vpn uplink source is not vpn address; dropping " + packetSummary(copy, length));
writeRuntimeDetail("source_drop", packetSummary(copy, length), "uplink", -1, mismatch, "SOURCE_MISMATCH");
recordUplinkDrop(length);
return;
}
writeRuntimeDetail("source_nat", packetSummary(copy, length), "uplink", -1, -1, "");
}
if (clampIPv4TCPMSS(copy, length, VPN_TCP_MSS_CLAMP)) {
writeRuntimeDetail("tcp_mss_clamp", packetSummary(copy, length), "uplink_tcp", -1, -1, "");