[client] Rebind the file drop receiver when the tun is renewed

Android re-establishes the VpnService interface on every route change, which
replaces tun0 with a fresh device. The file drop listeners are bound to the
overlay address of the interface being swapped out: the IPv4 one dies with
accept4: invalid argument and never comes back, so a peer dialing the overlay
IPv4 address gets an RST. Restart the receiver once the new device is in place.
This commit is contained in:
Zoltan Papp
2026-08-17 00:16:57 +02:00
parent 73cffdb702
commit a94424d563
2 changed files with 24 additions and 1 deletions
+8 -1
View File
@@ -2452,6 +2452,8 @@ func (e *Engine) GetWgV6Addr() netip.Addr {
return e.wgInterface.Address().IPv6
}
// RenewTun swaps the tunnel device for the one behind fd, which the platform
// hands over whenever it re-establishes the interface.
func (e *Engine) RenewTun(fd int) error {
e.syncMsgMux.Lock()
wgInterface := e.wgInterface
@@ -2461,7 +2463,12 @@ func (e *Engine) RenewTun(fd int) error {
return fmt.Errorf("wireguard interface not initialized")
}
return wgInterface.RenewTun(fd)
if err := wgInterface.RenewTun(fd); err != nil {
return err
}
e.restartFileDrop()
return nil
}
// updateDNSForwarder start or stop the DNS forwarder based on the domains and the feature flag