@@ -1443,7 +1443,13 @@ class BraveVPNService :
1443
1443
logd(" on pref change, key: $key " )
1444
1444
when (key) {
1445
1445
PersistentState .BRAVE_MODE -> {
1446
- io(" braveModeChange" ) { setTunMode() }
1446
+ io(" braveModeChange" ) {
1447
+ // change in brave mode, requires restart of the vpn (to set routes in vpn),
1448
+ // tunMode (to set the tun mode), and dnsAlg (to update the dns alg) in go
1449
+ restartVpnWithNewAppConfig(reason = " braveMode" )
1450
+ setTunMode()
1451
+ updateDnsAlg()
1452
+ }
1447
1453
notificationManager.notify(SERVICE_ID , updateNotificationBuilder())
1448
1454
}
1449
1455
PersistentState .LOCAL_BLOCK_LIST -> {
@@ -2995,7 +3001,7 @@ class BraveVPNService :
2995
3001
}
2996
3002
2997
3003
if (trapVpnDns) {
2998
- logd(" flow: dns-request, returning Ipn .Base, $uid " )
3004
+ logd(" flow: dns-request, returning ${ Backend .Base } , $uid , $connId " )
2999
3005
return @runBlocking persistAndConstructFlowResponse(null , Backend .Base , connId, uid)
3000
3006
}
3001
3007
@@ -3043,22 +3049,22 @@ class BraveVPNService :
3043
3049
val proxyId = " ${ProxyManager .ID_WG_BASE }${wgConfig.id} "
3044
3050
// even if inactive, route connections to wg if lockdown/catch-all is enabled to
3045
3051
// avoid leaks
3046
- return if (wgConfig.isActive || wgConfig.isLockdown || wgConfig.isCatchAll) {
3052
+ if (wgConfig.isActive || wgConfig.isLockdown || wgConfig.isCatchAll) {
3047
3053
val canRoute = vpnAdapter?.canRouteIp(proxyId, connTracker.destIP, true )
3048
3054
if (canRoute == true ) {
3049
3055
logd(" flow: wg is active/lockdown/catch-all; $proxyId , $connId , $uid " )
3050
- persistAndConstructFlowResponse(connTracker, proxyId, connId, uid)
3056
+ return persistAndConstructFlowResponse(connTracker, proxyId, connId, uid)
3051
3057
} else {
3052
3058
logd(" flow: wg is active/lockdown/catch-all, but no route, $connId , $uid " )
3053
- persistAndConstructFlowResponse(connTracker, Backend .Base , connId, uid)
3059
+ return persistAndConstructFlowResponse(connTracker, Backend .Base , connId, uid)
3054
3060
}
3055
3061
} else {
3056
- logd(" flow: wg is not active; using base, $connId , $uid " )
3057
- persistAndConstructFlowResponse(connTracker, Backend .Base , connId, uid)
3062
+ // fall-through, no lockdown/catch-all/active wg found, so proceed with other checks
3058
3063
}
3059
3064
}
3060
3065
3061
3066
// no need to check for other proxies if the protocol is not TCP or UDP
3067
+ // fixme: is this even needed?
3062
3068
if (
3063
3069
connTracker.protocol != Protocol .TCP .protocolType &&
3064
3070
connTracker.protocol != Protocol .UDP .protocolType
@@ -3132,7 +3138,7 @@ class BraveVPNService :
3132
3138
3133
3139
// chose socks5 proxy over http proxy
3134
3140
if (appConfig.isCustomSocks5Enabled()) {
3135
- val endpoint = runBlocking { appConfig.getSocks5ProxyDetails() }
3141
+ val endpoint = appConfig.getSocks5ProxyDetails()
3136
3142
val packageName = FirewallManager .getPackageNameByUid(uid)
3137
3143
logd(" flow: socks5 proxy is enabled, $packageName , ${endpoint.proxyAppName} " )
3138
3144
// do not block the app if the app is set to forward the traffic via socks5 proxy
@@ -3153,7 +3159,7 @@ class BraveVPNService :
3153
3159
}
3154
3160
3155
3161
if (appConfig.isCustomHttpProxyEnabled()) {
3156
- val endpoint = runBlocking { appConfig.getHttpProxyDetails() }
3162
+ val endpoint = appConfig.getHttpProxyDetails()
3157
3163
val packageName = FirewallManager .getPackageNameByUid(uid)
3158
3164
// do not block the app if the app is set to forward the traffic via http proxy
3159
3165
if (endpoint.proxyAppName == packageName) {
0 commit comments