Skip to content

Commit

Permalink
for now
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaileke committed Aug 3, 2024
1 parent 1287f4c commit 3764e4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/server/UnconnectedMessageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ private function handle(OfflineMessage $packet, InternetAddress $address) : bool
$this->server->sendPacket(IncompatibleProtocolVersion::create($this->protocolAcceptor->getPrimaryVersion(), $this->server->getID()), $address);
$this->server->getLogger()->notice("Refused connection from $address due to incompatible RakNet protocol version (version $packet->protocol)");
}else{
$serverHasSecurity = false; // then relocate it and make it available
if ($serverHasSecurity) {
if (!Cookie::$disableCookies) {
Cookie::add($address);
}
//IP header size (20 bytes) + UDP header size (8 bytes)
Expand All @@ -102,10 +101,12 @@ private function handle(OfflineMessage $packet, InternetAddress $address) : bool
$this->server->getLogger()->debug("Not creating session for $address due to session already opened");
return true;
}
if (!Cookie::check($address, $packet->cookie)) {
// Disconnect if OpenConnectionReply1 and the cookie in the OpenCnnectionRequest2 packet do not match
$this->server->getLogger()->debug("Not creating session for $address due to session mismatched cookies");
return true;
if (!Cookie::$disableCookies) {
if (!Cookie::check($address, $packet->cookie)) {
// Disconnect if OpenConnectionReply1 and the cookie in the OpenCnnectionRequest2 packet do not match
$this->server->getLogger()->debug("Not creating session for $address due to session mismatched cookies");
return true;
}
}
$mtuSize = min($packet->mtuSize, $this->server->getMaxMtuSize()); //Max size, do not allow creating large buffers to fill server memory
$this->server->sendPacket(OpenConnectionReply2::create($this->server->getID(), $address, $mtuSize, false), $address);
Expand Down
2 changes: 2 additions & 0 deletions src/utils/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

final class Cookie{

public static bool $disableCookies = true;

/**
* @var array<string, int> $cookies
*/
Expand Down

0 comments on commit 3764e4b

Please sign in to comment.