class Nghttpx:
- def __init__(self, env: Env, port: int, name: str):
+ def __init__(self, env: Env, port: int, https_port: int, name: str):
self.env = env
self._name = name
self._port = port
+ self._https_port = https_port
self._cmd = env.nghttpx
self._run_dir = os.path.join(env.gen_dir, name)
self._pid_file = os.path.join(self._run_dir, 'nghttpx.pid')
self._mkpath(self._run_dir)
self._write_config()
+ @property
+ def https_port(self):
+ return self._https_port
+
def exists(self):
- return os.path.exists(self._cmd)
+ return self._cmd and os.path.exists(self._cmd)
def clear_logs(self):
self._rmf(self._error_log)
curl = CurlClient(env=self.env, run_dir=self._tmp_dir)
try_until = datetime.now() + timeout
while datetime.now() < try_until:
- check_url = f'https://{self.env.domain1}:{self._port}/'
- r = curl.http_get(url=check_url, extra_args=[
- '--http3-only', '--connect-timeout', '1'
- ])
+ if self._https_port > 0:
+ check_url = f'https://{self.env.domain1}:{self._https_port}/'
+ r = curl.http_get(url=check_url, extra_args=[
+ '--trace', 'curl.trace', '--trace-time',
+ '--connect-timeout', '1'
+ ])
+ else:
+ check_url = f'https://{self.env.domain1}:{self._port}/'
+ r = curl.http_get(url=check_url, extra_args=[
+ '--trace', 'curl.trace', '--trace-time',
+ '--http3-only', '--connect-timeout', '1'
+ ])
if r.exit_code != 0:
return True
log.debug(f'waiting for nghttpx to stop responding: {r}')
curl = CurlClient(env=self.env, run_dir=self._tmp_dir)
try_until = datetime.now() + timeout
while datetime.now() < try_until:
- check_url = f'https://{self.env.domain1}:{self._port}/'
- r = curl.http_get(url=check_url, extra_args=[
- '--http3-only', '--trace', 'curl.trace', '--trace-time',
- '--connect-timeout', '1'
- ])
+ if self._https_port > 0:
+ check_url = f'https://{self.env.domain1}:{self._https_port}/'
+ r = curl.http_get(url=check_url, extra_args=[
+ '--trace', 'curl.trace', '--trace-time',
+ '--connect-timeout', '1'
+ ])
+ else:
+ check_url = f'https://{self.env.domain1}:{self._port}/'
+ r = curl.http_get(url=check_url, extra_args=[
+ '--http3-only', '--trace', 'curl.trace', '--trace-time',
+ '--connect-timeout', '1'
+ ])
if r.exit_code == 0:
return True
log.debug(f'waiting for nghttpx to become responsive: {r}')
class NghttpxQuic(Nghttpx):
def __init__(self, env: Env):
- super().__init__(env=env, name='nghttpx-quic', port=env.h3_port)
+ super().__init__(env=env, name='nghttpx-quic', port=env.h3_port,
+ https_port=env.nghttpx_https_port)
def start(self, wait_live=True):
self._mkpath(self._tmp_dir)
class NghttpxFwd(Nghttpx):
def __init__(self, env: Env):
- super().__init__(env=env, name='nghttpx-fwd', port=env.h2proxys_port)
+ super().__init__(env=env, name='nghttpx-fwd', port=env.h2proxys_port,
+ https_port=0)
def start(self, wait_live=True):
self._mkpath(self._tmp_dir)