Detect the public IP and ISP/ASN reached through each network interface. On a multi-WAN box this reveals which physical link goes to which ISP -- essential for troubleshooting when one of several uplinks is flaky. Makes an outbound call to a third-party geo-IP service (ipinfo.io, then
(interface=None)
| 1001 | for path in _OUI_DB_PATHS: |
| 1002 | try: |
| 1003 | with open(path, encoding='utf-8', errors='replace') as f: |
| 1004 | for line in f: |
| 1005 | line = line.strip() |
| 1006 | if not line or line.startswith('#'): |
| 1007 | continue |
| 1008 | parts = re.split(r'\s+', line, maxsplit=1) |
| 1009 | if len(parts) != 2: |
| 1010 | continue |
| 1011 | pfx = re.sub(r'[^0-9a-fA-F]', '', parts[0]).lower() |
| 1012 | if len(pfx) < 6: |
| 1013 | continue |
| 1014 | pfx = pfx[:6] |
| 1015 | if not _is_universal_prefix(pfx): |
| 1016 | continue |
| 1017 | db.setdefault(pfx, parts[1].strip()) |
| 1018 | if len(db) >= _OUI_DB_CAP: |
| 1019 | break |
| 1020 | except OSError: |
| 1021 | continue |
| 1022 | if len(db) >= _OUI_DB_CAP: |
| 1023 | break |
| 1024 | _oui_db_cache = db |
| 1025 | return db |
| 1026 | |
| 1027 | |
| 1028 | def _vendor_for_prefix(prefix6): |
| 1029 | return _load_oui_db().get(prefix6) |
| 1030 | |
| 1031 | |
| 1032 | def _classify_mac(mac): |
| 1033 | """Classify one MAC. Returns {klass, vendor, note}. |
| 1034 | |
| 1035 | klass ∈ {'universal', 'spoofed_vendor_oui', 'virtual_laa', 'randomized', |
| 1036 | 'invalid'}. A universal address is a normal burned-in NIC; the |
| 1037 | three LAA buckets are kept distinct so privacy randomization (benign, an |
| 1038 | aggregate) never gets conflated with a vendor OUI wearing the LAA bit |
no test coverage detected