From 39dc871fbee3e8b52effcf48f77eb90dc1a9fd4d Mon Sep 17 00:00:00 2001 From: Julian Paolo Dayag Date: Tue, 8 Oct 2024 18:03:49 +0800 Subject: [PATCH] Add protocol argument --- Dockerfile | 1 + README.md | 1 + app/backend/app.js | 4 ++++ app/backend/cloudflare-tunnel.js | 5 +++++ dev/Dockerfile | 1 + 5 files changed, 12 insertions(+) diff --git a/Dockerfile b/Dockerfile index 71f2bad..17803df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,7 @@ ENV WEBUI_PORT=${WEBUI_PORT:-14333} ENV METRICS_ENABLE=${METRICS_ENABLE:-"false"} ENV METRICS_PORT=${METRICS_PORT:-60123} +ENV PROTOCOL=auto EXPOSE ${WEBUI_PORT} EXPOSE ${METRICS_PORT} diff --git a/README.md b/README.md index ea81480..04a38d6 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ services: | Variable Name | Default value | Required or Optional | Description | |-----------------|---------------|---|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | WEBUI_PORT | 14333 | _Optional_ | The port on the host where the WebUI will be running. Useful when an existing process is running on port `14333` and want to assign cloudflared-web into a different available port. | +| PROTOCOL | auto | _Optional_ | Specifies the protocol used to establish a connection between cloudflared and the Cloudflare global network. Available values are `auto`, `http2`, and `quic`. | | METRICS_ENABLE | false | _Optional_ | Enable [tunnel metrics](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/monitor-tunnels/metrics/) server. | | METRICS_PORT | 60123 | _Optional_ | Specify port to run tunnel metrics on. `METRICS_ENABLE` must be set to `true`. | | BASIC_AUTH_PASS | | _Optional_ | Enable Basic Auth by specifying a password. If `BASIC_AUTH_USER` is not specified, the default value for username `admin` will be used. | diff --git a/app/backend/app.js b/app/backend/app.js index 4000561..890852e 100644 --- a/app/backend/app.js +++ b/app/backend/app.js @@ -188,6 +188,10 @@ function init(config, res) { additionalArgs.metrics = process.env.METRICS_PORT; } + if (['http2','quic'].indexOf(process.env.PROTOCOL)) { + additionalArgs.protocol = process.env.PROTOCOL; + } + if (fs.existsSync(cloudflaredconfigpath)) { additionalArgs.configPath = cloudflaredconfigpath; } diff --git a/app/backend/cloudflare-tunnel.js b/app/backend/cloudflare-tunnel.js index cdbb564..75a95b2 100644 --- a/app/backend/cloudflare-tunnel.js +++ b/app/backend/cloudflare-tunnel.js @@ -103,6 +103,11 @@ class CloudflaredTunnel { args.push(`0.0.0.0:${additionalArgs.metrics}`); } + if (!!additionalArgs.protocol) { + args.push("--protocol"); + args.push(additionalArgs.protocol); + } + args.push("run"); args.push("--token"); args.push(this.token); diff --git a/dev/Dockerfile b/dev/Dockerfile index 1e7e7cd..c496aa5 100644 --- a/dev/Dockerfile +++ b/dev/Dockerfile @@ -12,6 +12,7 @@ ENV WEBUI_PORT=${WEBUI_PORT:-14333} ENV METRICS_ENABLE=${METRICS_ENABLE:-"false"} ENV METRICS_PORT=${METRICS_PORT:-60123} +ENV PROTOCOL=auto EXPOSE ${WEBUI_PORT} EXPOSE ${METRICS_PORT}