mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Packet names
This commit is contained in:
parent
4daf7840d8
commit
ff7a61c7ae
@ -161,6 +161,16 @@ class CustomPacketHandler{
|
||||
$this->raw .= "\x00\xae\x21\x4e";
|
||||
}
|
||||
break;
|
||||
case 0x15:
|
||||
//null
|
||||
break;
|
||||
case 0x00:
|
||||
if($this->c === false){
|
||||
$this->data["payload"] = $this->get(8);
|
||||
}else{
|
||||
$this->raw .= $this->data["payload"];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,15 +26,17 @@ the Free Software Foundation, either version 3 of the License, or
|
||||
*/
|
||||
|
||||
class MinecraftInterface{
|
||||
var $pstruct, $name, $server, $protocol, $client, $buffer;
|
||||
var $pstruct, $name, $server, $protocol, $client, $buffer, $dataName;
|
||||
|
||||
function __construct($server, $protocol = CURRENT_PROTOCOL, $port = 25565, $listen = false, $client = true){
|
||||
$this->server = new Socket($server, $port, (bool) $listen);
|
||||
$this->protocol = (int) $protocol;
|
||||
require("pstruct/RakNet.php");
|
||||
require("pstruct/packetName.php");
|
||||
require("pstruct/dataName.php");
|
||||
$this->pstruct = $pstruct;
|
||||
$this->name = $packetName;
|
||||
$this->dataName = $dataName;
|
||||
$this->buffer = array();
|
||||
$this->client = (bool) $client;
|
||||
$this->start = microtime(true);
|
||||
@ -53,7 +55,7 @@ class MinecraftInterface{
|
||||
|
||||
protected function writeDump($pid, $raw, $data, $origin = "client", $ip = "", $port = 0){
|
||||
if(LOG === true and DEBUG >= 2){
|
||||
$p = "[".(microtime(true) - $this->start)."] [".((($origin === "client" and $this->client === true) or ($origin === "server" and $this->client === false)) ? "CLIENT->SERVER":"SERVER->CLIENT")." ".$ip.":".$port."]: ".$this->name[$pid]." (0x".Utils::strTohex(chr($pid)).") [lenght ".strlen($raw)."]".PHP_EOL;
|
||||
$p = "[".(microtime(true) - $this->start)."] [".((($origin === "client" and $this->client === true) or ($origin === "server" and $this->client === false)) ? "CLIENT->SERVER":"SERVER->CLIENT")." ".$ip.":".$port."]: ".(isset($data["id"]) ? "DATA ".$this->dataName[$pid]:$this->name[$pid])." (0x".Utils::strTohex(chr($pid)).") [lenght ".strlen($raw)."]".PHP_EOL;
|
||||
$p .= Utils::hexdump($raw);
|
||||
if(is_array($data)){
|
||||
foreach($data as $i => $d){
|
||||
|
@ -152,7 +152,7 @@ class PocketMinecraftClient{
|
||||
++$this->counter[0];
|
||||
break;
|
||||
case 0x86:
|
||||
console("[DEBUG] Time: ".$data["time"], true, true, 3);
|
||||
console("[DEBUG] Time: ".$data["time"], true, true, 2);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -47,10 +47,10 @@ class Session{
|
||||
}
|
||||
}
|
||||
|
||||
public function close(){
|
||||
public function close($reason = "timeout"){
|
||||
$this->server->deleteEvent("onTick", $this->eventID);
|
||||
$this->connected = false;
|
||||
console("[DEBUG] Session with ".$this->ip.":".$this->port." closed due to timeout", true, true, 2);
|
||||
console("[DEBUG] Session with ".$this->ip.":".$this->port." closed due to ".$reason, true, true, 2);
|
||||
}
|
||||
|
||||
public function handle($pid, &$data){
|
||||
@ -72,6 +72,19 @@ class Session{
|
||||
$this->send(0xc0, array(1, true, $data[0]));
|
||||
}
|
||||
switch($data["id"]){
|
||||
/*case 0x00:
|
||||
$this->send(0x84, array(
|
||||
$this->counter[0],
|
||||
0x40,
|
||||
array(
|
||||
"payload" => $data["payload"],
|
||||
),
|
||||
));
|
||||
++$this->counter[0];
|
||||
break;*/
|
||||
case 0x15:
|
||||
$this->close("client disconnect");
|
||||
break;
|
||||
case 0x09:
|
||||
$this->send(0x84, array(
|
||||
$this->counter[0],
|
||||
|
35
pstruct/dataName.php
Normal file
35
pstruct/dataName.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|
||||
-
|
||||
/ \
|
||||
/ \
|
||||
/ POCKET \
|
||||
/ MINECRAFT PHP \
|
||||
|\ @shoghicp /|
|
||||
|. \ / .|
|
||||
| .. \ / .. |
|
||||
| .. | .. |
|
||||
| .. | .. |
|
||||
\ | /
|
||||
\ | /
|
||||
\ | /
|
||||
\ | /
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
$dataName = array(
|
||||
0x00 => "KeepAlive",
|
||||
0x09 => "ClientHandshake",
|
||||
0x10 => "ServerHandshake",
|
||||
0x13 => "ClientConnect",
|
||||
0x15 => "ClientDisconnect",
|
||||
0x82 => "LoginPacket",
|
||||
);
|
Loading…
x
Reference in New Issue
Block a user