From 8675f84a95fd4f527ca22382cdbd05e69dd26171 Mon Sep 17 00:00:00 2001 From: Carsten Igel Date: Mon, 29 Jul 2024 19:39:26 +0200 Subject: [PATCH 1/3] fix: Proxy Agent usage The proxy variable will be used correctly. The HTTPS_PROXY / HTTP_PROXY will be used, if PROTOLINT_PROXY is not set. Evaluation takes place: if the remote url starts with https, HTTPS_PROXY will be used, otherwise HTTP_PROXY will be used. This interpretation is questionable, but makes sense in the first place. Closes #426 --- bdist/js/ReadMe.md | 2 +- bdist/js/install.mjs | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bdist/js/ReadMe.md b/bdist/js/ReadMe.md index c59cd460..4191e002 100644 --- a/bdist/js/ReadMe.md +++ b/bdist/js/ReadMe.md @@ -4,7 +4,7 @@ Protolint is a go based linter for `.proto` files for google protobuf und gRPC. The npm package provides a wrapper around the executables `protolint` and `protoc-gen-protolint`. During installation process, it will download the binaries matching the version and your operating system and CPU architecture from github. -If your behind a proxy, you can add the `PROTOLINT_PROXY` environment variable including the HTTP basic authentication information like username and password. +If your behind a proxy, you can add the `PROTOLINT_PROXY` environment variable including the HTTP basic authentication information like username and password. **NOTE** that this will take precedence of the system `HTTP_PROXY`/`HTTPS_PROXY` environment variables. If these variables should be used, do not use `PROTOLINT_PROXY`. If your running an airgapped environment, you can add the following environment variables: diff --git a/bdist/js/install.mjs b/bdist/js/install.mjs index de876d23..5cf3cb32 100644 --- a/bdist/js/install.mjs +++ b/bdist/js/install.mjs @@ -27,8 +27,15 @@ const arch = _arch_mapping[_arch] ?? _arch; const url = `${protolint_host}/${protolint_path}/v${protolint_version}/${module_name}_${protolint_version}_${platform}_${arch}.tar.gz`; let agent; -if (process.env.PROTOLINT_PROXY) { - agent = HttpProxyAgent(process.env.PROTOLINT_PROXY); + +let proxy_address = process.env.PROTOLINT_PROXY; +if (!proxy_address) +{ + proxy_address = protolint_host.startsWith("https") ? process.env.HTTPS_PROXY : process.env.HTTP_PROXY; +} + +if (proxy_address) { + agent = new HttpProxyAgent(proxy_address); } const agent_config = { From 1769deab3e31a209ee5111a02a34f9746c99fbd1 Mon Sep 17 00:00:00 2001 From: Carsten Igel <1760987+carstencodes@users.noreply.github.com> Date: Tue, 30 Jul 2024 18:17:47 +0200 Subject: [PATCH 2/3] feat: Add PROTOLINT_NO_PROXY Maybe useful in airgapped scenarios --- bdist/js/install.mjs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bdist/js/install.mjs b/bdist/js/install.mjs index 5cf3cb32..f699ee3d 100644 --- a/bdist/js/install.mjs +++ b/bdist/js/install.mjs @@ -28,10 +28,14 @@ const url = `${protolint_host}/${protolint_path}/v${protolint_version}/${module_ let agent; -let proxy_address = process.env.PROTOLINT_PROXY; -if (!proxy_address) -{ - proxy_address = protolint_host.startsWith("https") ? process.env.HTTPS_PROXY : process.env.HTTP_PROXY; +let proxy_address; + +if (!process.env.PROTOLINT_NO_PROXY) { + proxy_address = process.env.PROTOLINT_PROXY; + if (!proxy_address) + { + proxy_address = protolint_host.startsWith("https") ? process.env.HTTPS_PROXY : process.env.HTTP_PROXY; + } } if (proxy_address) { @@ -182,4 +186,4 @@ fetch(url).then( npmlog.error(script_name, "Failed to install protolint: %s", reason); process.exit(1); } -); \ No newline at end of file +); From b36be290763915d1099767e7ade7f294bf585213 Mon Sep 17 00:00:00 2001 From: Carsten Igel <1760987+carstencodes@users.noreply.github.com> Date: Tue, 30 Jul 2024 18:19:22 +0200 Subject: [PATCH 3/3] docs: document PROTOLINT_NO_PROXY Useful for airgapped scenarios --- bdist/js/ReadMe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bdist/js/ReadMe.md b/bdist/js/ReadMe.md index 4191e002..608fe1bb 100644 --- a/bdist/js/ReadMe.md +++ b/bdist/js/ReadMe.md @@ -4,7 +4,7 @@ Protolint is a go based linter for `.proto` files for google protobuf und gRPC. The npm package provides a wrapper around the executables `protolint` and `protoc-gen-protolint`. During installation process, it will download the binaries matching the version and your operating system and CPU architecture from github. -If your behind a proxy, you can add the `PROTOLINT_PROXY` environment variable including the HTTP basic authentication information like username and password. **NOTE** that this will take precedence of the system `HTTP_PROXY`/`HTTPS_PROXY` environment variables. If these variables should be used, do not use `PROTOLINT_PROXY`. +If your behind a proxy, you can add the `PROTOLINT_PROXY` environment variable including the HTTP basic authentication information like username and password. **NOTE** that this will take precedence of the system `HTTP_PROXY`/`HTTPS_PROXY` environment variables. If these variables should be used, do not use `PROTOLINT_PROXY`. If a proxy server is set that should not be used, set `PROTOLINT_NO_PROXY` to non-zero value. If your running an airgapped environment, you can add the following environment variables: