return upnp punch using secure xml library

fixes #105
This commit is contained in:
caryoscelus 2022-06-28 23:21:47 +00:00
parent 66001ee8b7
commit cb2347e7d6
3 changed files with 5 additions and 6 deletions

View file

@ -12,3 +12,4 @@ gevent-ws
coincurve
maxminddb
rich
defusedxml>=0.7

View file

@ -28,8 +28,8 @@ class PeerPortchecker(object):
return urllib.request.urlopen(req, timeout=20.0)
def portOpen(self, port):
self.log.info("Not trying to open port using UpnpPunch until it's proven robust...")
return False
# self.log.info("Not trying to open port using UpnpPunch until it's proven robust...")
# return False
try:
UpnpPunch.ask_to_open_port(port, 'ZeroNet', retries=3, protos=["TCP"])
@ -37,7 +37,6 @@ class PeerPortchecker(object):
except Exception as err:
self.log.warning("UpnpPunch run error: %s" % Debug.formatException(err))
return False
return True
def portClose(self, port):

View file

@ -3,8 +3,7 @@ import urllib.request
import http.client
import logging
from urllib.parse import urlparse
from xml.dom.minidom import parseString
from xml.parsers.expat import ExpatError
from defusedxml.minidom import parseString
from gevent import socket
import gevent
@ -105,7 +104,7 @@ def _parse_igd_profile(profile_xml):
"""
try:
dom = parseString(profile_xml)
except ExpatError as e:
except Exception as e:
raise IGDError(
'Unable to parse IGD reply: {0} \n\n\n {1}'.format(profile_xml, e))