logger = new \PrefixedLogger($logger, "UPnP Port Forwarder"); } public function start() : void{ $this->logger->info("Attempting to portforward..."); try{ $this->serviceURL = UPnP::getServiceUrl(); UPnP::portForward($this->serviceURL, Internet::getInternalIP(), $this->port, $this->port); $this->logger->info("Forwarded $this->ip:$this->port to external port $this->port"); }catch(UPnPException | InternetException $e){ $this->logger->error("UPnP portforward failed: " . $e->getMessage()); } } public function setName(string $name) : void{ } public function tick() : void{ } public function shutdown() : void{ if($this->serviceURL === null){ return; } UPnP::removePortForward($this->serviceURL, $this->port); } }