Reformat project

This commit is contained in:
2022-07-21 13:39:59 +01:00
parent 9d4d31fdc2
commit 760e43b59a
57 changed files with 523 additions and 218 deletions

View File

@@ -1,6 +1,7 @@
from twisted.internet.protocol import Protocol, Factory, ClientFactory
from json import dumps, loads
from copy import deepcopy
from json import dumps, loads
from twisted.internet.protocol import ClientFactory, Factory, Protocol
import main
from utils.logging.log import *
@@ -114,8 +115,13 @@ class Relay(Protocol):
def handleHello(self, parsed):
if parsed["key"] in main.tokens.keys():
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"]})
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.authed = True
else:
self.transport.loseConnection()
@@ -130,7 +136,10 @@ class Relay(Protocol):
def connectionLost(self, reason):
self.authed = False
log("Relay connection lost from %s:%s -- %s" % (self.addr.host, self.addr.port, reason.getErrorMessage()))
log(
"Relay connection lost from %s:%s -- %s"
% (self.addr.host, self.addr.port, reason.getErrorMessage())
)
if self.addr in main.relayConnections.keys():
del main.relayConnections[self.addr]
else: