Reformat and fix circular import
This commit is contained in:
parent
27cafa1def
commit
4ecb37b179
|
@ -1,5 +1,5 @@
|
||||||
import main
|
import main
|
||||||
from core.bot import deliverRelayCommands
|
from utils.deliver_relay_commands import deliverRelayCommands
|
||||||
|
|
||||||
|
|
||||||
class AdmallCommand:
|
class AdmallCommand:
|
||||||
|
|
|
@ -74,7 +74,9 @@ class EmailCommand:
|
||||||
elif length == 3:
|
elif length == 3:
|
||||||
if spl[1] == "list":
|
if spl[1] == "list":
|
||||||
if spl[2] == "domain":
|
if spl[2] == "domain":
|
||||||
filtered = {f"{k}:{k2}":v2 for k,v in main.irc.items() for k2,v2 in v.items() if k2 == "domains"}
|
filtered = {
|
||||||
|
f"{k}:{k2}": v2 for k, v in main.irc.items() for k2, v2 in v.items() if k2 == "domains"
|
||||||
|
}
|
||||||
info(dump(filtered))
|
info(dump(filtered))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -35,13 +35,7 @@ from utils.parsing import parsen
|
||||||
from twisted.internet.ssl import DefaultOpenSSLContextFactory
|
from twisted.internet.ssl import DefaultOpenSSLContextFactory
|
||||||
|
|
||||||
|
|
||||||
def deliverRelayCommands(num, relayCommands, user=None, stage2=None):
|
from utils.deliver_relay_commands import deliverRelayCommands
|
||||||
keyFN = main.certPath + main.config["Key"]
|
|
||||||
certFN = main.certPath + main.config["Certificate"]
|
|
||||||
contextFactory = DefaultOpenSSLContextFactory(keyFN.encode("utf-8", "replace"), certFN.encode("utf-8", "replace"))
|
|
||||||
bot = IRCBotFactory(net=None, num=num, relayCommands=relayCommands, user=user, stage2=stage2)
|
|
||||||
host, port = getRelay(num)
|
|
||||||
rct = reactor.connectSSL(host, port, bot, contextFactory)
|
|
||||||
|
|
||||||
|
|
||||||
# Copied from the Twisted source so we can fix a bug
|
# Copied from the Twisted source so we can fix a bug
|
||||||
|
|
|
@ -114,7 +114,10 @@ class Relay(Protocol):
|
||||||
|
|
||||||
def handleHello(self, parsed):
|
def handleHello(self, parsed):
|
||||||
if parsed["key"] in main.tokens.keys():
|
if parsed["key"] in main.tokens.keys():
|
||||||
if parsed["hello"] == main.tokens[parsed["key"]]["hello"] and main.tokens[parsed["key"]]["usage"] == "relay":
|
if (
|
||||||
|
parsed["hello"] == main.tokens[parsed["key"]]["hello"]
|
||||||
|
and main.tokens[parsed["key"]]["usage"] == "relay"
|
||||||
|
):
|
||||||
self.sendMsg({"type": "hello", "hello": main.tokens[parsed["key"]]["counter"]})
|
self.sendMsg({"type": "hello", "hello": main.tokens[parsed["key"]]["counter"]})
|
||||||
self.authed = True
|
self.authed = True
|
||||||
else:
|
else:
|
||||||
|
|
4
main.py
4
main.py
|
@ -106,5 +106,7 @@ def initConf():
|
||||||
def initMain():
|
def initMain():
|
||||||
global r, g
|
global r, g
|
||||||
initConf()
|
initConf()
|
||||||
r = StrictRedis(unix_socket_path=config["RedisSocket"], db=config["RedisDBEphemeral"]) # Ephemeral - flushed on quit
|
r = StrictRedis(
|
||||||
|
unix_socket_path=config["RedisSocket"], db=config["RedisDBEphemeral"]
|
||||||
|
) # Ephemeral - flushed on quit
|
||||||
g = StrictRedis(unix_socket_path=config["RedisSocket"], db=config["RedisDBPersistent"]) # Persistent
|
g = StrictRedis(unix_socket_path=config["RedisSocket"], db=config["RedisDBPersistent"]) # Persistent
|
||||||
|
|
|
@ -77,7 +77,9 @@ class Network:
|
||||||
# e.g. freenode1 for the first relay on freenode network
|
# e.g. freenode1 for the first relay on freenode network
|
||||||
keyFN = main.certPath + main.config["Key"]
|
keyFN = main.certPath + main.config["Key"]
|
||||||
certFN = main.certPath + main.config["Certificate"]
|
certFN = main.certPath + main.config["Certificate"]
|
||||||
contextFactory = DefaultOpenSSLContextFactory(keyFN.encode("utf-8", "replace"), certFN.encode("utf-8", "replace"))
|
contextFactory = DefaultOpenSSLContextFactory(
|
||||||
|
keyFN.encode("utf-8", "replace"), certFN.encode("utf-8", "replace")
|
||||||
|
)
|
||||||
bot = IRCBotFactory(self.net, num)
|
bot = IRCBotFactory(self.net, num)
|
||||||
# host, port = self.relays[num]["host"], self.relays[num]["port"]
|
# host, port = self.relays[num]["host"], self.relays[num]["port"]
|
||||||
host, port = getRelay(num)
|
host, port = getRelay(num)
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
import main
|
import main
|
||||||
from core.bot import deliverRelayCommands
|
from utils.deliver_relay_commands import deliverRelayCommands
|
||||||
from utils.logging.log import *
|
from utils.logging.log import *
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
import modules.regproc
|
import modules.regproc
|
||||||
|
|
||||||
|
|
||||||
def provisionUserNetworkData(num, nick, altnick, ident, realname, emails, network, host, port, security, auth, password):
|
def provisionUserNetworkData(
|
||||||
|
num, nick, altnick, ident, realname, emails, network, host, port, security, auth, password
|
||||||
|
):
|
||||||
print("nick", nick)
|
print("nick", nick)
|
||||||
print("altnick", altnick)
|
print("altnick", altnick)
|
||||||
print("emails", emails)
|
print("emails", emails)
|
||||||
|
|
|
@ -5,6 +5,7 @@ from utils.logging.debug import *
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from random import choice
|
from random import choice
|
||||||
|
|
||||||
|
|
||||||
def needToRegister(net):
|
def needToRegister(net):
|
||||||
# Check if the network does not support authentication
|
# Check if the network does not support authentication
|
||||||
networkObj = main.network[net]
|
networkObj = main.network[net]
|
||||||
|
@ -129,10 +130,14 @@ def registerTest(c):
|
||||||
if not main.IRCPool[name]._negativePass == True:
|
if not main.IRCPool[name]._negativePass == True:
|
||||||
if c["type"] == "query" and c["nick"] == sinst["entity"]:
|
if c["type"] == "query" and c["nick"] == sinst["entity"]:
|
||||||
if sinst["checknegativemsg"] in c["msg"]:
|
if sinst["checknegativemsg"] in c["msg"]:
|
||||||
confirmRegistration(c["net"], c["num"], negativepass=False) # Not passed negative check, report back
|
confirmRegistration(
|
||||||
|
c["net"], c["num"], negativepass=False
|
||||||
|
) # Not passed negative check, report back
|
||||||
return
|
return
|
||||||
if sinst["checkendnegative"] in c["msg"]:
|
if sinst["checkendnegative"] in c["msg"]:
|
||||||
confirmRegistration(c["net"], c["num"], negativepass=True) # Passed the negative check, report back
|
confirmRegistration(
|
||||||
|
c["net"], c["num"], negativepass=True
|
||||||
|
) # Passed the negative check, report back
|
||||||
return
|
return
|
||||||
if sinst["ping"]:
|
if sinst["ping"]:
|
||||||
if sinst["checkmsg2"] in c["msg"] and c["nick"] == sinst["entity"]:
|
if sinst["checkmsg2"] in c["msg"] and c["nick"] == sinst["entity"]:
|
||||||
|
|
10
threshold
10
threshold
|
@ -46,7 +46,10 @@ if __name__ == "__main__":
|
||||||
),
|
),
|
||||||
interface=main.config["Listener"]["Address"],
|
interface=main.config["Listener"]["Address"],
|
||||||
)
|
)
|
||||||
log("Threshold running with SSL on %s:%s" % (main.config["Listener"]["Address"], main.config["Listener"]["Port"]))
|
log(
|
||||||
|
"Threshold running with SSL on %s:%s"
|
||||||
|
% (main.config["Listener"]["Address"], main.config["Listener"]["Port"])
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
reactor.listenTCP(
|
reactor.listenTCP(
|
||||||
main.config["Listener"]["Port"],
|
main.config["Listener"]["Port"],
|
||||||
|
@ -76,7 +79,10 @@ if __name__ == "__main__":
|
||||||
relay,
|
relay,
|
||||||
interface=main.config["RelayAPI"]["Address"],
|
interface=main.config["RelayAPI"]["Address"],
|
||||||
)
|
)
|
||||||
log("Threshold relay running on %s:%s" % (main.config["RelayAPI"]["Address"], main.config["RelayAPI"]["Port"]))
|
log(
|
||||||
|
"Threshold relay running on %s:%s"
|
||||||
|
% (main.config["RelayAPI"]["Address"], main.config["RelayAPI"]["Port"])
|
||||||
|
)
|
||||||
for net in main.network.keys():
|
for net in main.network.keys():
|
||||||
main.network[net].start_bots()
|
main.network[net].start_bots()
|
||||||
modules.counters.setupCounterLoop()
|
modules.counters.setupCounterLoop()
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
def deliverRelayCommands(num, relayCommands, user=None, stage2=None):
|
||||||
|
keyFN = main.certPath + main.config["Key"]
|
||||||
|
certFN = main.certPath + main.config["Certificate"]
|
||||||
|
contextFactory = DefaultOpenSSLContextFactory(keyFN.encode("utf-8", "replace"), certFN.encode("utf-8", "replace"))
|
||||||
|
bot = IRCBotFactory(net=None, num=num, relayCommands=relayCommands, user=user, stage2=stage2)
|
||||||
|
host, port = getRelay(num)
|
||||||
|
rct = reactor.connectSSL(host, port, bot, contextFactory)
|
|
@ -12,7 +12,7 @@ def loadCommands(allowDup=False):
|
||||||
if filename.endswith(".py") and filename != "__init__.py":
|
if filename.endswith(".py") and filename != "__init__.py":
|
||||||
commandName = filename[0:-3]
|
commandName = filename[0:-3]
|
||||||
className = commandName.capitalize() + "Command"
|
className = commandName.capitalize() + "Command"
|
||||||
try:
|
# try:
|
||||||
module = __import__("commands.%s" % commandName)
|
module = __import__("commands.%s" % commandName)
|
||||||
if not commandName in CommandMap:
|
if not commandName in CommandMap:
|
||||||
CommandMap[commandName] = getattr(getattr(module, commandName), className)
|
CommandMap[commandName] = getattr(getattr(module, commandName), className)
|
||||||
|
@ -23,5 +23,5 @@ def loadCommands(allowDup=False):
|
||||||
debug("Registered command: %s" % commandName)
|
debug("Registered command: %s" % commandName)
|
||||||
|
|
||||||
error("Duplicate command: %s" % (commandName))
|
error("Duplicate command: %s" % (commandName))
|
||||||
except Exception as err:
|
# except Exception as err:
|
||||||
error("Exception while loading command %s:\n%s" % (commandName, err))
|
# error("Exception while loading command %s:\n%s" % (commandName, err))
|
||||||
|
|
Loading…
Reference in New Issue