mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2025-10-08 14:54:36 +00:00
Update natpmp_upnp.py
This commit is contained in:
parent
f469c3d302
commit
2b70c7e906
1 changed files with 40 additions and 25 deletions
|
|
@ -156,9 +156,9 @@ def add_port_mapping():
|
||||||
try:
|
try:
|
||||||
natpmp.map_port(
|
natpmp.map_port(
|
||||||
natpmp.NATPMP_PROTOCOL_UDP,
|
natpmp.NATPMP_PROTOCOL_UDP,
|
||||||
43210,
|
BS_PORT,
|
||||||
43210,
|
BS_PORT,
|
||||||
0,
|
14400,
|
||||||
gateway_ip=natpmp.get_gateway_addr(),
|
gateway_ip=natpmp.get_gateway_addr(),
|
||||||
)
|
)
|
||||||
if confirm_port():
|
if confirm_port():
|
||||||
|
|
@ -180,6 +180,7 @@ def add_port_mapping():
|
||||||
# bui.getsound('shieldDown').play() -> RuntimeError : Sound creation failed
|
# bui.getsound('shieldDown').play() -> RuntimeError : Sound creation failed
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
local_ip = (
|
local_ip = (
|
||||||
(
|
(
|
||||||
[
|
[
|
||||||
|
|
@ -216,7 +217,8 @@ def add_port_mapping():
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
except SOAPError:
|
except SOAPError:
|
||||||
pass
|
if confirm_port():
|
||||||
|
return
|
||||||
service.AddPortMapping(
|
service.AddPortMapping(
|
||||||
NewRemoteHost="",
|
NewRemoteHost="",
|
||||||
NewExternalPort=BS_PORT,
|
NewExternalPort=BS_PORT,
|
||||||
|
|
@ -225,7 +227,7 @@ def add_port_mapping():
|
||||||
NewInternalClient=str(local_ip),
|
NewInternalClient=str(local_ip),
|
||||||
NewEnabled="1",
|
NewEnabled="1",
|
||||||
NewPortMappingDescription="Bombsquad",
|
NewPortMappingDescription="Bombsquad",
|
||||||
NewLeaseDuration=0,
|
NewLeaseDuration=14400,
|
||||||
)
|
)
|
||||||
if confirm_port():
|
if confirm_port():
|
||||||
babase.screenmessage(
|
babase.screenmessage(
|
||||||
|
|
@ -233,11 +235,25 @@ def add_port_mapping():
|
||||||
)
|
)
|
||||||
bui.getsound("shieldUp").play()
|
bui.getsound("shieldUp").play()
|
||||||
except (SOAPError, HTTPError, UnicodeDecodeError):
|
except (SOAPError, HTTPError, UnicodeDecodeError):
|
||||||
babase.screenmessage('You will need to manualy add the port on the router :(')
|
babase.screenmessage('You will need to manualy add the port at the router :(')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@threaded
|
@threaded
|
||||||
def delete_port_mapping():
|
def delete_port_mapping():
|
||||||
|
import socket
|
||||||
|
import natpmp
|
||||||
|
from natpmp import NATPMPUnsupportedError, NATPMPNetworkError
|
||||||
|
|
||||||
|
try:
|
||||||
|
natpmp.map_port(
|
||||||
|
natpmp.NATPMP_PROTOCOL_UDP,
|
||||||
|
BS_PORT,
|
||||||
|
BS_PORT,
|
||||||
|
0,
|
||||||
|
gateway_ip=natpmp.get_gateway_addr(),
|
||||||
|
)
|
||||||
|
except (NATPMPUnsupportedError, NATPMPNetworkError):
|
||||||
import upnpy
|
import upnpy
|
||||||
from upnpy.exceptions import SOAPError
|
from upnpy.exceptions import SOAPError
|
||||||
|
|
||||||
|
|
@ -252,8 +268,7 @@ def delete_port_mapping():
|
||||||
for service in upnp_dev.services:
|
for service in upnp_dev.services:
|
||||||
if service in WAN_SERVICE_NAMES:
|
if service in WAN_SERVICE_NAMES:
|
||||||
service = upnp_dev[service]
|
service = upnp_dev[service]
|
||||||
service.DeletePortMapping(
|
service.DeletePortMapping(NewRemoteHost="", NewExternalPort=BS_PORT, NewProtocol="UDP")
|
||||||
NewRemoteHost="", NewExternalPort=BS_PORT, NewProtocol="UDP")
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue