mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-08 12:48:32 +00:00
Few protocol edits
This commit is contained in:
parent
2b03e71c97
commit
f8c6921ac4
@ -202,10 +202,10 @@ class Player{
|
|||||||
}
|
}
|
||||||
$reason = $reason == "" ? "server stop":$reason;
|
$reason = $reason == "" ? "server stop":$reason;
|
||||||
$this->eventHandler(new Container("You have been kicked. Reason: ".$reason), "server.chat");
|
$this->eventHandler(new Container("You have been kicked. Reason: ".$reason), "server.chat");
|
||||||
$this->dataPacket(MC_LOGIN_STATUS, array(
|
$this->directDataPacket(MC_LOGIN_STATUS, array(
|
||||||
"status" => 1,
|
"status" => 1,
|
||||||
));
|
));
|
||||||
$this->dataPacket(MC_DISCONNECT);
|
$this->directDataPacket(MC_DISCONNECT);
|
||||||
$this->sendBuffer();
|
$this->sendBuffer();
|
||||||
$this->buffer = null;
|
$this->buffer = null;
|
||||||
unset($this->buffer);
|
unset($this->buffer);
|
||||||
@ -638,11 +638,15 @@ class Player{
|
|||||||
if($this->loggedIn === true){
|
if($this->loggedIn === true){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if(count($this->server->clients) >= $this->server->maxClients){
|
||||||
|
$this->close("server is full!", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if($data["protocol1"] !== CURRENT_PROTOCOL){
|
if($data["protocol1"] !== CURRENT_PROTOCOL){
|
||||||
$this->close("protocol", false);
|
$this->close("protocol", false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->loggedIn = true;
|
|
||||||
if(preg_match('#^[a-zA-Z0-9_]{2,16}$#', $data["username"])){
|
if(preg_match('#^[a-zA-Z0-9_]{2,16}$#', $data["username"])){
|
||||||
$this->username = $data["username"];
|
$this->username = $data["username"];
|
||||||
$this->iusername = strtolower($this->username);
|
$this->iusername = strtolower($this->username);
|
||||||
@ -658,6 +662,8 @@ class Player{
|
|||||||
$this->close("\"\x1b[33m".$this->username."\x1b[0m\" is banned!", false);
|
$this->close("\"\x1b[33m".$this->username."\x1b[0m\" is banned!", false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$this->loggedIn = true;
|
||||||
|
|
||||||
$u = $this->server->api->player->get($this->iusername);
|
$u = $this->server->api->player->get($this->iusername);
|
||||||
if($u !== false){
|
if($u !== false){
|
||||||
$u->close("logged in from another location");
|
$u->close("logged in from another location");
|
||||||
@ -1045,7 +1051,7 @@ class Player{
|
|||||||
$this->nextBuffer = microtime(true) + 0.1;
|
$this->nextBuffer = microtime(true) + 0.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function directDataPacket($id, $data, $count = false){
|
public function directDataPacket($id, $data = array(), $count = false){
|
||||||
$data["id"] = $id;
|
$data["id"] = $id;
|
||||||
$data["sendtime"] = microtime(true);
|
$data["sendtime"] = microtime(true);
|
||||||
if($count === false){
|
if($count === false){
|
||||||
|
@ -534,15 +534,6 @@ class PocketMinecraftServer{
|
|||||||
), false, $packet["ip"], $packet["port"]);
|
), false, $packet["ip"], $packet["port"]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if($this->api->ban->isIPBanned($packet["ip"])){
|
|
||||||
$this->send(0x1c, array(
|
|
||||||
$data[0],
|
|
||||||
$this->serverID,
|
|
||||||
RAKNET_MAGIC,
|
|
||||||
$this->serverType. $this->name . " [You're banned]",
|
|
||||||
), false, $packet["ip"], $packet["port"]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(!isset($this->custom["times_".$CID])){
|
if(!isset($this->custom["times_".$CID])){
|
||||||
$this->custom["times_".$CID] = 0;
|
$this->custom["times_".$CID] = 0;
|
||||||
}
|
}
|
||||||
@ -561,24 +552,6 @@ class PocketMinecraftServer{
|
|||||||
$this->custom["times_".$CID] = ($this->custom["times_".$CID] + 1) % strlen($this->description);
|
$this->custom["times_".$CID] = ($this->custom["times_".$CID] + 1) % strlen($this->description);
|
||||||
break;
|
break;
|
||||||
case 0x05:
|
case 0x05:
|
||||||
if($this->api->ban->isIPBanned($packet["ip"]) or count($this->clients) >= $this->maxClients){
|
|
||||||
$this->send(0x80, array(
|
|
||||||
0,
|
|
||||||
0x00,
|
|
||||||
array(
|
|
||||||
"id" => MC_LOGIN_STATUS,
|
|
||||||
"status" => 1,
|
|
||||||
),
|
|
||||||
), false, $packet["ip"], $packet["port"]);
|
|
||||||
$this->send(0x80, array(
|
|
||||||
1,
|
|
||||||
0x00,
|
|
||||||
array(
|
|
||||||
"id" => MC_DISCONNECT,
|
|
||||||
),
|
|
||||||
), false, $packet["ip"], $packet["port"]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$version = $data[1];
|
$version = $data[1];
|
||||||
$size = strlen($data[2]);
|
$size = strlen($data[2]);
|
||||||
if($version !== CURRENT_STRUCTURE){
|
if($version !== CURRENT_STRUCTURE){
|
||||||
@ -598,24 +571,6 @@ class PocketMinecraftServer{
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x07:
|
case 0x07:
|
||||||
if($this->api->ban->isIPBanned($packet["ip"]) or count($this->clients) >= $this->maxClients){
|
|
||||||
$this->send(0x80, array(
|
|
||||||
0,
|
|
||||||
0x00,
|
|
||||||
array(
|
|
||||||
"id" => MC_LOGIN_STATUS,
|
|
||||||
"status" => 1,
|
|
||||||
),
|
|
||||||
), false, $packet["ip"], $packet["port"]);
|
|
||||||
$this->send(0x80, array(
|
|
||||||
1,
|
|
||||||
0x00,
|
|
||||||
array(
|
|
||||||
"id" => MC_DISCONNECT,
|
|
||||||
),
|
|
||||||
), false, $packet["ip"], $packet["port"]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$port = $data[2];
|
$port = $data[2];
|
||||||
$MTU = $data[3];
|
$MTU = $data[3];
|
||||||
$clientID = $data[4];
|
$clientID = $data[4];
|
||||||
|
@ -34,8 +34,11 @@ define("MC_SERVER_HANDSHAKE", 0x10);
|
|||||||
|
|
||||||
define("MC_CLIENT_HANDSHAKE", 0x13);
|
define("MC_CLIENT_HANDSHAKE", 0x13);
|
||||||
|
|
||||||
|
define("MC_SERVER_FULL", 0x14);
|
||||||
define("MC_DISCONNECT", 0x15);
|
define("MC_DISCONNECT", 0x15);
|
||||||
|
|
||||||
|
define("MC_BANNED", 0x17);
|
||||||
|
|
||||||
define("MC_LOGIN", 0x82);
|
define("MC_LOGIN", 0x82);
|
||||||
define("MC_LOGIN_STATUS", 0x83);
|
define("MC_LOGIN_STATUS", 0x83);
|
||||||
define("MC_READY", 0x84);
|
define("MC_READY", 0x84);
|
||||||
@ -99,6 +102,7 @@ class Protocol{
|
|||||||
|
|
||||||
MC_CLIENT_HANDSHAKE => "Client Handshake",
|
MC_CLIENT_HANDSHAKE => "Client Handshake",
|
||||||
|
|
||||||
|
//MC_SERVER_FULL => "Server Full",
|
||||||
MC_DISCONNECT => "Disconnect",
|
MC_DISCONNECT => "Disconnect",
|
||||||
|
|
||||||
0x18 => "Unknown",
|
0x18 => "Unknown",
|
||||||
|
@ -87,7 +87,7 @@ class CustomPacketHandler{
|
|||||||
$this->data["port"] = Utils::readShort($this->get(2), false);
|
$this->data["port"] = Utils::readShort($this->get(2), false);
|
||||||
$this->data["dataArray"] = Utils::readDataArray($this->get(true, false), 10, $offset);
|
$this->data["dataArray"] = Utils::readDataArray($this->get(true, false), 10, $offset);
|
||||||
$this->get($offset);
|
$this->get($offset);
|
||||||
$this->data["unknown1"] = $this->get(2);
|
$this->data["timestamp"] = $this->get(2);
|
||||||
$this->data["session"] = Utils::readLong($this->get(8));
|
$this->data["session"] = Utils::readLong($this->get(8));
|
||||||
$this->data["session2"] = Utils::readLong($this->get(8));
|
$this->data["session2"] = Utils::readLong($this->get(8));
|
||||||
}else{
|
}else{
|
||||||
@ -119,7 +119,7 @@ class CustomPacketHandler{
|
|||||||
$this->data["dataArray0"] = $this->get(ord($this->get(1)));
|
$this->data["dataArray0"] = $this->get(ord($this->get(1)));
|
||||||
$this->data["dataArray"] = Utils::readDataArray($this->get(true, false), 9, $offset);
|
$this->data["dataArray"] = Utils::readDataArray($this->get(true, false), 9, $offset);
|
||||||
$this->get($offset);
|
$this->get($offset);
|
||||||
$this->data["unknown1"] = $this->get(2);
|
$this->data["timestamp"] = $this->get(2);
|
||||||
$this->data["session2"] = Utils::readLong($this->get(8));
|
$this->data["session2"] = Utils::readLong($this->get(8));
|
||||||
$this->data["session"] = Utils::readLong($this->get(8));
|
$this->data["session"] = Utils::readLong($this->get(8));
|
||||||
}else{
|
}else{
|
||||||
@ -134,9 +134,23 @@ class CustomPacketHandler{
|
|||||||
$this->raw .= Utils::writeLong($this->data["session"]);
|
$this->raw .= Utils::writeLong($this->data["session"]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case MC_SERVER_FULL:
|
||||||
|
if($this->c === false){
|
||||||
|
}else{
|
||||||
|
$this->raw .= RAKNET_MAGIC;
|
||||||
|
$this->raw .= Utils::writeLong($this->data["serverID"]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case MC_DISCONNECT:
|
case MC_DISCONNECT:
|
||||||
//null
|
//null
|
||||||
break;
|
break;
|
||||||
|
case MC_BANNED:
|
||||||
|
if($this->c === false){
|
||||||
|
}else{
|
||||||
|
$this->raw .= RAKNET_MAGIC;
|
||||||
|
$this->raw .= Utils::writeLong($this->data["serverID"]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case MC_LOGIN:
|
case MC_LOGIN:
|
||||||
if($this->c === false){
|
if($this->c === false){
|
||||||
$this->data["username"] = $this->get(Utils::readShort($this->get(2), false));
|
$this->data["username"] = $this->get(Utils::readShort($this->get(2), false));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user