2 # Copyright (c) Twisted Matrix Laboratories.
3 # See LICENSE for details.
7 I am a support module for making SOCKSv4 servers with twistd.
10 from twisted.protocols import socks
11 from twisted.python import usage
12 from twisted.application import internet
15 class Options(usage.Options):
16 synopsis = "[-i <interface>] [-p <port>] [-l <file>]"
17 optParameters = [["interface", "i", "127.0.0.1", "local interface to which we listen"],
18 ["port", "p", 1080, "Port on which to listen"],
19 ["log", "l", None, "file to log connection data to"]]
21 compData = usage.Completions(
22 optActions={"log": usage.CompleteFiles("*.log"),
23 "interface": usage.CompleteNetInterfaces()}
26 longdesc = "Makes a SOCKSv4 server."
28 def makeService(config):
29 if config["interface"] != "127.0.0.1":
32 print " You have chosen to listen on a non-local interface."
33 print " This may allow intruders to access your local network"
34 print " if you run this on a firewall."
36 t = socks.SOCKSv4Factory(config['log'])
37 portno = int(config['port'])
38 return internet.TCPServer(portno, t, interface=config['interface'])