upnp port forwarding
[p2pool.git] / nattraverso / pynupnp / __init__.py
1 """
2 This package offers ways to retreive ip addresses of the machine, and map ports
3 through UPnP devices.
4
5 @author: Raphael Slinckx
6 @copyright: Copyright 2005
7 @license: LGPL
8 @contact: U{raphael@slinckx.net<mailto:raphael@slinckx.net>}
9 @version: 0.1.0
10 """
11 __revision__ = "$id"
12
13 from nattraverso.pynupnp.upnp import search_upnp_device, UPnPMapper
14
15 def get_external_ip():
16         """
17         Returns a deferred which will be called with the WAN ip address
18         retreived through UPnP. The ip is a string of the form "x.x.x.x"
19         
20         @return: A deferred called with the external ip address of this host
21         @rtype: L{twisted.internet.defer.Deferred}
22         """
23         return search_upnp_device().addCallback(lambda x: x.get_external_ip())
24
25 def get_port_mapper():
26         """
27         Returns a deferred which will be called with a L{UPnPMapper} instance.
28         This is a L{nattraverso.portmapper.NATMapper} implementation.
29         
30         @return: A deferred called with the L{UPnPMapper} instance.
31         @rtype: L{twisted.internet.defer.Deferred}
32         """
33         return search_upnp_device().addCallback(lambda x: UPnPMapper(x))