diff options
author | Riccardo Spagni <ric@spagni.net> | 2015-12-30 12:28:03 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2015-12-30 12:28:03 +0200 |
commit | 7223eebbe71833e895fca95267cb243834dedf83 (patch) | |
tree | a5d48783316ff837e353c51a29b54f5324dd0bb1 /external/miniupnpc/pymoduletest.py | |
parent | Merge pull request #575 (diff) | |
parent | no longer need to pass the size to rapidjson (diff) | |
download | monero-7223eebbe71833e895fca95267cb243834dedf83.tar.xz |
Merge pull request #577
32a2633 no longer need to pass the size to rapidjson (Riccardo Spagni)
bd8e0fd add missing miniupnpc files, modify cmake to not build miniupnpc tests and to fix an issue with finding miniupnpcstrings (Riccardo Spagni)
7da9905 updated miniupnpc (Riccardo Spagni)
Diffstat (limited to 'external/miniupnpc/pymoduletest.py')
-rwxr-xr-x | external/miniupnpc/pymoduletest.py | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/external/miniupnpc/pymoduletest.py b/external/miniupnpc/pymoduletest.py index d35a3b092..9fddd9c29 100755 --- a/external/miniupnpc/pymoduletest.py +++ b/external/miniupnpc/pymoduletest.py @@ -1,4 +1,5 @@ #! /usr/bin/python +# vim: tabstop=2 shiftwidth=2 expandtab # MiniUPnP project # Author : Thomas Bernard # This Sample code is public domain. @@ -8,14 +9,43 @@ import miniupnpc import sys -# create the object -u = miniupnpc.UPnP() +try: + import argparse + parser = argparse.ArgumentParser() + parser.add_argument('-m', '--multicastif') + parser.add_argument('-p', '--minissdpdsocket') + parser.add_argument('-d', '--discoverdelay', type=int, default=200) + parser.add_argument('-z', '--localport', type=int, default=0) + # create the object + u = miniupnpc.UPnP(**vars(parser.parse_args())) +except: + print 'argparse not available' + i = 1 + multicastif = None + minissdpdsocket = None + discoverdelay = 200 + localport = 0 + while i < len(sys.argv): + print sys.argv[i] + if sys.argv[i] == '-m' or sys.argv[i] == '--multicastif': + multicastif = sys.argv[i+1] + elif sys.argv[i] == '-p' or sys.argv[i] == '--minissdpdsocket': + minissdpdsocket = sys.argv[i+1] + elif sys.argv[i] == '-d' or sys.argv[i] == '--discoverdelay': + discoverdelay = int(sys.argv[i+1]) + elif sys.argv[i] == '-z' or sys.argv[i] == '--localport': + localport = int(sys.argv[i+1]) + else: + raise Exception('invalid argument %s' % sys.argv[i]) + i += 2 + # create the object + u = miniupnpc.UPnP(multicastif, minissdpdsocket, discoverdelay, localport) + 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 @@ -30,6 +60,8 @@ except Exception, e: print 'local ip address :', u.lanaddr print 'external ip address :', u.externalipaddress() print u.statusinfo(), u.connectiontype() +print 'total bytes : sent', u.totalbytesent(), 'received', u.totalbytereceived() +print 'total packets : sent', u.totalpacketsent(), 'received', u.totalpacketreceived() #print u.addportmapping(64000, 'TCP', # '192.168.1.166', 63000, 'port mapping test', '') @@ -49,4 +81,8 @@ while True: i = i + 1 print u.getspecificportmapping(port, proto) +try: + print u.getportmappingnumberofentries() +except Exception, e: + print 'GetPortMappingNumberOfEntries() is not supported :', e |