Repository navigation
fix: bars hidden again over the video, LAN-only debug addresses, no leaked menu (#202, #203, #205) #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: bars hidden again over the video, LAN-only debug addresses, no leaked menu (#202, #203, #205) #206
Changes from all commits
baa4d51
c2a83f2
a93b2a3
2937d7a
7741cf0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,24 +15,49 @@ | |
| import java.net.NetworkInterface; | ||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.LinkedHashMap; | ||
| import java.util.List; | ||
| import java.util.Locale; | ||
| import java.util.Map; | ||
|
|
||
| final class NetInfo { | ||
| private static final String TAG = "OpenIPCDecoder"; | ||
|
|
||
| private NetInfo() {} | ||
|
|
||
| /** Interface name prefixes of mobile data (#203): never a LAN the debug page answers. */ | ||
| private static final String[] CELLULAR = { | ||
| "rmnet", "rev_rmnet", "ccmni", "v4-", "clat", "seth", "pdp", "wwan"}; | ||
|
|
||
| /** | ||
| * IPv4 addresses of every interface that is up, the ones worth showing to a user who has | ||
| * to type one in: no loopback (127.0.0.0/8) and no link-local (169.254.0.0/16) (#87, #96). | ||
| * The debug page's addresses (#87, #96): private IPv4 of every interface that is up and | ||
| * not mobile data, Wi-Fi first, then Ethernet, then the rest (#203). | ||
| */ | ||
| static List<String> addresses() { | ||
| Map<String, List<InetAddress>> byInterface = new LinkedHashMap<>(); | ||
| try { | ||
| for (NetworkInterface nif : Collections.list(NetworkInterface.getNetworkInterfaces())) { | ||
| if (!nif.isUp()) continue; | ||
| byInterface.put(nif.getName(), Collections.list(nif.getInetAddresses())); | ||
| } | ||
| } catch (Exception e) { | ||
| Log.w(TAG, "No local address: " + e.getMessage()); | ||
| } | ||
| return lanAddresses(byInterface); | ||
| } | ||
|
|
||
| /** | ||
| * Every IPv4 address a pushed RTP stream can arrive on (the UDP receiver listens on all of | ||
| * them), mobile data and public ones too, for the U view's hint (#68, Qodo on #206): | ||
| * no loopback, link-local or wildcard address. | ||
| */ | ||
| static List<String> udpAddresses() { | ||
| List<String> out = new ArrayList<>(); | ||
| try { | ||
| for (NetworkInterface nif : Collections.list(NetworkInterface.getNetworkInterfaces())) { | ||
| if (!nif.isUp()) continue; | ||
| for (InetAddress a : Collections.list(nif.getInetAddresses())) { | ||
| if (isShown(a) && !out.contains(a.getHostAddress())) out.add(a.getHostAddress()); | ||
| if (isUsable(a) && !out.contains(a.getHostAddress())) out.add(a.getHostAddress()); | ||
| } | ||
| } | ||
| } catch (Exception e) { | ||
|
|
@@ -41,11 +66,54 @@ static List<String> addresses() { | |
| return out; | ||
| } | ||
|
|
||
| static boolean isShown(InetAddress a) { | ||
| static boolean isUsable(InetAddress a) { | ||
| return a instanceof Inet4Address && !a.isLoopbackAddress() && !a.isLinkLocalAddress() | ||
| && !a.isAnyLocalAddress(); | ||
| } | ||
|
|
||
| /** | ||
| * The addresses a LAN client can reach the debug server on, from the interfaces in their | ||
| * system order (#203): no mobile-data interface and only private IPv4 (isShown), as the | ||
| * server answers LAN clients only. Wi-Fi (also a hotspot) first, then Ethernet. | ||
| */ | ||
| static List<String> lanAddresses(Map<String, List<InetAddress>> byInterface) { | ||
| List<String> out = new ArrayList<>(); | ||
| for (int rank = 0; rank <= 2; rank++) { | ||
| for (Map.Entry<String, List<InetAddress>> e : byInterface.entrySet()) { | ||
| String name = e.getKey() == null ? "" : e.getKey().toLowerCase(Locale.ROOT); | ||
| if (isCellular(name) || rank(name) != rank) continue; | ||
| for (InetAddress a : e.getValue()) { | ||
| if (isShown(a) && !out.contains(a.getHostAddress())) out.add(a.getHostAddress()); | ||
|
qodo-free-for-open-source-projects[bot] marked this conversation as resolved.
|
||
| } | ||
| } | ||
| } | ||
| return out; | ||
| } | ||
|
|
||
| static boolean isCellular(String name) { | ||
| for (String prefix : CELLULAR) { | ||
| if (name.startsWith(prefix)) return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| /** 0 Wi-Fi, 1 Ethernet, 2 anything else (USB tethering, a bridge ...). */ | ||
| private static int rank(String name) { | ||
| if (name.startsWith("wlan") || name.startsWith("swlan") || name.startsWith("ap") | ||
| || name.startsWith("wifi")) return 0; | ||
| if (name.startsWith("eth") || name.startsWith("en")) return 1; | ||
| return 2; | ||
| } | ||
|
|
||
| /** | ||
| * An address to show: private IPv4 (10/8, 172.16/12, 192.168/16) — no loopback, no | ||
| * link-local and nothing public or carrier-grade NAT, which the debug server never | ||
| * answers (#203). | ||
| */ | ||
| static boolean isShown(InetAddress a) { | ||
| return a instanceof Inet4Address && a.isSiteLocalAddress(); | ||
| } | ||
|
Comment on lines
113
to
115
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. Local ipv6 addresses disappear NetInfo.isShown() accepts only IPv4 site-local addresses, so link-local and unique-local IPv6 addresses are discarded. lanAddresses() applies this filter to every interface used by the overlay, /stats.json, and UDP hint, preventing eligible local addresses from being advertised. Agent Prompt
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not changed: the shown addresses were IPv4 only before this PR as well (#87, #96). An IPv6 link-local URL needs a zone id (fe80::1%wlan0) that a browser cannot use, and ULA addresses are rare on the LANs this app runs in; a user types the IPv4 address. Only public/CGNAT IPv4 and mobile-data interfaces are dropped (#203). |
||
|
|
||
| /** | ||
| * A client on the local network: loopback, private IPv4 (10/8, 172.16/12, 192.168/16), | ||
| * link-local (169.254/16, fe80::/10) or IPv6 unique-local (fc00::/7). An IPv4 client on a | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2. Usb-tethered addresses are advertised
📎 Requirement gap≡ CorrectnessAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation toolsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kept on purpose: the debug server answers every private client, and a phone sharing its connection over USB (rndis) or a bridge is such a LAN, so its private address is reachable. They come last, after Wi-Fi and Ethernet, as #203 asks for the order; only mobile-data interfaces are left out.