Skip to content

Commit

Permalink
Add UPnP NAT port mapping function
Browse files Browse the repository at this point in the history
  • Loading branch information
lakewik authored Jul 27, 2017
1 parent 8fd4a9d commit 1be35a4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions UI/utilities/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import errno
import hashlib
import requests
import miniupnpc
SYNC_SERVER_URL = "http://localhost:8234"

class Tools:
Expand Down Expand Up @@ -148,3 +149,16 @@ def generate_max_shard_size(self, max_shard_size_input, shard_size_unit):

return max_shard_size

# NETWORK

def map_port_UPnP(self, port, description):
upnp = miniupnpc.UPnP()

upnp.discoverdelay = 10
upnp.discover()

upnp.selectigd()

upnp.addportmapping(port, 'TCP', upnp.lanaddr, port, description, '')


0 comments on commit 1be35a4

Please sign in to comment.