Initial import to Tizen
[profile/ivi/python-twisted.git] / twisted / tap / portforward.py
1
2 # Copyright (c) Twisted Matrix Laboratories.
3 # See LICENSE for details.
4
5 """
6 Support module for making a port forwarder with twistd.
7 """
8 from twisted.protocols import portforward
9 from twisted.python import usage
10 from twisted.application import strports
11
12 class Options(usage.Options):
13     synopsis = "[options]"
14     longdesc = 'Port Forwarder.'
15     optParameters = [
16           ["port", "p", "6666","Set the port number."],
17           ["host", "h", "localhost","Set the host."],
18           ["dest_port", "d", 6665,"Set the destination port."],
19     ]
20
21     compData = usage.Completions(
22         optActions={"host": usage.CompleteHostnames()}
23         )
24
25 def makeService(config):
26     f = portforward.ProxyFactory(config['host'], int(config['dest_port']))
27     return strports.service(config['port'], f)