public function testValidatePort() { $util = new PortUtil(); $this->assertFalse($util->validatePort(22)); $this->assertFalse($util->validatePort(70000)); $this->assertFalse($util->validatePort(-1)); $this->assertFalse($util->validatePort('banana')); $this->assertTrue($util->validatePort(3000)); $this->assertTrue($util->validatePort('3000')); }
/** * Automatically determine the best port for a new tunnel. * * @param int $default * * @return int */ protected function getPort($default = 30000) { $ports = []; foreach ($this->getTunnelInfo() as $tunnel) { $ports[] = $tunnel['localPort']; } return PortUtil::getPort($ports ? max($ports) + 1 : $default); }