walkor vor 2 Jahren
Ursprung
Commit
8ce5bef266
3 geänderte Dateien mit 4 neuen und 3 gelöschten Zeilen
  1. 2 1
      src/Connection/AsyncTcpConnection.php
  2. 1 1
      src/Protocols/Websocket.php
  3. 1 1
      src/Protocols/Ws.php

+ 2 - 1
src/Connection/AsyncTcpConnection.php

@@ -17,6 +17,7 @@ declare(strict_types=1);
 namespace Workerman\Connection;
 
 use Exception;
+use RuntimeException;
 use stdClass;
 use Throwable;
 use Workerman\Timer;
@@ -152,7 +153,7 @@ class AsyncTcpConnection extends TcpConnection
                 $this->remoteAddress = substr($remoteAddress, strpos($remoteAddress, '/') + 2);
             }
             if (!$this->remoteAddress) {
-                Worker::safeEcho(new Exception('bad remote_address'));
+                throw new RuntimeException('Bad remoteAddress');
             }
         } else {
             if (!isset($addressInfo['port'])) {

+ 1 - 1
src/Protocols/Websocket.php

@@ -322,7 +322,7 @@ class Websocket
             }
         }
         $dataLength = strlen($data);
-        $masks = str_repeat($masks, floor($dataLength / 4)) . substr($masks, 0, $dataLength % 4);
+        $masks = str_repeat($masks, (int)floor($dataLength / 4)) . substr($masks, 0, $dataLength % 4);
         $decoded = $data ^ $masks;
         if ($connection->context->websocketCurrentFrameLength) {
             $connection->context->websocketDataBuffer .= $decoded;

+ 1 - 1
src/Protocols/Ws.php

@@ -261,7 +261,7 @@ class Ws
 
         $frame = $connection->websocketType . $head . $maskKey;
         // append payload to frame:
-        $maskKey = str_repeat($maskKey, floor($length / 4)) . substr($maskKey, 0, $length % 4);
+        $maskKey = str_repeat($maskKey, (int)floor($length / 4)) . substr($maskKey, 0, $length % 4);
         $frame .= $payload ^ $maskKey;
         if ($connection->context->handshakeStep === 1) {
             // If buffer has already full then discard the current package.