-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't follow typical usage examples from readme #42
Comments
@R0CKH0PP3R Could you show the output of print(d.services) This is my output [<Service service_id='urn:upnp-org:serviceId:L3Forwarding1'>, <Service service_id='urn:upnp-org:serviceId:WANCommonIFC1'>, <Service service_id='urn:upnp-org:serviceId:WANIPConn1'>] |
The second last element in your devices list (the bt home hub) is something that might expose the |
I have the same problem:
after this what I can do ? how I list / browse the server ? |
I figured out a solution. Its a little more complicated, as I'm not sure what happened to the API, as it seems to have changed a bit since the README was written. However, I developed and tested this code for my TP-Link ER7206 router, and it works fine. The process is slightly more cumbersome, but not too bad.
|
import upnpclient
# Plucked from https://github.com/ethereum/upnp-port-forward/blob/master/upnp_port_forward/
WAN_SERVICE_NAMES = (
"WANIPConn1",
"WANIPConnection.1", # Nighthawk C7800
"WANPPPConnection.1", # CenturyLink C1100Z
"WANPPPConn1", # Huawei B528s-23a
)
devices = upnpclient.discover()
if devices == []:
print("No devices found")
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# connect() for UDP doesn't send packets
s.connect(('10.0.0.0', 0))
local_ip = s.getsockname()[0]
s.close()
except:
pass
for upnp_dev in devices:
for service in upnp_dev.services:
if service.name in WAN_SERVICE_NAMES:
service.AddPortMapping(
NewRemoteHost="0.0.0.0",
NewExternalPort=43210,
NewProtocol="UDP",
NewInternalPort=43210,
NewInternalClient=local_ip,
NewEnabled="1",
NewPortMappingDescription="Bombsquad",
NewLeaseDuration=14400) have you tried this |
After installing with pip as user, I get the following when trying the usage examples:
The text was updated successfully, but these errors were encountered: