def on_input(self): data = self.buffer_recv() for header, payload in data: self.proxy.packlog.debug(self.name, header, payload) if not self.proxy.filter(header, payload, self.target): origdata = packets.make_packet(header, payload) self.target.send(origdata)
def send_packet(self, name, payload): p = make_packet(name, payload) if config.DEBUG: packet_printout("CLIENT", [(packets_by_name[name], Container(**payload))], types=log_packet_types) self.sendData(p)
def handle_packets(self, packetId, packet): if packetId in packets_by_id: packetId = packets_by_id[packetId] else: reason = "Invalid packetId: %i" % packetId disc = make_packet("Disconnect",reasonType="Custom",reason=reason,reasonlength=len(reason)) self.send(disc) return if packetId == "ConnectionRequest": print "sending acceptConnection" #self.connected = True accept_connection = make_packet("AcceptConnection",int=1) self.send(accept_connection,1) print "acceptConnection sent" elif packetId == "AcceptConnection": print "got acceptConnection" self.connected = True else: print packetId,packet
def onHandshake(self, payload): print ("DEBUG: Received Handshake packet.") print ("INFO: Asking minecraft.net to join...") login = mechanize.Browser() url = "http://www.minecraft.net/game/joinserver.jsp?user="******"&sessionId=" + session_id url+= "&serverId=" + payload.username login.open(url) print ("DEBUG: Sending Login Response packet.") self.protocol.send(make_packet("login", {"protocol": 8, "username": username, "unused": "Password", "seed": 0, "dimension": 0}))
def send_packet(self, name, **kwargs): header = packets.packets_by_name[name] self.packlog.debug('send', header, kwargs) self.send(packets.make_packet(name, **kwargs))
def send_packet(self, name, payload): p = make_packet(name, payload) if config.DEBUG: packet_printout("CLIENT", [(packets_by_name[name], Container(**payload))]) self.sendData(p)
def faster_time(self, header, payload, target): if header == packets.packets_by_name['time']: newdata = packets.make_packet(header, {'timestamp': payload.timestamp * 30}) target.send(newdata) self.stop_relay()
def connectionMade(self): self.send(make_packet("handshake", {"username": username}))
def sendMessage(self, message): self.protocol.send(make_packet("chat", {"message": message}))
def onPing(self, payload): self.protocol.send(make_packet("ping"))