fix(v0.1.9): détection IP/interface — filtre VPN WireGuard par flags kernel
- get_local_ip: construit d'abord la liste des IPs physiques (getifaddrs avec IFF_POINTOPOINT exclu + type=1 ARPHRD_ETHER requis), puis vérifie que l'IP choisie par le UDP-connect-trick en fait partie → évite de retourner une IP VPN même quand le trafic y est routé - is_physical: remplace le filtrage par préfixe de nom par type kernel /sys/class/net/<iface>/type == 1 (Ethernet/WiFi) ; exclut WireGuard (type 65534), tunnels et autres interfaces virtuelles nommées librement Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -26,11 +26,13 @@ pub fn current_yday() -> u32 {
|
||||
}
|
||||
|
||||
fn is_physical(name: &str) -> bool {
|
||||
if name == "lo" { return false; }
|
||||
for prefix in &["veth", "docker", "br-", "virbr", "vir", "tun", "tap", "dummy", "bond"] {
|
||||
if name.starts_with(prefix) { return false; }
|
||||
}
|
||||
true
|
||||
// Type 1 = ARPHRD_ETHER (Ethernet + WiFi). WireGuard = 65534, tunnels = autres.
|
||||
let itype: u32 = std::fs::read_to_string(format!("/sys/class/net/{}/type", name))
|
||||
.ok().and_then(|s| s.trim().parse().ok()).unwrap_or(0);
|
||||
if itype != 1 { return false; }
|
||||
// Exclut bridges et interfaces Docker par nom (type 1 aussi)
|
||||
!name.starts_with("br-") && !name.starts_with("docker")
|
||||
&& !name.starts_with("virbr") && !name.starts_with("veth")
|
||||
}
|
||||
|
||||
fn read_sysfs(iface: &str, file: &str) -> Option<String> {
|
||||
|
||||
Reference in New Issue
Block a user