py.py 409 B

1234567891011121314151617
  1. import miniupnpc
  2. upnp = miniupnpc.UPnP()
  3. upnp.discoverdelay = 10
  4. upnp.discover()
  5. upnp.selectigd()
  6. port = 8443
  7. # addportmapping(external-port, protocol, internal-host, internal-port, description, remote-host)
  8. upnp.addportmapping(port, 'TCP', upnp.lanaddr, port, 'testing', '')
  9. externalipaddress = upnp.externalipaddress()
  10. print('external ip address : ', 'https://' + externalipaddress + ':' + str(port))