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:
|
||||
natpmp.map_port(
|
||||
natpmp.NATPMP_PROTOCOL_UDP,
|
||||
43210,
|
||||
43210,
|
||||
0,
|
||||
BS_PORT,
|
||||
BS_PORT,
|
||||
14400,
|
||||
gateway_ip=natpmp.get_gateway_addr(),
|
||||
)
|
||||
if confirm_port():
|
||||
|
|
@ -180,6 +180,7 @@ def add_port_mapping():
|
|||
# bui.getsound('shieldDown').play() -> RuntimeError : Sound creation failed
|
||||
return
|
||||
|
||||
|
||||
local_ip = (
|
||||
(
|
||||
[
|
||||
|
|
@ -216,7 +217,8 @@ def add_port_mapping():
|
|||
)
|
||||
return
|
||||
except SOAPError:
|
||||
pass
|
||||
if confirm_port():
|
||||
return
|
||||
service.AddPortMapping(
|
||||
NewRemoteHost="",
|
||||
NewExternalPort=BS_PORT,
|
||||
|
|
@ -225,7 +227,7 @@ def add_port_mapping():
|
|||
NewInternalClient=str(local_ip),
|
||||
NewEnabled="1",
|
||||
NewPortMappingDescription="Bombsquad",
|
||||
NewLeaseDuration=0,
|
||||
NewLeaseDuration=14400,
|
||||
)
|
||||
if confirm_port():
|
||||
babase.screenmessage(
|
||||
|
|
@ -233,11 +235,25 @@ def add_port_mapping():
|
|||
)
|
||||
bui.getsound("shieldUp").play()
|
||||
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
|
||||
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
|
||||
from upnpy.exceptions import SOAPError
|
||||
|
||||
|
|
@ -252,8 +268,7 @@ def delete_port_mapping():
|
|||
for service in upnp_dev.services:
|
||||
if service in WAN_SERVICE_NAMES:
|
||||
service = upnp_dev[service]
|
||||
service.DeletePortMapping(
|
||||
NewRemoteHost="", NewExternalPort=BS_PORT, NewProtocol="UDP")
|
||||
service.DeletePortMapping(NewRemoteHost="", NewExternalPort=BS_PORT, NewProtocol="UDP")
|
||||
except:
|
||||
pass
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue