protected function port_is_blocked($port) {
        $portnum = intval($port);
        // Intentionally block port 0 and below and check the int cast was valid.
        if (empty($port) || (string)$portnum !== (string)$port || $port < 0) {
            return true;
        }
        $allowedports = $this->get_whitelisted_ports();
        return !empty($allowedports) && !in_array($portnum, $allowedports);
    }