Repository navigation
ssdp: allow overriding interface address lookup - #195
Merged
Merged
Conversation
lieranderl
force-pushed
the
ssdp-interface-addrs-hook
branch
from
October 2, 2026 12:47
856ed8e to
dda3619
Compare
net.Interface.Addrs fails with "route ip+net: netlinkrib: permission denied" on Android 11+ for non-system apps (golang/go#40569), which makes ssdp.Server.Serve return immediately, so the server is never announced. Add an optional InterfaceAddrs func to ssdp.Server, passed through from dms.Server, so callers can supply a working lookup (e.g. wlynxg/anet). Behaviour is unchanged when it's nil. Also stop panicking in the M-SEARCH handler when the lookup fails; log and skip the response instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lieranderl
force-pushed
the
ssdp-interface-addrs-hook
branch
from
October 2, 2026 12:49
dda3619 to
6a01604
Compare
Owner
|
Why don't you also include the anet package and its function on Android? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Android 11+ (API 30+),
net.Interface.Addrs()fails for ordinary apps because SELinux denies the netlinkRTM_GETADDRrequest. This is a long-standing Go issue: golang/go#40569.When that happens,
ssdp.Server.Servereturns right after it starts, so the server is never announced and clients can't discover it. The HTTP side keeps working fine. Log from a real device (Android 14, running under Termux):The same lookup in the M-SEARCH handler
panics on that error. Today it's only unreachable becauseServehas already exited.Listing interfaces isn't a problem, since
dms.Server.Interfacescan already be set by the caller (for example fromgithub.com/wlynxg/anet). Looking up the addresses insidessdphas no such override.Change
ssdp.Server.InterfaceAddrs func(net.Interface) ([]net.Addr, error): optional. When it's nil,net.Interface.Addrsis used, so existing behaviour is unchanged.dms.Server.InterfaceAddrspasses it through to eachssdp.Server.This adds no Android-specific code or new dependency to dms. A caller on Android would set:
Testing
go build ./...,go vet ./ssdp ./dlna/dmsandgo test ./dlna/...all pass.No behaviour change when the field is unset.
On a real device (Android 14, built natively under Termux with Go 1.26.4,
ssdp.Serveroneth0, with another LAN host listening on 239.255.255.250:1900 for 24 s):Serve()InterfaceAddrsnetlinkrib: permission deniedimmediatelyInterfaceAddrsfromanetLOCATION🤖 Generated with Claude Code