Beispiel #1
0
class ConnectionRequestAccepted(Packet):
    id = PacketIdentifiers.ConnectionRequestAccepted

    clientAddress = InternetAddress("127.0.0.1", 0, 4)
    systemIndex = 0
    systemAddresses = []
    requestTime = 0
    time = 0

    def encodePayload(self):
        self.putAddress(self.clientAddress)
        self.putShort(self.systemIndex)
        i = 0
        while i < 20:
            self.putAddress(
                self.systemAddresses[i] if len(self.systemAddresses) > i else
                InternetAddress("127.0.0.1", 0, 4))
            i += 1
        self.putLong(self.requestTime)
        self.putLong(self.time)

    def decodePayload(self):
        self.clientAddress = self.getAddress()
        self.systemIndex = self.getShort()
        i = 0
        while i < 20:
            self.systemAddresses.append(self.getAddress())
            i += 1
        self.requestTime = self.getLong()
        self.time = self.getLong()
Beispiel #2
0
 def run(self):
     while True:
         buffer = self.socket.receiveBuffer()
         if buffer is not None:
             data, address = buffer
             self.handle(data, InternetAddress(address[0], address[1]))
             self.tick()
Beispiel #3
0
 def decodePayload(self):
     self.address = self.getAddress()
     for i in range(0, 20):
         if self.getOffset >= len(self.getBuffer) - 16:
             self.systemAddresses.append(InternetAddress("0.0.0.0", 0, 4))
         else:
             self.systemAddresses.append(self.getAddress())
     self.pingTime = self.getLong()
     self.pongTime = self.getLong()
Beispiel #4
0
 def getAddress(self):
     ver = self.getByte()
     if ver == 4:
         addr = ".".join([
             str((~self.getByte()) & 0xff),
             str((~self.getByte()) & 0xff),
             str((~self.getByte()) & 0xff),
             str((~self.getByte()) & 0xff)
         ])
         port = self.getShort()
         return InternetAddress(addr, port, ver)
     if ver == 6:
         self.getLShort()
         port = self.getShort()
         self.getInt()
         addr = socket.inet_ntop(socket.AF_INET6, self.get(16))
         self.getInt()
         return InternetAddress(addr, port, ver)
     raise Exception(f"Unknown address version {ver}")
Beispiel #5
0
 def run(self):
     while True:
         buffer = self.socket.receiveBuffer()
         if buffer is not None:
             data, address = buffer
             self.handle(data, InternetAddress(address[0], address[1]))
         if not self.shutdown:
             for token in self.connections:
                 self.connections[token].update(timeNow())
             sleep(self.raknetTickLength)
Beispiel #6
0
 def encodePayload(self):
     self.putAddress(self.clientAddress)
     self.putShort(self.systemIndex)
     i = 0
     while i < 20:
         self.putAddress(
             self.systemAddresses[i] if len(self.systemAddresses) > i else
             InternetAddress("127.0.0.1", 0, 4))
         i += 1
     self.putLong(self.requestTime)
     self.putLong(self.time)
Beispiel #7
0
 def putAddress(self, address: InternetAddress):
     ver = address.getVersion()
     addr = address.getAddress()
     port = address.getPort()
     self.putByte(ver)
     if ver == 4:
         parts = str(addr).split(".")
         partsLength = len(parts)
         assert partsLength == 4, f"Expected address length: 4, got {partsLength}"
         for part in parts:
             self.putByte((~(int(part))) & 0xff)
         self.putShort(port)
     elif ver == 6:
         self.putLShort(socket.AF_INET6)
         self.putShort(port)
         self.putInt(0)
         self.put(socket.inet_pton(socket.AF_INET6, addr))
         self.putInt(0)
     else:
         raise Exception(f"Unknown address version {ver}")
Beispiel #8
0
 def __init__(self):
     edition = input("Choose Edition [mcbe/mcpi] ")
     if edition.lower() == "mcbe":
         self.name = self.makeName()
     elif edition.lower() == "mcpi":
         self.name = "MCCPP;Demo;MyServer"
     else:
         print("Invalid Edition")
         os.kill(os.getpid(), signal.SIGTERM)
     self.server = Server(InternetAddress("0.0.0.0", 19132), self)
     self.server.name = self.name
class OpenConnectionRequest2(OfflinePacket):
    id = PacketIdentifiers.OpenConnectionRequest2
    
    serverAddress = InternetAddress("127.0.0.1", 0, 4)
    mtu = 0
    clientId = 0
    
    def encodePayload(self):
        self.putMagic()
        self.putAddress(self.serverAddress)
        self.putShort(self.mtu)
        self.putLong(self.clientId)
        
    def decodePayload(self):
        self.magic = self.getMagic()
        self.serverAddress = self.getAddress()
        self.mtu = self.getShort()
        self.clientId = self.getLong()
Beispiel #10
0
class NewIncomingConnection(Packet):
    id = PacketIdentifiers.NewIncomingConnection

    address = InternetAddress("127.0.0.1", 0, 4)
    systemAddresses = []
    pingTime = 0
    pongTime = 0

    def encodePayload(self):
        self.putAddress(self.address)
        for address in self.systemAddresses:
            self.putAddress(address)
        self.putLong(self.pingTime)
        self.putLong(self.pongTime)

    def decodePayload(self):
        self.address = self.getAddress()
        i = 0
        while i < 20:
            self.systemAddresses.append(self.getAddress())
            i += 1
        self.pingTime = self.getLong()
        self.pongTime = self.getLong()
Beispiel #11
0
 def __init__(self, address, port):
     self.raknet = Server(InternetAddress(address, port), self)
     self.raknet.name = "MCPE;Dedicated Server;390;1.14.60;0;10;13253860892328930865;Bedrock level;Survival;1;19132;19133;"
     self.pool = Pool()
Beispiel #12
0
 def __init__(self):
     self.server = Server(InternetAddress("0.0.0.0", 19132), self)
     self.name = self.makeName()
     self.server.name = self.name
Beispiel #13
0
 def decodePayload(self):
     self.clientAddress = self.getAddress()
     self.systemIndex = self.getShort()
     for i in range(0, 20):
         self.systemAddresses.append(self.getAddress() if self.getOffset + 16 < len(self.getBuffer()) else InternetAddress("127.0.0.1", 0, 4))
     self.requestTime = self.getLong()
     self.time = self.getLong()
Beispiel #14
0
 def encodePayload(self):
     self.putAddress(self.clientAddress)
     self.putShort(self.systemIndex)
     for i in range(0, 20):
         self.putAddress(self.systemAddresses[i] if len(self.systemAddresses) > i else InternetAddress("127.0.0.1", 0, 4))
     self.putLong(self.requestTime)
     self.putLong(self.time)