Skip to content

Commit 14f186a

Browse files
committed
proxy: more optimization on socks5 and http proxy
1 parent 361798a commit 14f186a

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

app/src/main/java/com/celzero/bravedns/data/AppConfig.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,15 +1051,18 @@ internal constructor(
10511051

10521052
suspend fun updateCustomSocks5Proxy(proxyEndpoint: ProxyEndpoint) {
10531053
proxyEndpointRepository.update(proxyEndpoint)
1054+
customSocks5Endpoint = proxyEndpoint
10541055
addProxy(ProxyType.SOCKS5, ProxyProvider.CUSTOM)
10551056
}
10561057

10571058
suspend fun updateOrbotProxy(proxyEndpoint: ProxyEndpoint) {
10581059
proxyEndpointRepository.update(proxyEndpoint)
1060+
orbotEndpoint = proxyEndpoint
10591061
}
10601062

10611063
suspend fun updateCustomHttpProxy(proxyEndpoint: ProxyEndpoint) {
10621064
proxyEndpointRepository.update(proxyEndpoint)
1065+
customHttpEndpoint = proxyEndpoint
10631066
addProxy(ProxyType.HTTP, ProxyProvider.CUSTOM)
10641067
}
10651068

app/src/main/java/com/celzero/bravedns/service/BraveVPNService.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3001,7 +3001,7 @@ class BraveVPNService :
30013001
}
30023002

30033003
if (trapVpnDns) {
3004-
logd("flow: dns-request, returning Ipn.Base, $uid")
3004+
logd("flow: dns-request, returning ${Backend.Base}, $uid, $connId")
30053005
return@runBlocking persistAndConstructFlowResponse(null, Backend.Base, connId, uid)
30063006
}
30073007

@@ -3049,22 +3049,22 @@ class BraveVPNService :
30493049
val proxyId = "${ProxyManager.ID_WG_BASE}${wgConfig.id}"
30503050
// even if inactive, route connections to wg if lockdown/catch-all is enabled to
30513051
// avoid leaks
3052-
return if (wgConfig.isActive || wgConfig.isLockdown || wgConfig.isCatchAll) {
3052+
if (wgConfig.isActive || wgConfig.isLockdown || wgConfig.isCatchAll) {
30533053
val canRoute = vpnAdapter?.canRouteIp(proxyId, connTracker.destIP, true)
30543054
if (canRoute == true) {
30553055
logd("flow: wg is active/lockdown/catch-all; $proxyId, $connId, $uid")
3056-
persistAndConstructFlowResponse(connTracker, proxyId, connId, uid)
3056+
return persistAndConstructFlowResponse(connTracker, proxyId, connId, uid)
30573057
} else {
30583058
logd("flow: wg is active/lockdown/catch-all, but no route, $connId, $uid")
3059-
persistAndConstructFlowResponse(connTracker, Backend.Base, connId, uid)
3059+
return persistAndConstructFlowResponse(connTracker, Backend.Base, connId, uid)
30603060
}
30613061
} else {
3062-
logd("flow: wg is not active; using base, $connId, $uid")
3063-
persistAndConstructFlowResponse(connTracker, Backend.Base, connId, uid)
3062+
// fall-through, no lockdown/catch-all/active wg found, so proceed with other checks
30643063
}
30653064
}
30663065

30673066
// no need to check for other proxies if the protocol is not TCP or UDP
3067+
// fixme: is this even needed?
30683068
if (
30693069
connTracker.protocol != Protocol.TCP.protocolType &&
30703070
connTracker.protocol != Protocol.UDP.protocolType

0 commit comments

Comments
 (0)