Skip to content

Commit 9f81131

Browse files
committed
Fix interface lookup error on Android mobile platforms
On Android, InterfaceByName can fail due to SELinux restrictions, but for link-local addresses with zone identifiers, the zone is sufficient for routing and we can proceed without source binding. This fixes the 'interface wlan0 not found' error during multicast peer discovery.
1 parent 4949b90 commit 9f81131

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/core/link_tcp.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,24 @@ func (l *linkTCP) dialerFor(dst *net.TCPAddr, sintf string) (*net.Dialer, error)
6969
dialer.Control = l.getControl(sintf)
7070
ief, err := net.InterfaceByName(sintf)
7171
if err != nil {
72+
// On mobile platforms (Android/iOS), InterfaceByName may fail due to
73+
// permission restrictions (SELinux on Android), but for link-local
74+
// addresses with zone identifiers, the zone is sufficient for routing
75+
// and we can proceed without source binding
76+
if dst.IP.IsLinkLocalUnicast() && dst.Zone != "" {
77+
return dialer, nil
78+
}
7279
return nil, fmt.Errorf("interface %q not found", sintf)
7380
}
7481
if ief.Flags&net.FlagUp == 0 {
7582
return nil, fmt.Errorf("interface %q is not up", sintf)
7683
}
7784
addrs, err := ief.Addrs()
7885
if err != nil {
86+
// Same mobile platform handling for address lookup failures
87+
if dst.IP.IsLinkLocalUnicast() && dst.Zone != "" {
88+
return dialer, nil
89+
}
7990
return nil, fmt.Errorf("interface %q addresses not available: %w", sintf, err)
8091
}
8192
for addrindex, addr := range addrs {

0 commit comments

Comments
 (0)