GenisysPro  for Minecraft PE/Windows 10 v1.1.x
Feature-rich server software for Minecraft PE and Windows 10 Edition
UPnP Class Reference

Static Public Member Functions

static PortForward ($port)
 
static RemovePortForward ($port)
 

Member Function Documentation

◆ PortForward()

static PortForward (   $port)
static
Parameters
$port
Returns
bool
36  {
37  if(Utils::$online === false){
38  return false;
39  }
40  if(Utils::getOS() != "win" or !class_exists("COM", false)){
41  return false;
42  }
43  $port = (int) $port;
44  $myLocalIP = gethostbyname(trim(`hostname`));
45  try{
46  $com = new \COM("HNetCfg.NATUPnP");
47  if($com === false or !is_object($com->StaticPortMappingCollection)){
48  return false;
49  }
50  $com->StaticPortMappingCollection->Add($port, "UDP", $port, $myLocalIP, true, "PocketMine-MP");
51  }catch(\Throwable $e){
52  return false;
53  }
54 
55  return true;
56  }

◆ RemovePortForward()

static RemovePortForward (   $port)
static
Parameters
$port
Returns
bool
63  {
64  if(Utils::$online === false){
65  return false;
66  }
67  if(Utils::getOS() != "win" or !class_exists("COM")){
68  return false;
69  }
70  $port = (int) $port;
71  try{
72  $com = new \COM("HNetCfg.NATUPnP") or false;
73  if($com === false or !is_object($com->StaticPortMappingCollection)){
74  return false;
75  }
76  $com->StaticPortMappingCollection->Remove($port, "UDP");
77  }catch(\Throwable $e){
78  return false;
79  }
80 
81  return true;
82  }

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