mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-05 21:19:08 +02:00
[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:
@@ -103,6 +103,22 @@ func (e *Engine) setFileDropTunnel() {
|
||||
e.fileDrop.SetTunnel(dial, e.statusRecorder.GetLocalPeerState().FQDN)
|
||||
}
|
||||
|
||||
// restartFileDrop rebinds the receiver after the platform replaced the tunnel
|
||||
// device. The listeners are bound to the overlay address of the interface being
|
||||
// swapped out and do not survive it: Android renews the tun on every route
|
||||
// change, which leaves the IPv4 listener dead with accept4: invalid argument.
|
||||
func (e *Engine) restartFileDrop() {
|
||||
e.syncMsgMux.Lock()
|
||||
defer e.syncMsgMux.Unlock()
|
||||
|
||||
if e.fileDrop == nil || !e.fileDropRunning || e.wgInterface == nil {
|
||||
return
|
||||
}
|
||||
|
||||
e.stopFileDrop()
|
||||
e.startFileDrop()
|
||||
}
|
||||
|
||||
func (e *Engine) stopFileDrop() {
|
||||
if e.fileDrop == nil {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user