2012-04-07 16:02:46 +02:00
|
|
|
import socket
|
|
|
|
import wx
|
2012-04-15 18:49:47 +02:00
|
|
|
import PacketListenerManager
|
2012-04-07 16:02:46 +02:00
|
|
|
import urllib2
|
|
|
|
import traceback
|
2012-04-10 21:14:32 +02:00
|
|
|
import threading
|
2012-09-02 19:54:16 +02:00
|
|
|
import hashlib
|
|
|
|
import string
|
|
|
|
from networking import PacketSenderManager
|
|
|
|
from Crypto.Random import _UserFriendlyRNG
|
|
|
|
from Crypto.Util import asn1
|
|
|
|
from Crypto.PublicKey import RSA
|
|
|
|
from Crypto.Cipher import AES
|
|
|
|
from Crypto.Cipher import PKCS1_v1_5
|
2012-04-07 16:02:46 +02:00
|
|
|
|
|
|
|
#Eclipse pyDev error fix
|
|
|
|
wx=wx
|
|
|
|
|
2012-04-11 22:22:58 +02:00
|
|
|
EntityID = 0
|
|
|
|
|
|
|
|
class ServerConnection(threading.Thread):
|
2012-04-07 16:02:46 +02:00
|
|
|
|
|
|
|
def __init__(self, window, username, password, sessionID, server, port):
|
2012-04-11 22:22:58 +02:00
|
|
|
threading.Thread.__init__(self)
|
2012-04-07 16:02:46 +02:00
|
|
|
self.username = username
|
|
|
|
self.password = password
|
|
|
|
self.sessionID = sessionID
|
|
|
|
self.server = server
|
|
|
|
self.port = port
|
2012-04-11 22:22:58 +02:00
|
|
|
if(window == None):
|
|
|
|
self.NoGUI = True
|
2012-05-31 14:50:01 +02:00
|
|
|
else:
|
|
|
|
self.NoGUI = False
|
2012-04-07 16:02:46 +02:00
|
|
|
self.window = window
|
|
|
|
|
2012-07-17 23:42:42 +02:00
|
|
|
def setWindow(self, window):
|
|
|
|
self.window = window
|
|
|
|
|
2012-04-15 18:49:47 +02:00
|
|
|
def grabSocket(self):
|
|
|
|
return self.socket
|
|
|
|
|
2012-04-11 22:22:58 +02:00
|
|
|
def run(self):
|
2012-04-07 16:02:46 +02:00
|
|
|
try:
|
2012-09-02 19:54:16 +02:00
|
|
|
#Create the socket and fileobject
|
|
|
|
self.socket = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
|
2012-04-07 16:02:46 +02:00
|
|
|
self.socket.connect ( ( self.server, self.port ) )
|
2012-04-15 16:51:00 +02:00
|
|
|
self.FileObject = self.socket.makefile()
|
2012-09-02 19:54:16 +02:00
|
|
|
|
|
|
|
#Send out the handshake packet
|
|
|
|
PacketSenderManager.sendHandshake(self.socket, self.username, self.server, self.port)
|
|
|
|
|
|
|
|
#Receive the encryption packet id
|
|
|
|
packetid = self.socket.recv(1)
|
|
|
|
|
|
|
|
#Sanity check the packet id
|
|
|
|
if (packetid != "\xFD"):
|
|
|
|
if(self.NoGUI == False):
|
|
|
|
self.window.ConnectPanel.Status.SetFont(wx.Font(15, wx.MODERN, wx.NORMAL, wx.NORMAL, 0, "Minecraft"))
|
|
|
|
self.window.ConnectPanel.Status.SetLabel("Server responded with malformed packet")
|
|
|
|
else:
|
|
|
|
print "Server responded with malformed packet"
|
|
|
|
return False
|
|
|
|
|
|
|
|
#Parse the packet
|
|
|
|
packetFD = PacketListenerManager.handleFD(self.FileObject)
|
|
|
|
|
|
|
|
#Import the server's public key
|
|
|
|
print "#Import the server's public key"
|
|
|
|
self.pubkey = RSA.importKey(packetFD['Public Key'])
|
|
|
|
|
|
|
|
#Generate a 16 byte (128 bit) shared secret
|
|
|
|
print "#Generate a 16 byte (128 bit) shared secret"
|
|
|
|
self.sharedSecret = _UserFriendlyRNG.get_random_bytes(16)
|
|
|
|
|
|
|
|
#Grab the server id
|
|
|
|
print "#Grab the server id"
|
|
|
|
serverid = packetFD['ServerID']
|
|
|
|
sha1 = hashlib.sha1()
|
|
|
|
sha1.update(serverid)
|
|
|
|
sha1.update(str(self.sharedSecret))
|
|
|
|
sha1.update(str(self.pubkey))
|
|
|
|
serverid = sha1.hexdigest()
|
|
|
|
|
|
|
|
#Authenticate the server from sessions.minecraft.net
|
|
|
|
print "#Authenticate the server from sessions.minecraft.net"
|
2012-04-07 16:02:46 +02:00
|
|
|
if(serverid != '-'):
|
2012-07-17 23:42:42 +02:00
|
|
|
try:
|
2012-09-02 19:54:16 +02:00
|
|
|
#Open up the url with the appropriate get parameters
|
2012-07-17 23:42:42 +02:00
|
|
|
url = "http://session.minecraft.net/game/joinserver.jsp?user=" + self.username + "&sessionId=" + self.sessionID + "&serverId=" + serverid
|
|
|
|
response = urllib2.urlopen(url).read()
|
2012-09-02 19:54:16 +02:00
|
|
|
|
2012-07-17 23:42:42 +02:00
|
|
|
if(response != "OK"):
|
2012-09-02 19:54:16 +02:00
|
|
|
#handle gui errors
|
2012-07-17 23:42:42 +02:00
|
|
|
if(self.NoGUI == False):
|
|
|
|
self.window.ConnectPanel.Status.SetFont(wx.Font(15, wx.MODERN, wx.NORMAL, wx.NORMAL, 0, "Minecraft"))
|
|
|
|
self.window.ConnectPanel.Status.SetLabel("Response from sessions.minecraft.net wasn't OK")
|
|
|
|
else:
|
|
|
|
print "Response from sessions.minecraft.net wasn't OK, it was " + response
|
|
|
|
return False
|
2012-09-02 19:54:16 +02:00
|
|
|
|
|
|
|
#Success \o/ We can now begin sending our stuff to the server
|
|
|
|
print "#Success \o/ We can now begin sending our stuff to the server"
|
|
|
|
|
|
|
|
#Instantiate our main packet listener
|
|
|
|
print "#Instantiate our main packet listener"
|
|
|
|
PacketListener(self, self.window, self.socket, self.FileObject).start()
|
|
|
|
|
|
|
|
#Encrypt the verification token from earlier along with our shared secret with the server's rsa key
|
|
|
|
print "#Encrypt the verification token from earlier along with our shared secret"
|
|
|
|
self.RSACipher = PKCS1_v1_5.new(self.pubkey)
|
|
|
|
encryptedSanityToken = self.RSACipher.encrypt(str(packetFD['Token']))
|
|
|
|
encryptedSharedSecret = self.RSACipher.encrypt(str(self.sharedSecret))
|
|
|
|
|
|
|
|
#Send out a a packet FC to the server
|
|
|
|
print "#Send out a a packet FC to the server"
|
|
|
|
PacketSenderManager.sendFC(self.socket, encryptedSharedSecret, encryptedSanityToken)
|
|
|
|
|
|
|
|
#GUI handling
|
2012-04-11 22:22:58 +02:00
|
|
|
if(self.NoGUI == False):
|
2012-07-17 23:42:42 +02:00
|
|
|
self.window.ConnectPanel.callbackAfterConnect()
|
2012-09-02 19:54:16 +02:00
|
|
|
#Wait for server screen to be ready
|
2012-07-17 23:42:42 +02:00
|
|
|
while(not hasattr(self.window, 'text')):
|
|
|
|
continue
|
2012-09-02 19:54:16 +02:00
|
|
|
|
2012-07-17 23:42:42 +02:00
|
|
|
except Exception, e:
|
2012-09-02 19:54:16 +02:00
|
|
|
#handle gui errors
|
2012-07-17 23:42:42 +02:00
|
|
|
if(self.NoGUI == False and hasattr(self.window, 'ConnectPanel')):
|
|
|
|
self.window.ConnectPanel.Status.SetForegroundColour(wx.RED)
|
|
|
|
self.window.ConnectPanel.Status.SetLabel("Conection to sessions.mc.net failed")
|
|
|
|
self.window.ConnectPanel.RotationThread.Kill = True
|
2012-09-02 19:54:16 +02:00
|
|
|
traceback.print_exc()
|
2012-04-11 22:22:58 +02:00
|
|
|
else:
|
2012-05-31 14:50:01 +02:00
|
|
|
if(self.NoGUI):
|
|
|
|
print "Server is in offline mode"
|
2012-09-02 19:54:16 +02:00
|
|
|
#TODO: handle offline mod servers
|
2012-04-07 16:02:46 +02:00
|
|
|
except Exception, e:
|
2012-07-17 23:42:42 +02:00
|
|
|
if(self.NoGUI == False and self.window):
|
2012-05-31 14:50:01 +02:00
|
|
|
self.window.ConnectPanel.Status.SetForegroundColour(wx.RED)
|
|
|
|
self.window.ConnectPanel.Status.SetLabel("Connection to server failed")
|
|
|
|
self.window.ConnectPanel.RotationThread.Kill = True
|
2012-04-11 22:22:58 +02:00
|
|
|
else:
|
|
|
|
print "Connection to server failed"
|
2012-04-07 16:02:46 +02:00
|
|
|
traceback.print_exc()
|
|
|
|
return False
|
2012-07-17 23:42:42 +02:00
|
|
|
#self.window.Status.SetLabel("Connected to " + self.server + "!")
|
2012-09-02 19:54:16 +02:00
|
|
|
|
|
|
|
class EncryptedFileObjectHandler():
|
|
|
|
|
|
|
|
def __init__(self, fileobject, cipher):
|
|
|
|
self.fileobject = fileobject
|
|
|
|
self.cipher = cipher
|
|
|
|
|
|
|
|
def read(self, length):
|
|
|
|
return self.cipher.decrypt(self.fileobject.read(length))
|
|
|
|
|
|
|
|
class EncryptedSocketObjectHandler():
|
|
|
|
|
|
|
|
def __init__(self, socket, cipher):
|
|
|
|
self.socket = socket
|
|
|
|
self.cipher = cipher
|
|
|
|
|
|
|
|
def send(self, stuff):
|
|
|
|
self.socket.send(self.cipher.encrypt(stuff))
|
|
|
|
|
|
|
|
def recv(self, length):
|
|
|
|
return self.cipher.decrypt(self.socket.recv(length))
|
|
|
|
|
|
|
|
def close(self):
|
|
|
|
self.socket.close()
|
2012-04-15 18:49:47 +02:00
|
|
|
|
2012-04-10 21:14:32 +02:00
|
|
|
class PacketListener(threading.Thread):
|
|
|
|
|
2012-04-15 18:49:47 +02:00
|
|
|
def __init__(self, connection, window, socket, FileObject):
|
2012-04-10 21:14:32 +02:00
|
|
|
threading.Thread.__init__(self)
|
2012-09-02 19:54:16 +02:00
|
|
|
self.connection = connection
|
2012-04-10 21:14:32 +02:00
|
|
|
self.socket = socket
|
2012-04-15 16:51:00 +02:00
|
|
|
self.FileObject = FileObject
|
2012-09-02 19:54:16 +02:00
|
|
|
self.window = window
|
|
|
|
self.encryptedConnection = False
|
|
|
|
|
|
|
|
def enableEncryption(self):
|
|
|
|
#Create an AES cipher from the previously obtained public key
|
|
|
|
print "#Create an AES cipher from the previously generated shared secret"
|
|
|
|
self.cipher = AES.new(str(self.connection.sharedSecret), AES.MODE_CFB, IV=self.connection.sharedSecret, segment_size=8)
|
|
|
|
self.rawsocket = self.socket
|
|
|
|
self.socket = EncryptedSocketObjectHandler(self.rawsocket, self.cipher)
|
|
|
|
self.rawFileObject = self.FileObject
|
|
|
|
self.FileObject = EncryptedFileObjectHandler(self.rawFileObject, self.cipher)
|
|
|
|
self.encryptedConnection = True
|
|
|
|
print "#Encryption enabled"
|
2012-04-10 21:14:32 +02:00
|
|
|
|
|
|
|
def run(self):
|
|
|
|
while True:
|
|
|
|
try:
|
2012-09-02 19:54:16 +02:00
|
|
|
response = self.FileObject.read(1)
|
|
|
|
if (response == ""):
|
|
|
|
continue
|
2012-07-17 23:42:42 +02:00
|
|
|
except Exception, e:
|
|
|
|
if(self.window):
|
|
|
|
self.window.Status.SetLabel("Ping timeout")
|
2012-04-11 22:22:58 +02:00
|
|
|
else:
|
|
|
|
print "Ping timeout"
|
2012-09-02 19:54:16 +02:00
|
|
|
traceback.print_exc()
|
2012-04-10 21:14:32 +02:00
|
|
|
break
|
2012-09-02 19:54:16 +02:00
|
|
|
print hex(ord(response))
|
|
|
|
if(response == "\x00"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle00(self.FileObject, self.socket)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x01"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle01(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x03"):
|
2012-05-31 14:50:01 +02:00
|
|
|
message = PacketListenerManager.handle03(self.FileObject)
|
|
|
|
if(self.connection.NoGUI):
|
2012-09-02 19:54:16 +02:00
|
|
|
filtered_string = filter(lambda x: x in string.printable, message)
|
|
|
|
#print message.replace(u'\xa7', '&')
|
|
|
|
print filtered_string
|
2012-07-17 23:42:42 +02:00
|
|
|
elif(self.window):
|
|
|
|
self.window.handleChat(message)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x04"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle04(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x05"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle05(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x06"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle06(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x07"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle07(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x08"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle08(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x09"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle09(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x0D"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle0D(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x11"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle11(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x12"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle12(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x14"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle14(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x15"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle15(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x16"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle16(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x17"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle17(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x18"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle18(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x19"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle19(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x1A"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle1A(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x1C"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle1C(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x1D"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle1D(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x1E"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle1E(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x1F"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle1F(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x20"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle20(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x21"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle21(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x22"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle22(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x23"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle23(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x26"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle26(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x27"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle27(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x28"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle28(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x29"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle29(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x2A"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle2A(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x2B"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle2B(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x32"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle32(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x33"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle33(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x34"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle34(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x35"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle35(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x36"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle36(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x3C"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle3C(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x3D"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle3D(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x46"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle46(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x47"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle47(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x64"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle64(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x65"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle65(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x67"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle67(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x68"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle68(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x69"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle69(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x6A"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle6A(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x6B"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle6B(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x82"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle82(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x83"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle83(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\x84"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handle84(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\xC8"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handleC8(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\xC9"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handleC9(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\xCA"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handleCA(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\xFA"):
|
2012-04-15 18:49:47 +02:00
|
|
|
PacketListenerManager.handleFA(self.FileObject)
|
2012-09-02 19:54:16 +02:00
|
|
|
elif(response == "\xFC"):
|
|
|
|
PacketListenerManager.handleFC(self.FileObject)
|
|
|
|
if (not self.encryptedConnection):
|
|
|
|
self.enableEncryption()
|
|
|
|
PacketSenderManager.sendCD(self.socket, 0)
|
|
|
|
elif(response == "\xFF"):
|
2012-04-15 18:49:47 +02:00
|
|
|
DisconMessage = PacketListenerManager.handleFF(self.FileObject)
|
2012-04-14 17:29:04 +02:00
|
|
|
if(self.window == None):
|
|
|
|
print "Disconnected: " + DisconMessage
|
2012-09-02 19:54:16 +02:00
|
|
|
if(self.window):
|
2012-07-17 23:42:42 +02:00
|
|
|
if(hasattr(self.window, 'ChatPanel')):
|
|
|
|
self.window.ChatPanel.Status.SetLabel("Disconnected: " + DisconMessage)
|
2012-09-02 19:54:16 +02:00
|
|
|
if(hasattr(self.window, 'Status')):
|
2012-07-17 23:42:42 +02:00
|
|
|
self.window.Status.SetLabel("Disconnected: " + DisconMessage)
|
|
|
|
self.socket.close()
|
2012-04-14 17:29:04 +02:00
|
|
|
break
|
2012-09-02 19:54:16 +02:00
|
|
|
else:
|
|
|
|
if(self.window == None):
|
|
|
|
print "Protocol error: " + hex(ord(response))
|
|
|
|
self.socket.close()
|
|
|
|
break
|