89 $header = $stream->
get(2);
90 if($header !==
"\xfe\xfd"){
93 $packetType = $stream->getByte();
94 $sessionID = $stream->getInt();
98 $reply = chr(self::HANDSHAKE);
99 $reply .= Binary::writeInt($sessionID);
100 $reply .= self::getTokenString($this->token, $address) .
"\x00";
105 case self::STATISTICS:
106 $token = $stream->getInt();
107 if($token !== ($t1 = self::getTokenString($this->token, $address)) && $token !== ($t2 = self::getTokenString($this->lastToken, $address))){
108 $this->logger->debug(
"Bad token $token from $address $port, expected $t1 or $t2");
112 $reply = chr(self::STATISTICS);
113 $reply .= Binary::writeInt($sessionID);
115 $remaining = $stream->getRemaining();
116 if(strlen($remaining) === 4){
117 $reply .= $this->
server->getQueryInformation()->getLongQuery();
119 $reply .= $this->
server->getQueryInformation()->getShortQuery();
127 }
catch(BinaryDataException $e){
128 $this->logger->debug(
"Bad packet from $address $port: " . $e->getMessage());