Stop traffic capture and analysis
(self)
| 550 | gateways.add(match.group(1)) |
| 551 | except Exception as e: |
| 552 | logger.debug(f"Gateway detection error: {e}") |
| 553 | if gateways: |
| 554 | logger.info(f"Default gateway(s) (port-scan exempt): {gateways}") |
| 555 | return gateways |
| 556 | |
| 557 | def _derive_lan_networks(self) -> List[ipaddress.IPv4Network]: |
| 558 | nets: set = set() |
| 559 | candidates: set = set() |
| 560 | candidates.update(getattr(self, '_local_ips', set()) or set()) |
| 561 | candidates.update(getattr(self, '_gateway_ips', set()) or set()) |
| 562 | for ip in candidates: |
| 563 | try: |
| 564 | addr = ipaddress.IPv4Address(ip) |
| 565 | except (ValueError, ipaddress.AddressValueError): |
| 566 | continue |
| 567 | if addr.is_loopback or addr.is_link_local or addr.is_multicast: |
| 568 | continue |
| 569 | try: |
| 570 | net = ipaddress.IPv4Network( |
| 571 | f"{ip}/{self.PASSIVE_LAN_PREFIX}", strict=False) |
| 572 | nets.add(net) |
| 573 | except (ValueError, ipaddress.NetmaskValueError): |
| 574 | continue |
| 575 | result = sorted(nets, key=lambda n: int(n.network_address)) |
no test coverage detected