aboutsummaryrefslogtreecommitdiff
path: root/external/miniupnpc/pymoduletest3.py
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2015-12-30 10:00:50 +0200
committerRiccardo Spagni <ric@spagni.net>2015-12-30 10:00:50 +0200
commitbd8e0fd2a11efe8c0e92ac3a8b8373b87a93ed95 (patch)
tree2e6e0a1dba09939058f9ad930ce2fc3963777631 /external/miniupnpc/pymoduletest3.py
parentupdated miniupnpc (diff)
downloadmonero-bd8e0fd2a11efe8c0e92ac3a8b8373b87a93ed95.tar.xz
add missing miniupnpc files, modify cmake to not build miniupnpc tests and to fix an issue with finding miniupnpcstrings
Diffstat (limited to 'external/miniupnpc/pymoduletest3.py')
-rwxr-xr-xexternal/miniupnpc/pymoduletest3.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/external/miniupnpc/pymoduletest3.py b/external/miniupnpc/pymoduletest3.py
new file mode 100755
index 000000000..d4cf1e22f
--- /dev/null
+++ b/external/miniupnpc/pymoduletest3.py
@@ -0,0 +1,52 @@
+#! /usr/bin/python3
+# MiniUPnP project
+# Author : Thomas Bernard
+# This Sample code is public domain.
+# website : http://miniupnp.tuxfamily.org/
+
+# import the python miniupnpc module
+import miniupnpc
+import sys
+
+# create the object
+u = miniupnpc.UPnP()
+print('inital(default) values :')
+print(' discoverdelay', u.discoverdelay)
+print(' lanaddr', u.lanaddr)
+print(' multicastif', u.multicastif)
+print(' minissdpdsocket', u.minissdpdsocket)
+u.discoverdelay = 200;
+#u.minissdpdsocket = '../minissdpd/minissdpd.sock'
+# discovery process, it usualy takes several seconds (2 seconds or more)
+print('Discovering... delay=%ums' % u.discoverdelay)
+print(u.discover(), 'device(s) detected')
+# select an igd
+try:
+ u.selectigd()
+except Exception as e:
+ print('Exception :', e)
+ sys.exit(1)
+# display information about the IGD and the internet connection
+print('local ip address :', u.lanaddr)
+print('external ip address :', u.externalipaddress())
+print(u.statusinfo(), u.connectiontype())
+
+#print u.addportmapping(64000, 'TCP',
+# '192.168.1.166', 63000, 'port mapping test', '')
+#print u.deleteportmapping(64000, 'TCP')
+
+port = 0
+proto = 'UDP'
+# list the redirections :
+i = 0
+while True:
+ p = u.getgenericportmapping(i)
+ if p==None:
+ break
+ print(i, p)
+ (port, proto, (ihost,iport), desc, c, d, e) = p
+ #print port, desc
+ i = i + 1
+
+print(u.getspecificportmapping(port, proto))
+