Fix client disconnection from server on unmute. Fix html handling inside text messages in server.
This commit is contained in:
parent
009ce3734a
commit
5f63670043
|
@ -39,6 +39,9 @@ class ClientTracker(object):
|
|||
s['admin'] = self._admin
|
||||
s.close()
|
||||
|
||||
def isLoggedIn(self, clientId):
|
||||
return clientId in self._clientData
|
||||
|
||||
def getClient(self, clientId):
|
||||
return self._clientData[clientId].user
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ from frn.utility import *
|
|||
|
||||
class FRNServer(BufferingLineReceiver, TimeoutMixin):
|
||||
|
||||
PING_PERIOD = 0.5
|
||||
|
||||
def connectionMade(self):
|
||||
BufferingLineReceiver.connectionMade(self)
|
||||
log.msg("Connection from %s" % self.transport.getPeer().host)
|
||||
|
@ -131,7 +133,7 @@ class FRNServer(BufferingLineReceiver, TimeoutMixin):
|
|||
|
||||
def startPinging(self):
|
||||
if not self.pingTimer.running:
|
||||
self.pingTimer.start(0.5, True)
|
||||
self.pingTimer.start(self.PING_PERIOD, True)
|
||||
|
||||
def stopPinging(self):
|
||||
if self.pingTimer.running:
|
||||
|
@ -171,6 +173,8 @@ class FRNServer(BufferingLineReceiver, TimeoutMixin):
|
|||
def decodeMC(self, body):
|
||||
if self.role in ["OWNER","ADMIN"]:
|
||||
self.factory.tracker.mute(self.user, body['ip'])
|
||||
if self.factory.tracker.isLoggedIn(body['ip']):
|
||||
self.factory.tracker.getClientProtocol(body['ip']).decodeRX('0')
|
||||
|
||||
def decodeUM(self, body):
|
||||
if self.role in ["OWNER","ADMIN"]:
|
||||
|
|
|
@ -20,19 +20,31 @@ def makeRandomChallange():
|
|||
|
||||
|
||||
class SimpleXMLParser(HTMLParser):
|
||||
"""Dirty FRN-specific hack to handle bogus one-level nesting only
|
||||
XML-like syntax"""
|
||||
|
||||
def handle_starttag(self, tag, attrs):
|
||||
if not hasattr(self, 'fields'):
|
||||
self.fields = {}
|
||||
self.next_field = tag
|
||||
self.next_data = ''
|
||||
self.next_field = None
|
||||
self.next_data = ''
|
||||
if self.next_field is None:
|
||||
self.next_field = tag
|
||||
self.next_data = ''
|
||||
else:
|
||||
self.next_data += "<%s>" % tag
|
||||
|
||||
def handle_data(self, data):
|
||||
self.next_data += data
|
||||
if self.next_field is not None:
|
||||
self.next_data += data
|
||||
|
||||
def handle_endtag(self, tag):
|
||||
self.fields[self.next_field] = self.next_data
|
||||
self.next_field = self.next_data = None
|
||||
if tag == self.next_field:
|
||||
self.fields[self.next_field] = self.next_data
|
||||
self.next_field = None
|
||||
self.next_data = ''
|
||||
else:
|
||||
self.next_data += "</%s>" % tag
|
||||
|
||||
def get_fields(self):
|
||||
return self.fields
|
||||
|
|
Loading…
Reference in New Issue