manager: Addedd timeout to server protocol
This commit is contained in:
parent
345a13edc2
commit
0f2881fbab
|
@ -6,6 +6,7 @@
|
|||
from twisted.internet.defer import Deferred, succeed
|
||||
from twisted.internet.protocol import ReconnectingClientFactory, ServerFactory
|
||||
from twisted.protocols.basic import LineOnlyReceiver
|
||||
from twisted.protocols.policies import TimeoutMixin
|
||||
from twisted.internet.task import LoopingCall
|
||||
from twisted.python import log
|
||||
from frn.user import FRNUser
|
||||
|
@ -107,13 +108,14 @@ class FRNManagerClientFactory(ReconnectingClientFactory):
|
|||
pass
|
||||
|
||||
|
||||
class FRNManagerServer(LineOnlyReceiver):
|
||||
class FRNManagerServer(LineOnlyReceiver, TimeoutMixin):
|
||||
|
||||
def connectionMade(self):
|
||||
log.msg("Manager client connected from %s" % self.transport.getPeer().host)
|
||||
self._phase = "CONNECTED"
|
||||
self.serverInfo = None
|
||||
self.kp = makeRandomChallange()
|
||||
self.setTimeout(30.0)
|
||||
|
||||
def connectionLost(self, reason):
|
||||
log.msg("Manager client disconnected from %s: %s" %
|
||||
|
@ -129,6 +131,7 @@ class FRNManagerServer(LineOnlyReceiver):
|
|||
self.transport.loseConnection()
|
||||
|
||||
def lineReceived(self, line):
|
||||
self.resetTimeout()
|
||||
sline = line.strip()
|
||||
if self._phase == "CHALLANGE":
|
||||
if sline == responseToChallange(self.kp):
|
||||
|
|
Loading…
Reference in New Issue