Skip to content

Commit 57f0fa6

Browse files
committed
Change increment id to random
1 parent 05bd363 commit 57f0fa6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Packet/Header.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use function base64_encode;
1515
use function is_string;
1616
use function ord;
17+
use function rand;
1718
use function serialize;
1819
use function sprintf;
1920
use function strlen;
@@ -150,12 +151,13 @@ class Header implements PacketHeaderInterface
150151
protected int $arcount;
151152

152153

153-
/**
154+
/*
154155
* Maximum 16-bit integer = 65535
155156
*
156157
* @var int
157-
*/
158+
*
158159
private static int $increment = 0;
160+
*/
159161

160162
/**
161163
* Header constructor
@@ -279,11 +281,13 @@ public static function createQueryHeader(
279281
bool $rdFlag = true
280282
) : PacketHeaderInterface {
281283
if ($id === null) {
284+
$id = rand(1, 65535);
282285
// 160-bit max 65535 -> then reset to 1
283-
if (++self::$increment > 65535) {
286+
/*if (++self::$increment > 65535) {
284287
self::$increment = 1;
285288
}
286289
$id = self::$increment;
290+
*/
287291
}
288292

289293
$id = $id % 65535;

0 commit comments

Comments
 (0)