Skip to content

Commit 6adb33c

Browse files
author
Alexandr Stelnykovych
committed
Ensure V2Ray route is correct after VPN resume
1 parent 8894dd6 commit 6adb33c

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

daemon/netchange/net_change_detector_linux.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ func (d *Detector) isRoutingChanged() (bool, error) {
5454
for _, testIP := range testIPs {
5555
currentInterface, err := getCurrentRoutingInterface(testIP)
5656
if err != nil {
57-
log.Error("Failed to get current routing interface:", err)
5857
lastErr = err
5958
continue
6059
}
@@ -66,6 +65,9 @@ func (d *Detector) isRoutingChanged() (bool, error) {
6665
}
6766
}
6867

68+
if lastErr != nil {
69+
log.Warning("Failed to determine current routing interface")
70+
}
6971
return false, lastErr
7072
}
7173

@@ -74,7 +76,7 @@ func getCurrentRoutingInterface(destIP net.IP) (*net.Interface, error) {
7476
// Get the outbound IP that would be used to connect to destIP
7577
outboundIP, err := netinfo.GetOutboundIPEx(destIP)
7678
if err != nil {
77-
return nil, fmt.Errorf("failed to get outbound IP for %s: %w", destIP, err)
79+
return nil, err
7880
}
7981
// Find the interface that has this outbound IP
8082
return netinfo.InterfaceByIPAddr(outboundIP)

daemon/service/service_connect.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,13 @@ func (s *Service) connect(originalEntryServerInfo *svrConnInfo, vpnProc vpn.Proc
780780
}
781781
}
782782

783+
if v2rayWrapper != nil {
784+
// Ensure that V2Ray route is correct (e.g. after VPN resume)
785+
if err := s.updateV2RayRoute(v2rayWrapper, false); err != nil {
786+
log.Error(fmt.Errorf("failed to update V2Ray route: %w", err))
787+
}
788+
}
789+
783790
case vpn.CONNECTED:
784791
// since we are connected - keep connection (reconnect if unexpected disconnection)
785792
if s._requiredVpnState == Connect {

0 commit comments

Comments
 (0)