This commit is contained in:
yumoqing 2022-03-13 13:21:01 +08:00
parent c02cc1b4a8
commit a451a976e1
3 changed files with 17 additions and 8 deletions

View File

@ -1,7 +1,7 @@
from traceback import print_exc
from natpmp import NATPMP as pmp
import upnpy
import upnpclient
from requests import get
from .background import Background
@ -16,10 +16,9 @@ class AcrossNat(object):
def init_upnp(self):
try:
upnp = upnpy.UPnP()
igd = upnp.discover()[0]
s_names = [ n for n in igd.services.keys() if n.startswith('WANPPPConn') ]
self.upnp = igd.services[s_names[0]]
igd = upnpclient.discover()[0]
s_names = [ n for n in igd.service_map.keys() if 'WAN' in n and 'Conn' in n]
self.upnp = igd.service_map[s_names[0]]
except Exception as e:
print(e)
print_exc()

View File

@ -1,5 +1,6 @@
import os,sys
import json
from pathlib import Path
from appPublic.dictObject import DictObject
from appPublic.Singleton import SingletonDecorator
from appPublic.folderUtils import ProgramPath
@ -46,12 +47,21 @@ class JsonObject(DictObject):
@SingletonDecorator
class JsonConfig(JsonObject):
pass
def getConfig(path=None,NS=None):
pp = ProgramPath()
if path==None:
path = ProgramPath()
path = pp
cfname = os.path.abspath(os.path.join(path,"conf","config.json"))
# print __name__,cfname
a = JsonConfig(cfname,NS=NS)
ns = {
'home':str(Path.home()),
'workdir':path,
'ProgramPath':pp
}
if NS is not None:
ns.update(NS)
a = JsonConfig(cfname,NS=ns)
return a
if __name__ == '__main__':

View File

@ -7,7 +7,7 @@ numpy
cryptography
brotli
aiohttp
aioupnp
upnpclient
py-natpmp
asyncio
requests