~ari-tczew/ubuntu/natty/clementine/lp-747113

« back to all changes in this revision

Viewing changes to 3rdparty/libportfwd/third-party/miniupnpc-20090605/pymoduletest.py

  • Committer: Artur Rona
  • Date: 2011-04-04 20:05:33 UTC
  • Revision ID: ari-tczew@ubuntu.com-20110404200533-6aclzasj5pp8t1hq
* New upstream release. (LP: #747113)
* Drop all patches, have been applied upstream.
* Update debian/copyright.
* Refresh description in debian/control in order to avoid lintian error.
* Bump debhelper to 8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/python
 
2
# MiniUPnP project
 
3
# Author : Thomas Bernard
 
4
# This Sample code is public domain.
 
5
# website : http://miniupnp.tuxfamily.org/
 
6
 
 
7
# import the python miniupnpc module
 
8
import miniupnpc
 
9
import sys
 
10
 
 
11
# create the object
 
12
u = miniupnpc.UPnP()
 
13
print 'inital(default) values :'
 
14
print ' discoverdelay', u.discoverdelay
 
15
print ' lanaddr', u.lanaddr
 
16
print ' multicastif', u.multicastif
 
17
print ' minissdpdsocket', u.minissdpdsocket
 
18
u.discoverdelay = 200;
 
19
#u.minissdpdsocket = '../minissdpd/minissdpd.sock'
 
20
# discovery process, it usualy takes several seconds (2 seconds or more)
 
21
print 'Discovering... delay=%ums' % u.discoverdelay
 
22
print u.discover(), 'device(s) detected'
 
23
# select an igd
 
24
try:
 
25
  u.selectigd()
 
26
except Exception, e:
 
27
  print 'Exception :', e
 
28
  sys.exit(1)
 
29
# display information about the IGD and the internet connection
 
30
print 'local ip address :', u.lanaddr
 
31
print 'external ip address :', u.externalipaddress()
 
32
print u.statusinfo(), u.connectiontype()
 
33
 
 
34
#print u.addportmapping(64000, 'TCP',
 
35
#                       '192.168.1.166', 63000, 'port mapping test', '')
 
36
#print u.deleteportmapping(64000, 'TCP')
 
37
 
 
38
port = 0
 
39
proto = 'UDP'
 
40
# list the redirections :
 
41
i = 0
 
42
while True:
 
43
        p = u.getgenericportmapping(i)
 
44
        if p==None:
 
45
                break
 
46
        print i, p
 
47
        (port, proto, (ihost,iport), desc, c, d, e) = p
 
48
        #print port, desc
 
49
        i = i + 1
 
50
 
 
51
print u.getspecificportmapping(port, proto)
 
52