mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-03 00:25:04 +00:00
Merge branch 'next-minor'
# Conflicts: # resources/vanilla # src/plugin/PluginBase.php # src/plugin/PluginDescription.php # src/pocketmine/Player.php # src/pocketmine/network/rcon/RCON.php # src/pocketmine/network/rcon/RCONInstance.php # src/pocketmine/scheduler/AsyncTask.php # src/pocketmine/tile/Spawnable.php # src/scheduler/AsyncPool.php # src/utils/Config.php # src/utils/Timezone.php # src/utils/UUID.php # src/utils/Utils.php # src/world/format/io/region/RegionLoader.php
This commit is contained in:
@ -72,7 +72,7 @@ class Internet{
|
||||
*
|
||||
* @param bool $force default false, force IP check even when cached
|
||||
*
|
||||
* @return string|bool
|
||||
* @return string|false
|
||||
*/
|
||||
public static function getIP(bool $force = false){
|
||||
if(!self::$online){
|
||||
@ -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))));
|
||||
@ -205,6 +208,9 @@ class Internet{
|
||||
}
|
||||
|
||||
$ch = curl_init($page);
|
||||
if($ch === false){
|
||||
throw new InternetException("Unable to create new cURL session");
|
||||
}
|
||||
|
||||
curl_setopt_array($ch, $extraOpts + [
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
@ -221,10 +227,10 @@ class Internet{
|
||||
]);
|
||||
try{
|
||||
$raw = curl_exec($ch);
|
||||
$error = curl_error($ch);
|
||||
if($error !== ""){
|
||||
throw new InternetException($error);
|
||||
if($raw === false){
|
||||
throw new InternetException(curl_error($ch));
|
||||
}
|
||||
if(!is_string($raw)) throw new AssumptionFailedError("curl_exec() should return string|false when CURLOPT_RETURNTRANSFER is set");
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
|
||||
$rawHeaders = substr($raw, 0, $headerSize);
|
||||
|
Reference in New Issue
Block a user