Import the main module properly and fix some oddities in Twisted to prevent it from discarding some data
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from twisted.internet.protocol import Protocol, Factory, ClientFactory
|
||||
from core.main import *
|
||||
import main
|
||||
from utils.logging.log import *
|
||||
|
||||
from core.parser import parseCommand
|
||||
@@ -8,7 +8,7 @@ class Server(Protocol):
|
||||
def __init__(self, addr):
|
||||
self.addr = addr
|
||||
self.authed = False
|
||||
if config["UsePassword"] == False:
|
||||
if main.config["UsePassword"] == False:
|
||||
self.authed = True
|
||||
|
||||
def send(self, data):
|
||||
@@ -34,22 +34,22 @@ class Server(Protocol):
|
||||
def connectionLost(self, reason):
|
||||
self.authed = False
|
||||
log("Connection lost from %s:%s -- %s" % (self.addr.host, self.addr.port, reason.getErrorMessage()))
|
||||
if self.addr in connections.keys():
|
||||
del connections[self.addr]
|
||||
if self.addr in main.connections.keys():
|
||||
del main.connections[self.addr]
|
||||
else:
|
||||
warn("Tried to remove a non-existant connection.")
|
||||
if self.addr in MonitorPool:
|
||||
MonitorPool.remove(self.addr)
|
||||
if self.addr in main.MonitorPool:
|
||||
main.MonitorPool.remove(self.addr)
|
||||
|
||||
class ServerFactory(Factory):
|
||||
def buildProtocol(self, addr):
|
||||
entry = Server(addr)
|
||||
connections[addr] = entry
|
||||
main.connections[addr] = entry
|
||||
return entry
|
||||
|
||||
def send(self, addr, data):
|
||||
if addr in connections.keys():
|
||||
connection = connections[addr]
|
||||
if addr in main.connections.keys():
|
||||
connection = main.connections[addr]
|
||||
connection.send(data)
|
||||
else:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user