Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

socks.py 1.2KB

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