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