1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #!/usr/bin/env python3
- import sys
- try:
- from twisted.internet import reactor
- except ImportError:
- print("\x1b[1mHey!\x1b[0m Activate your venv first!")
- sys.exit(2)
- from twisted.internet import protocol
- import logging
- import logging.config
- from twisted.python import log
- from proxy import Player
- import argparse
- parser = argparse.ArgumentParser(description="TradeWars Proxy")
- parser.add_argument(
- "--config", type=str, help="Configuration file to load", default="config.yaml"
- )
- parser.add_argument("--debug", action="store_true")
- args = parser.parse_args()
- # from twisted.python.logfile import DailyLogFile
- from config import version, load
- load(args.config)
- from config import config
- logger = logging.getLogger(__name__)
- log.PythonLoggingObserver().start()
- # if "logfile" in config and config["logfile"]:
- # log.startLogging(DailyLogFile("proxy.log", "."))
- # else:
- # log.startLogging(sys.stdout)
- logger.error("This is version: {0}".format(version))
- factory = protocol.Factory()
- factory.protocol = Player
- reactor.listenTCP(config["listen_port"], factory, interface=config["listen_on"])
- reactor.run()
|