• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Handle login to tfs 1.4.2

lexus21

Active Member
Joined
Dec 14, 2022
Messages
86
Reaction score
25
hi
Im trying to handle login to tfs in python.
I have this code:

Code:
from twisted.internet import reactor, protocol

class TFSClientProtocol(protocol.Protocol):
    def connectionMade(self):
        print("Connected to the TFS server!")
        # Send the login packet here
        account_name = "mylogin"
        password = "mypass"
        login_packet = self.create_login_packet(account_name, password)
        self.transport.write(login_packet)

    def dataReceived(self, data):
        print("Received data:", data)
        # Handle the incoming data from the server
        
    def connectionLost(self, reason):
        print("Connection lost:", reason)
        # Handle the connection loss, you might want to reconnect here

    def create_login_packet(self, accountName, accountPassword,):
        packet = bytearray()
        packet.append(0x0A)  # Packet type for login
        packet.extend(accountName.encode('utf-8'))
        packet.append(0x00)
        packet.extend(accountPassword.encode('utf-8'))
        packet.append(0x00)
        return bytes(packet)

class TFSClientFactory(protocol.ClientFactory):
    protocol = TFSClientProtocol

    def clientConnectionFailed(self, connector, reason):
        print("Connection failed:", reason)
        reactor.stop()

    def clientConnectionLost(self, connector, reason):
        print("Connection lost:", reason)
        reactor.stop()

if __name__ == '__main__':
    host = '127.0.0.1'
    port = 7171  # Default TFS port, change if necessary

    factory = TFSClientFactory()
    reactor.connectTCP(host, port, factory)
    reactor.run()


but i get error

Code:
Connected to the TFS server!
Connection lost: [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion.
]
Connection lost: [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion.
]



is packet.append(0x0A) # Packet type for login is good for 10.98?
 
Back
Top