Ejemplo n.º 1
0
    def connectionMade(self):
        """
        This is called when the connection is first
        established.
        """
        # initialize the session
        self.iaw_mode = False
        client_address = self.transport.client
        self.init_session("telnet", client_address,
                          self.factory.sessionhandler)
        # negotiate mccp (data compression)
        self.mccp = Mccp(self)
        # negotiate ttype (client info)
        self.ttype = ttype.Ttype(self)
        # negotiate mssp (crawler communication)
        self.mssp = mssp.Mssp(self)
        # msdp
        self.msdp = msdp.Msdp(self)
        # add this new connection to sessionhandler so
        # the Server becomes aware of it.

        # This is a fix to make sure the connection does not
        # continue until the handshakes are done. This is a
        # dumb delay of 1 second. This solution is not ideal (and
        # potentially buggy for slow connections?) but
        # adding a callback chain to all protocols (and notably
        # to their handshakes, which in some cases are multi-part)
        # is not trivial. Without it, the protocol will default
        # to their defaults since sessionhandler.connect will sync
        # before the handshakes have had time to finish. Keeping this patch
        # until coming up with a more elegant solution /Griatch
        from src.utils.utils import delay
        delay(1, callback=self.sessionhandler.connect, retval=self)
Ejemplo n.º 2
0
    def connectionMade(self):
        """
        This is called when the connection is first
        established.
        """
        # initialize the session
        self.iaw_mode = False
        client_address = self.transport.client
        # this number is counted down for every handshake that completes.
        # when it reaches 0 the portal/server syncs their data
        self.handshakes = 5  # naws, ttype, mccp, mssp, msdp
        self.init_session("telnet", client_address,
                          self.factory.sessionhandler)

        # negotiate client size
        self.naws = naws.Naws(self)
        # negotiate ttype (client info)
        # Obs: mudlet ttype does not seem to work if we start mccp before ttype. /Griatch
        self.ttype = ttype.Ttype(self)
        # negotiate mccp (data compression) - turn this off for wireshark analysis
        self.mccp = Mccp(self)
        # negotiate mssp (crawler communication)
        self.mssp = mssp.Mssp(self)
        # msdp
        self.msdp = msdp.Msdp(self)
        # add this new connection to sessionhandler so
        # the Server becomes aware of it.
        self.sessionhandler.connect(self)

        # timeout the handshakes in case the client doesn't reply at all
        from src.utils.utils import delay
        delay(2, callback=self.handshake_done, retval=True)