|
@@ -15,6 +15,7 @@
|
|
|
namespace Workerman\Connection;
|
|
namespace Workerman\Connection;
|
|
|
|
|
|
|
|
use JetBrains\PhpStorm\ArrayShape;
|
|
use JetBrains\PhpStorm\ArrayShape;
|
|
|
|
|
+use JetBrains\PhpStorm\Pure;
|
|
|
use JsonSerializable;
|
|
use JsonSerializable;
|
|
|
use Workerman\Protocols\ProtocolInterface;
|
|
use Workerman\Protocols\ProtocolInterface;
|
|
|
use function stream_socket_get_name;
|
|
use function stream_socket_get_name;
|
|
@@ -176,6 +177,34 @@ class UdpConnection extends ConnectionInterface implements JsonSerializable
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * Is ipv4.
|
|
|
|
|
+ *
|
|
|
|
|
+ * return bool.
|
|
|
|
|
+ */
|
|
|
|
|
+ #[Pure]
|
|
|
|
|
+ public function isIpV4(): bool
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->transport === 'unix') {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ return !str_contains($this->getRemoteIp(), ':');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Is ipv6.
|
|
|
|
|
+ *
|
|
|
|
|
+ * return bool.
|
|
|
|
|
+ */
|
|
|
|
|
+ #[Pure]
|
|
|
|
|
+ public function isIpV6(): bool
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->transport === 'unix') {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ return str_contains($this->getRemoteIp(), ':');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* Get the real socket.
|
|
* Get the real socket.
|
|
|
*
|
|
*
|
|
|
* @return resource
|
|
* @return resource
|