Browse Source

SSDP logging and interval_timer (#1734)

* SSDP: also log the User-Agent

* SSDP: also log the User-Agent

* SSDP: also log the User-Agent

* SSDP: ssdp_broadcast_interval in seconds, configurable via GUI -> Specials

* SSDP: ssdp_broadcast_interval as optional parater to the SSDP class

* SSDP: less is more: start_ssdp(*args, **kwargs):

* SSDP: less is more: start_ssdp(*args, **kwargs):

* SSDP: handle if no User-Agent specified

* SSDP: small change

Co-authored-by: Safihre <safihre@sabnzbd.org>
tags/3.2.0Beta1
Sander 4 years ago
committed by GitHub
parent
commit
1a4ba51dec
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      SABnzbd.py
  2. 2
      sabnzbd/cfg.py
  3. 9
      sabnzbd/interface.py
  4. 9
      sabnzbd/utils/ssdp.py

1
SABnzbd.py

@ -1510,6 +1510,7 @@ def main():
"SABnzbd Team",
"https://sabnzbd.org/",
"SABnzbd %s" % sabnzbd.__version__,
ssdp_broadcast_interval=sabnzbd.cfg.ssdp_broadcast_interval(),
)
# Have to keep this running, otherwise logging will terminate

2
sabnzbd/cfg.py

@ -298,6 +298,8 @@ url_base = OptionStr("misc", "url_base", "/sabnzbd", validation=validate_strip_r
host_whitelist = OptionList("misc", "host_whitelist", validation=all_lowercase)
max_url_retries = OptionNumber("misc", "max_url_retries", 10, 1)
downloader_sleep_time = OptionNumber("misc", "downloader_sleep_time", 10, 0)
ssdp_broadcast_interval = OptionNumber("misc", "ssdp_broadcast_interval", 15, 1, 600)
##############################################################################
# Config - Notifications

9
sabnzbd/interface.py

@ -471,8 +471,12 @@ class MainPage:
@secured_expose
def description_xml(self, **kwargs):
""" Keep web crawlers out """
logging.debug("description.xml was requested by %s", cherrypy.request.remote.ip)
""" Provide the description.xml which was broadcast via SSDP """
logging.debug(
"description.xml was requested from %s by %s",
cherrypy.request.remote.ip,
cherrypy.request.headers.get("User-Agent", "??"),
)
cherrypy.response.headers["Content-Type"] = "application/xml"
return utob(sabnzbd.utils.ssdp.server_ssdp_xml())
@ -1347,6 +1351,7 @@ SPECIAL_VALUE_LIST = (
"ipv6_servers",
"selftest_host",
"rating_host",
"ssdp_broadcast_interval",
)
SPECIAL_LIST_LIST = ("rss_odd_titles", "quick_check_ext_ignore", "host_whitelist")

9
sabnzbd/utils/ssdp.py

@ -44,7 +44,7 @@ from typing import Optional
class SSDP(Thread):
def __init__(self, host, server_name, url, description, manufacturer, manufacturer_url, model):
def __init__(self, host, server_name, url, description, manufacturer, manufacturer_url, model, **kwargs):
self.__host = host # Note: this is the LAN IP address!
self.__server_name = server_name
self.__url = url
@ -52,6 +52,7 @@ class SSDP(Thread):
self.__manufacturer = manufacturer
self.__manufacturer_url = manufacturer_url
self.__model = model
self.__ssdp_broadcast_interval = kwargs.get("ssdp_broadcast_interval", 15) # optional, default 15 seconds
self.__myhostname = socket.gethostname()
# a steady uuid: stays the same as long as hostname and ip address stay the same:
@ -122,7 +123,7 @@ OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
except:
# probably no network
pass
time.sleep(5)
time.sleep(self.__ssdp_broadcast_interval)
def serve_xml(self):
"""Returns an XML-structure based on the information being
@ -139,9 +140,9 @@ __SSDP: Optional[SSDP] = None
# Wrapper functions to be called by program
def start_ssdp(host, server_name, url, description, manufacturer, manufacturer_url, model):
def start_ssdp(*args, **kwargs):
global __SSDP
__SSDP = SSDP(host, server_name, url, description, manufacturer, manufacturer_url, model)
__SSDP = SSDP(*args, **kwargs)
__SSDP.start()

Loading…
Cancel
Save