PocketMine-MP 5.15.1 git-5ef247620a7c6301a849b54e5ef1009217729fc8
pocketmine\utils\Internet Class Reference
+ Collaboration diagram for pocketmine\utils\Internet:

Static Public Member Functions

static getInternalIP ()
 
static getIP (bool $force=false)
 
static getURL (string $page, int $timeout=10, array $extraHeaders=[], &$err=null)
 
static postURL (string $page, array|string $args, int $timeout=10, array $extraHeaders=[], &$err=null)
 
static simpleCurl (string $page, float $timeout=10, array $extraHeaders=[], array $extraOpts=[], ?\Closure $onSuccess=null)
 

Static Public Attributes

static string false $ip = false
 
static bool $online = true
 

Detailed Description

Definition at line 66 of file Internet.php.

Member Function Documentation

◆ getInternalIP()

static pocketmine\utils\Internet::getInternalIP ( )
static

Returns the machine's internal network IP address. If the machine is not behind a router, this may be the same as the external IP.

Exceptions
InternetException

Definition at line 116 of file Internet.php.

Referenced by pocketmine\network\upnp\UPnPNetworkInterface\start().

+ Here is the caller graph for this function:

◆ getIP()

static pocketmine\utils\Internet::getIP ( bool  $force = false)
static

Lazily gets the External IP using an external service and caches the result

Parameters
bool$forcedefault false, force IP check even when cached

Definition at line 75 of file Internet.php.

◆ getURL()

static pocketmine\utils\Internet::getURL ( string  $page,
int  $timeout = 10,
array  $extraHeaders = [],
$err = null 
)
static

GETs an URL using cURL NOTE: This is a blocking operation and can take a significant amount of time. It is inadvisable to use this method on the main thread.

@phpstan-template TErrorVar of mixed

Parameters
int$timeoutdefault 10
string[]$extraHeaders
string | null$errreference parameter, will be set to the output of curl_error(). Use this to retrieve errors that occured during the operation. @phpstan-param list<string> $extraHeaders @phpstan-param TErrorVar $err @phpstan-param-out TErrorVar|string $err

Definition at line 147 of file Internet.php.

◆ postURL()

static pocketmine\utils\Internet::postURL ( string  $page,
array|string  $args,
int  $timeout = 10,
array  $extraHeaders = [],
$err = null 
)
static

POSTs data to an URL NOTE: This is a blocking operation and can take a significant amount of time. It is inadvisable to use this method on the main thread.

@phpstan-template TErrorVar of mixed

Parameters
string[] | string$args
string[]$extraHeaders
string | null$errreference parameter, will be set to the output of curl_error(). Use this to retrieve errors that occurred during the operation. @phpstan-param string|array<string, string> $args @phpstan-param list<string> $extraHeaders @phpstan-param TErrorVar $err @phpstan-param-out TErrorVar|string $err

Definition at line 170 of file Internet.php.

◆ simpleCurl()

static pocketmine\utils\Internet::simpleCurl ( string  $page,
float  $timeout = 10,
array  $extraHeaders = [],
array  $extraOpts = [],
?\Closure  $onSuccess = null 
)
static

General cURL shorthand function. NOTE: This is a blocking operation and can take a significant amount of time. It is inadvisable to use this method on the main thread.

Parameters
float$timeoutThe maximum connect timeout and timeout in seconds, correct to ms.
string[]$extraHeadersextra headers to send as a plain string array
array$extraOptsextra CURLOPT_* to set as an [opt => value] map
\Closure | null$onSuccessfunction to be called if there is no error. Accepts a resource argument as the cURL handle. @phpstan-param array<int, mixed> $extraOpts @phpstan-param list<string> $extraHeaders @phpstan-param (\Closure(\CurlHandle) : void)|null $onSuccess
Exceptions
InternetExceptionif a cURL error occurs

Definition at line 196 of file Internet.php.

Referenced by pocketmine\scheduler\BulkCurlTask\onRun().

+ Here is the caller graph for this function:

Member Data Documentation

◆ $ip

string false pocketmine\utils\Internet::$ip = false
static

Definition at line 67 of file Internet.php.

◆ $online

bool pocketmine\utils\Internet::$online = true
static

Definition at line 68 of file Internet.php.


The documentation for this class was generated from the following file: