#!/usr/bin/env python3 import sys import os from subprocess import check_output from twisted.internet import reactor from twisted.internet import protocol from twisted.python import log from twisted.python.logfile import DailyLogFile import yaml def config_load(filename: str): global config with open(filename, "r") as fp: config = yaml.safe_load(fp) if os.path.exists("config_dev.yaml"): config_load("config_dev.yaml") else: config_load("config.yaml") # Extract the version information from git. # The match gives us only tags starting with v[0-9]* Using anything else trips up on double digits. version = check_output( [ "git", "describe", "--abbrev=8", "--long", "--tags", "--dirty", "--always", "--match", "v[0-9]*", ], universal_newlines=True, ).strip() from proxy import Player if "logfile" in config and config["logfile"]: log.startLogging(DailyLogFile("proxy.log", ".")) else: log.startLogging(sys.stdout) log.msg("This is version: {0}".format(version)) factory = protocol.Factory() factory.protocol = Player reactor.listenTCP(config["listen_port"], factory, interface=config["listen_on"]) reactor.run()