Example #1
0
 def __init__(self):
     Telnet.__init__(self)
     self.session_id = session_id()
     sessions[self.session_id] = self
     self.output_buffer = []
     self.MAX_LENGTH = amp.MAX_VALUE_LENGTH * 8
     self.idle_cmd = config.get('Main', 'idle command')
Example #2
0
 def connectionLost(self, reason):
     """Clean up and let the superclass handle it."""
     Telnet.connectionLost(self, reason)
     LineOnlyReceiver.connectionLost(self, reason)
     #flush out the buffer
     if self._buffer:
         self.lineReceived(self._buffer)
     self.factory.realm.connectionLost()
Example #3
0
 def dataReceived(self, data):
     if self.fix_broken_godwars_line_endings:
         while broken_line_ending_pattern.match(data):
             data = re.sub(broken_line_ending_pattern, "\\1\r\n", data, 1)
     try:
         Telnet.dataReceived(self, data)
     except ValueError as e:
         print('Telnet error: %s'%e)
Example #4
0
 def connectionLost(self, reason):
     """Clean up and let the superclass handle it."""
     Telnet.connectionLost(self, reason)
     LineOnlyReceiver.connectionLost(self, reason)
     #flush out the buffer
     if self._buffer:
         self.lineReceived(self._buffer)
     self.factory.realm.connectionLost()
Example #5
0
 def connectionMade(self):
     """Call our superclasses.
     
     Late initialisation should also go here.
     """
     self.factory.realm.connectionMade()
     Telnet.connectionMade(self)
     LineOnlyReceiver.connectionMade(self)
Example #6
0
    def __init__(self, perle_actuator, user, password, relay):
        Telnet.__init__(self)
        self.perle_actuator = perle_actuator
        self.user           = user
        self.password       = password
        self.relay          = relay
        self.callid         = None

        self.resetTimer()
Example #7
0
 def connectionMade(self):
     """Call our superclasses.
     
     Late initialisation should also go here.
     """
     
     self.factory.realm.connectionMade()
     Telnet.connectionMade(self)
     LineOnlyReceiver.connectionMade(self)
Example #8
0
 def __init__(self, factory):
     Telnet.__init__(self)
     self.commandMap[GA] = self.ga_received
     self.negotiationMap[COMPRESS2] = self.turn_on_compression
     self.negotiationMap[GMCP] = self.handle_gmcp
     #LineOnlyReceiver doesn't have an __init__ method, weirdly.
     self.factory = factory
     self.allowing_compress = False
     self._colourparser = ColourCodeParser()
     self.fix_broken_godwars_line_endings = True
Example #9
0
    def __init__(self, connection):
        Telnet.__init__(self)

        self.connection = connection

        if self.connection and self.connection.connected:
            self.connection.register(self)

        else:
            self.abortConnection()
Example #10
0
 def dataReceived(self, data):
     if self.fix_broken_godwars_line_endings:
         while broken_line_ending_pattern.match(data):
             data = re.sub(broken_line_ending_pattern, "\\1\r\n", data, 1)
     try:
         Telnet.dataReceived(self, data)
     except ValueError as e:
         print("Telnet error: %s" % e)
         # It may be things getting stuck in 'escaped'
         self.state = "data"
Example #11
0
    def __init__(self, telnet_client):
        Telnet.__init__(self)
        self.reset()
        self.client = telnet_client

        if self not in self.client.receivers:
            self.client.addReceiver(self)

        self.outbound_buffer = ''
        self.inbound_buffer = ''

        if self.client.connected:
            self.ready()
