47 lines
2.6 KiB
Python
Executable File
47 lines
2.6 KiB
Python
Executable File
#!/usr/bin/env python
|
|
from twisted.internet import reactor
|
|
from twisted.internet.ssl import DefaultOpenSSLContextFactory
|
|
import sys
|
|
from signal import signal, SIGINT
|
|
#from twisted.python import log
|
|
#from sys import stdout
|
|
#log.startLogging(stdout)
|
|
from sys import stdout, stderr # Import again because we want to override
|
|
from codecs import getwriter # fix printing odd shit to the terminal
|
|
stdout = getwriter("utf8")(stdout) # this is a generic fix but we all know
|
|
stderr = getwriter("utf8")(stderr) # it's just for the retards on Rizon using
|
|
# unicode quit messages for no reason
|
|
import main
|
|
main.initMain()
|
|
from utils.cleanup import handler
|
|
signal(SIGINT, handler) # Handle Ctrl-C and run the cleanup routine
|
|
if "--debug" in sys.argv: # yes really
|
|
main.config["Debug"] = True
|
|
from utils.logging.log import *
|
|
from utils.loaders.command_loader import loadCommands
|
|
from core.server import Server, ServerFactory
|
|
from core.relay import Relay, RelayFactory
|
|
import modules.counters
|
|
loadCommands()
|
|
|
|
if __name__ == "__main__":
|
|
listener = ServerFactory()
|
|
if main.config["Listener"]["UseSSL"] == True:
|
|
reactor.listenSSL(main.config["Listener"]["Port"], listener, DefaultOpenSSLContextFactory(main.certPath+main.config["Key"], main.certPath+main.config["Certificate"]), interface=main.config["Listener"]["Address"])
|
|
log("Threshold running with SSL on %s:%s" % (main.config["Listener"]["Address"], main.config["Listener"]["Port"]))
|
|
else:
|
|
reactor.listenTCP(main.config["Listener"]["Port"], listener, interface=main.config["Listener"]["Address"])
|
|
log("Threshold running on %s:%s" % (main.config["Listener"]["Address"], main.config["Listener"]["Port"]))
|
|
if main.config["RelayAPI"]["Enabled"]:
|
|
relay = RelayFactory()
|
|
if main.config["RelayAPI"]["UseSSL"] == True:
|
|
reactor.listenSSL(main.config["RelayAPI"]["Port"], relay, DefaultOpenSSLContextFactory(main.certPath+main.config["Key"], main.certPath+main.config["Certificate"]), interface=main.config["RelayAPI"]["Address"])
|
|
log("Threshold relay running with SSL on %s:%s" % (main.config["RelayAPI"]["Address"], main.config["RelayAPI"]["Port"]))
|
|
else:
|
|
reactor.listenTCP(main.config["RelayAPI"]["Port"], relay, interface=main.config["RelayAPI"]["Address"])
|
|
log("Threshold relay running on %s:%s" % (main.config["RelayAPI"]["Address"], main.config["RelayAPI"]["Port"]))
|
|
for net in main.network.keys():
|
|
main.network[net].start_bots()
|
|
modules.counters.setupCounterLoop()
|
|
reactor.run()
|