Use if in protocol port detection

This commit is contained in:
shortcutme 2019-03-16 00:32:50 +01:00
parent 6d2a863af5
commit 16f29b65f2
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -171,13 +171,14 @@ class SiteAnnouncer(object):
if "://" not in tracker or not re.match("^[A-Za-z0-9:/\\.#-]+$", tracker):
return None
protocol, address = tracker.split("://", 1)
try:
if ":" in address:
ip, port = address.rsplit(":", 1)
except ValueError as err:
else:
ip = address
port = 80
if protocol.startswith("https"):
port = 443
else:
port = 80
back = {}
back["protocol"] = protocol
back["address"] = address