Example #12
0
 def __init__(self, timeout=settings.TELNET_TIMEOUT):
     self.protocol = TelnetProtocol()
     self.waiting_for = [
         ('Username: '******'Please Enter Login Name  : ', self.state_username), # OLD Foundry
         ('User Name:', self.state_username),                  # Dell
         ('login: '******'Password: '******''
     self.applicationDataReceived = self.login_state_machine
     self.timeout = timeout
     self.setTimeout(self.timeout)
     Telnet.__init__(self)
Example #13
0
 def __init__(self, factory):
     Telnet.__init__(self)
     self.commandMap[GA] = self.ga_received
     self.negotiationMap[COMPRESS2] = self.turn_on_compression
     #LineOnlyReceiver doesn't have an __init__ method, weirdly.
     self.factory = factory
     self.allowing_compress = False
     self._colourparser = ColourCodeParser()
     self.fix_broken_godwars_line_endings = True
     
     # MSDP support
     self.allowing_msdp = False
     self.msdp = MSDPParser(self)
     self.negotiationMap[MSDP] = self.msdp_negotiation
Example #14
0
    def __init__(self, telnet_client):
        Telnet.__init__(self)
        self.reset()
        self.client = telnet_client

        self.negotiationMap[GMCP] = self.gmcpReceived

        # telnet options to enable
        self.options_enabled = (
            GMCP,
            EOR,
        )

        self.options_disabled = ()

        if self not in self.client.receivers:
            self.client.addReceiver(self)

        self.outbound_buffer = ''
        self.inbound_buffer = ''

        if self.client.connected:
            self.ready()
Example #15
0
    def __init__(self):
        Telnet.__init__(self)

        # ISageProxyReceiver receivers (like a Telnet Server or a WS Server)
        self.receivers = Receivers()

        self.compress = False
        self.decompressobj = zlib.decompressobj()
        self.compressobj = zlib.compressobj()

        self.gmcp = gmcp.GMCP(self)
        sage.gmcp = self.gmcp  # make easily accessible
        self.gmcp_passthrough = True  # send GMCP to client

        # Hold over incomplete app data until the next packet
        self.data_buffer = ''
        self.outbound_buffer = ''

        # Setup recieving GMCP negotation
        self.negotiationMap[GMCP] = self.gmcpReceived
        self.negotiationMap[COMPRESS2] = self.enableCompress

        # telnet options to enable
        self.options_enabled = (
            GMCP,
            EOR,
            #COMPRESS2  # MCCP2 seems to break GMCP's Core.Ping in Achaea
        )

        self.options_disabled = ()

        # Used to identify a line that is only a color code
        self.color_prefix = chr(27) + '[1;'

        # Achaea will sometimes give us a line that is just a color code...
        self.color_newline = re.compile('^' + ESC + '\[[0-9;]*[m]' + NL)
Example #16
0
    def __init__(self):
        Telnet.__init__(self)

        # ISageProxyReceiver receivers (like a Telnet Server or a WS Server)
        self.receivers = Receivers()

        self.compress = False
        self.decompressobj = zlib.decompressobj()
        self.compressobj = zlib.compressobj()

        self.gmcp = gmcp.GMCP(self)
        sage.gmcp = self.gmcp  # make easily accessible
        self.gmcp_passthrough = False  # send GMCP to client

        # Hold over incomplete app data until the next packet
        self.data_buffer = ''
        self.outbound_buffer = ''

        # Setup recieving GMCP negotation
        self.negotiationMap[GMCP] = self.gmcpRecieved
        self.negotiationMap[COMPRESS2] = self.enableCompress

        # telnet options to enable
        self.options_enabled = (
            GMCP,
            EOR,
            #COMPRESS2  # MCCP2 seems to break GMCP's Core.Ping in Achaea
        )

        self.options_disabled = ()

        # Used to identify a line that is only a color code
        self.color_prefix = chr(27) + '[1;'

        # Achaea will sometimes give us a line that is just a color code...
        self.color_newline = re.compile('^' + ESC + '\[[0-9;]*[m]' + NL)
Example #17
0
    def dataReceived(self, data):
        if self.compression_enabled:
            data = self.decompress.decompress(data)

        Telnet.dataReceived(self, data)
Example #18
0
 def __init__(self, perle_actuator, user, password, relay):
     Telnet.__init__(self)
     self.perle_actuator = perle_actuator
     self.user = user
     self.password = password
     self.relay = relay
Example #19
0
 def __init__(self):
     Telnet.__init__(self)
Example #20
0
	def __init__(self):
		Telnet.__init__(self)

		# Used to identify a line that is only a color code
		self.color_prefix = chr(27) + chr(91) + chr(49) + chr(59)

		# Dirty hack until I am confident GMCP negotiation is working...
		#self.options[GMCP] = self._OptionState()
		#self.options[GMCP].us.state = 'yes'

		# Register GMCP SN to process_GMCP
		#self.negotiationMap[GMCP] = self.process_GMCP

		# Negotiation Options
		self.allow_echo = False
		self.allow_mccp2 = False
		self.allow_mccp = False
		self.allow_atcp = False

		#self.allow_gmcp = True
		self.allow_eor = False

		"""
		# GMCP Options and data
		self.gmcp_enabled_modules = ["Char 1", "Char.Vitals 1", "Char.Skills 1", "Char.Items 1", "Room 1", "IRE.Rift 1", "Comm.Channel 1"]
		self.gmcp_data = ""
		self.ping_task = None
		self.ping_frequency = 5
		self.gmcp_ping_awaiting = False
		self.gmcp_ping_start = 0
		self.gmcp_ping_finish = 0
		self.gmcp_avg = core.EMA(alpha = 0.6)

		# Negotation Statuses
		self.mccp2 = False
		self.atcp = False
		self.gmcp = False
		self.eor = False
		self.echo = False
		"""

		self.logging = core.config['logging_enabled']

		# We have to use empty strings to support Cython
		self.full_char_set = ''
		self.omit_char_set = ''

		for n in range(256):
			self.full_char_set += chr(n)

		for n in self.full_char_set:
			if ord(n) < 32 or ord(n) > 200:
				self.omit_char_set += n

		if self.logging:
			if os.path.isdir('logs') == False:
				os.mkdir('logs')
			self.log = logging.getLogger(player.name)
			handler = logging.handlers.TimedRotatingFileHandler('logs/' + player.name + '.' + self.today(), 'midnight', 0)
			handler.suffix = "%Y%m%d"
			self.log.addHandler(handler)
			self.log.setLevel(logging.DEBUG)
Example #21
0
 def __init__( self, *args, **kwargs ):
     self.deferred = Deferred()
     self.data = []
     Telnet.__init__(self, *args, **kwargs )
Example #22
0
    def commandReceived(self, command, argument):

        Telnet.commandReceived(self, command, argument)
        if argument == GMCP and command == WILL:
            for msg in self.factory.gmcp_handshakes:
                self.requestNegotiation(GMCP, msg)
Example #23
0
 def connectionLost(self, reason):
     self.call_remote(proxy_sessions.EndSession)
     basic.LineReceiver.connectionLost(self, reason)
     Telnet.connectionLost(self, reason)
     if self.session_id in sessions:
         del sessions[self.session_id]
Example #24
0
 def __init__(self):
     Telnet.__init__(self)
Example #25
0
 def dataReceived(self, data):
     if self.fix_broken_godwars_line_endings:
         while broken_line_ending_pattern.match(data):
             data = re.sub(broken_line_ending_pattern, "\\1\r\n", data, 1)
     Telnet.dataReceived(self, data)
Example #26
0
 def commandReceived(self, command, argument):
     
     Telnet.commandReceived(self, command, argument)
     if argument==GMCP and command == WILL and self.factory.realm.gmcp_handler:
         for msg in self.factory.realm.gmcp_handler.handshakeMessages():
             self.requestNegotiation(GMCP, msg)