mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-12 21:05:12 +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
|
* @throws InternetException
|
||||||
*/
|
*/
|
||||||
public static function getInternalIP() : string{
|
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{
|
try{
|
||||||
if(!@socket_connect($sock, "8.8.8.8", 65534)){
|
if(!@socket_connect($sock, "8.8.8.8", 65534)){
|
||||||
throw new InternetException("Failed to get internal IP: " . trim(socket_strerror(socket_last_error($sock))));
|
throw new InternetException("Failed to get internal IP: " . trim(socket_strerror(socket_last_error($sock))));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user