2017-11-19 14:46:42 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
from twisted.internet import reactor
|
|
|
|
from twisted.internet.ssl import DefaultOpenSSLContextFactory
|
2019-08-16 20:27:23 +00:00
|
|
|
from sys import argv, stdout, stderr
|
2017-12-24 21:04:48 +00:00
|
|
|
#from twisted.python import log
|
|
|
|
#from sys import stdout
|
|
|
|
#log.startLogging(stdout)
|
2019-08-16 20:27:23 +00:00
|
|
|
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
|
2018-03-14 20:13:40 +00:00
|
|
|
import main
|
2018-02-24 12:42:27 +00:00
|
|
|
|
2018-03-14 20:13:40 +00:00
|
|
|
main.initMain()
|
2019-08-15 20:20:49 +00:00
|
|
|
if "--debug" in argv: # yes really
|
|
|
|
main.config["Debug"] = True
|
2018-02-22 19:30:31 +00:00
|
|
|
from utils.logging.log import *
|
2019-01-26 18:58:21 +00:00
|
|
|
from utils.loaders.command_loader import loadCommands
|
2018-03-04 13:26:53 +00:00
|
|
|
from core.server import Server, ServerFactory
|
2019-03-18 21:01:28 +00:00
|
|
|
from core.relay import Relay, RelayFactory
|
2019-07-28 14:07:46 +00:00
|
|
|
import modules.counters
|
2019-01-26 18:58:21 +00:00
|
|
|
loadCommands()
|
|
|
|
|
2017-11-19 14:46:42 +00:00
|
|
|
if __name__ == "__main__":
|
2018-03-04 13:26:53 +00:00
|
|
|
listener = ServerFactory()
|
2018-03-14 20:13:40 +00:00
|
|
|
if main.config["Listener"]["UseSSL"] == True:
|
2019-01-26 01:57:24 +00:00
|
|
|
reactor.listenSSL(main.config["Listener"]["Port"], listener, DefaultOpenSSLContextFactory(main.certPath+main.config["Key"], main.certPath+main.config["Certificate"]), interface=main.config["Listener"]["Address"])
|
2018-03-14 20:13:40 +00:00
|
|
|
log("Threshold running with SSL on %s:%s" % (main.config["Listener"]["Address"], main.config["Listener"]["Port"]))
|
2017-11-19 14:46:42 +00:00
|
|
|
else:
|
2018-03-14 20:13:40 +00:00
|
|
|
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"]))
|
2019-03-18 21:01:28 +00:00
|
|
|
if main.config["Relay"]["Enabled"]:
|
|
|
|
relay = RelayFactory()
|
|
|
|
if main.config["Relay"]["UseSSL"] == True:
|
|
|
|
reactor.listenSSL(main.config["Relay"]["Port"], relay, DefaultOpenSSLContextFactory(main.certPath+main.config["Key"], main.certPath+main.config["Certificate"]), interface=main.config["Relay"]["Address"])
|
|
|
|
log("Threshold relay running with SSL on %s:%s" % (main.config["Relay"]["Address"], main.config["Relay"]["Port"]))
|
|
|
|
else:
|
|
|
|
reactor.listenTCP(main.config["Relay"]["Port"], relay, interface=main.config["Relay"]["Address"])
|
|
|
|
log("Threshold relay running on %s:%s" % (main.config["Relay"]["Address"], main.config["Relay"]["Port"]))
|
2019-08-11 20:58:14 +00:00
|
|
|
for net in main.network.keys():
|
|
|
|
main.network[net].start_bots()
|
2019-07-28 14:07:46 +00:00
|
|
|
modules.counters.setupCounterLoop()
|
2017-11-19 14:46:42 +00:00
|
|
|
reactor.run()
|