diff --git a/SABnzbd.py b/SABnzbd.py index f3ac53a..86aea31 100755 --- a/SABnzbd.py +++ b/SABnzbd.py @@ -86,6 +86,7 @@ from sabnzbd.misc import ( upload_file_to_sabnzbd, is_localhost, is_lan_addr, + ip_in_subnet, ) from sabnzbd.filesystem import get_ext, real_path, long_path, globber_full, remove_file from sabnzbd.panic import panic_tmpl, panic_port, panic_host, panic, launch_a_browser @@ -1505,7 +1506,14 @@ def main(): external_host = localipv4() logging.debug("Using %s as host address for Bonjour and SSDP", external_host) - if is_lan_addr(external_host): + # Only broadcast to local network addresses. If local ranges have been defined, further + # restrict broadcasts to those specific ranges in order to avoid broadcasting to the "wrong" + # private network when the system is connected to multiple such networks (e.g. a corporate + # VPN in addition to a standard household LAN). + if is_lan_addr(external_host) and ( + (not sabnzbd.cfg.local_ranges()) or any(ip_in_subnet(external_host, r) for r in sabnzbd.cfg.local_ranges()) + ): + # Start Bonjour and SSDP sabnzbd.zconfig.set_bonjour(external_host, cherryport) # Set URL for browser for external hosts