twgs-proxy.py 819 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env python3
  2. import sys
  3. try:
  4. from twisted.internet import reactor
  5. except ImportError:
  6. print("\x1b[1mHey!\x1b[0m Activate your venv first!")
  7. sys.exit(2)
  8. from twisted.internet import protocol
  9. import logging
  10. import logging.config
  11. from twisted.python import log
  12. # from twisted.python.logfile import DailyLogFile
  13. from config import config, version
  14. from proxy import Player
  15. logger = logging.getLogger(__name__)
  16. log.PythonLoggingObserver().start()
  17. # if "logfile" in config and config["logfile"]:
  18. # log.startLogging(DailyLogFile("proxy.log", "."))
  19. # else:
  20. # log.startLogging(sys.stdout)
  21. logger.error("This is version: {0}".format(version))
  22. factory = protocol.Factory()
  23. factory.protocol = Player
  24. reactor.listenTCP(config["listen_port"], factory, interface=config["listen_on"])
  25. reactor.run()