mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Internet: account for socket_create() maybe failing in getInternalIP()
This commit is contained in:
parent
51908ec45a
commit
53dbbd5f97
@ -116,7 +116,10 @@ class Internet{
|
||||
* @throws InternetException
|
||||
*/
|
||||
public static function getInternalIP() : string{
|
||||
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
|
||||
$sock = @socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
|
||||
if($sock === false){
|
||||
throw new InternetException("Failed to get internal IP: " . trim(socket_strerror(socket_last_error())));
|
||||
}
|
||||
try{
|
||||
if(!@socket_connect($sock, "8.8.8.8", 65534)){
|
||||
throw new InternetException("Failed to get internal IP: " . trim(socket_strerror(socket_last_error($sock))));
|
||||
|
Loading…
x
Reference in New Issue
Block a user