dsh-proxy-enhance 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +111 -2
- package/cidr.js +195 -0
- package/client.js +407 -0
- package/cordis.patch.yml +4 -0
- package/env.js +246 -0
- package/icon.svg +8 -0
- package/index.js +322 -0
- package/locale/en.json +37 -0
- package/locale/zh.json +37 -0
- package/package.json +86 -3
- package/route.js +161 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-proxy-enhance contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,112 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-proxy-enhance
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
在 DeepSeek Harness 的「设置」里增加一个**代理**分区:配置引擎对外请求的 HTTP 代理与 `no_proxy` 白名单,并支持官方库读不懂的 **CIDR 网段**。
|
|
4
|
+
|
|
5
|
+
官方 `@deepseek-ai/dsh-http-proxy` 在启动时从环境解析一份策略,没有界面;它的匹配器只按主机名后缀比对,文档原文写着 CIDR "is not matched",所以 `10.0.0.0/8` 写进 `no_proxy` 是无效的。本包补上这个界面,以及那些网段。
|
|
6
|
+
|
|
7
|
+
[English](#english)
|
|
8
|
+
|
|
9
|
+
## 安装
|
|
10
|
+
|
|
11
|
+
前置:DSH `^0.2.3-alpha.3`、Node `>= 22.5`。
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
dsh plugin --profile web add dsh-proxy-enhance
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
装完重启 `dsh` 并刷新页面,设置里会出现「代理」。
|
|
18
|
+
|
|
19
|
+
## 它做什么
|
|
20
|
+
|
|
21
|
+
- 在「设置 → 代理」里配置 `http_proxy`、`https_proxy`、`all_proxy`、`no_proxy`。
|
|
22
|
+
- 写进 `$DSH_HOME/.env`(大小写两套)以便重启后仍然有效,同时对当前进程立即生效,不必重启。
|
|
23
|
+
- 作用于引擎自身的出站请求:模型调用、联网搜索、HTTP MCP。终端不受影响,`curl`、`git` 仍用它们继承到的环境。
|
|
24
|
+
|
|
25
|
+
## 与官方包的关系
|
|
26
|
+
|
|
27
|
+
不重写代理逻辑。解析、校验、`ALL_PROXY` 如何兜底两个 scheme、HTTPS 如何回退到 HTTP 代理、SOCKS 如何被拒绝、回环如何强制直连,全部来自 `installProxyFromEnvironment`。本包只替换一个判断——某个 URL 是否绕过代理——在后缀匹配旁边加上 CIDR 判断。
|
|
28
|
+
|
|
29
|
+
CIDR 只能把「走代理」变成「直连」,不会反向,所以两套规则不可能互相矛盾。
|
|
30
|
+
|
|
31
|
+
## `no_proxy` 写法
|
|
32
|
+
|
|
33
|
+
逗号或空格分隔。
|
|
34
|
+
|
|
35
|
+
| 条目 | 含义 |
|
|
36
|
+
|---|---|
|
|
37
|
+
| `example.com`、`.example.com`、`*.example.com` | 该主机及其所有子域 |
|
|
38
|
+
| `10.0.0.0/8`、`192.168.0.0/16`、`fc00::/7` | 网段 |
|
|
39
|
+
| `10.0.0.0/8:8080` | 限定端口的网段 |
|
|
40
|
+
| `*` | 全部直连 |
|
|
41
|
+
|
|
42
|
+
回环地址始终直连,无需填写。IPv4、IPv6、`::ffff:` 映射写法与端口限定都支持。
|
|
43
|
+
|
|
44
|
+
## 表单只管理你改过的字段
|
|
45
|
+
|
|
46
|
+
你在 shell 里导出的代理、或手写进 `.env` 的代理继续有效。页面会把它显示出来,并标注「尚未由表单接管」。只有你在页面上改过某个字段之后,它才归表单管,此后每次保存都会写入。
|
|
47
|
+
|
|
48
|
+
编辑一个字段不会动别的字段:改 `no_proxy` 不会顺手删掉手写的 `http_proxy`。关掉开关会移除代理地址,但保留白名单。
|
|
49
|
+
|
|
50
|
+
## 凭据
|
|
51
|
+
|
|
52
|
+
代理地址可以带用户名和密码,写成 `http://` + 用户名 + `:` + 密码 + `@` + 代理主机。页面会原样存下,并写进 `~/.dsh/.env`——引擎启动时只从环境变量读代理,重启后还要能认证,密码就必须在那儿。这是明文。
|
|
53
|
+
|
|
54
|
+
profile 的配置文件里只存去掉密码的地址,那份文件可以安全地分享。
|
|
55
|
+
|
|
56
|
+
本插件不改动 `.env` 的权限。这个文件是你的,权限由你决定;只有它**新建** `.env` 时才会用 `600`。如果你希望这个文件仅自己可读:
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
chmod 600 ~/.dsh/.env
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## 限制
|
|
63
|
+
|
|
64
|
+
- **CIDR 只在本插件的实时策略里生效。** `curl`、`git` 等直接读 `no_proxy` 的程序会把网段条目当作无效文本。要让这些工具也走同样的绕过规则,请用代理软件自己的局域网规则。
|
|
65
|
+
- **只覆盖引擎流量。** 派生的 shell 或子 agent CLI 继承的是环境变量,不是这个页面。
|
|
66
|
+
- **不支持 SOCKS / PAC。** 官方匹配器拒绝它们,所以非 `http(s)` 地址在保存时会被拒绝,而不是被当成「不设代理」。
|
|
67
|
+
- **不管理自定义 CA。** 做 TLS 拦截的代理仍需在启动前设置 `NODE_EXTRA_CA_CERTS`。
|
|
68
|
+
- **策略本身活不过重启。** `.env` 必须写——那是下次启动唯一会读的地方。
|
|
69
|
+
- **没有标题栏或原生外壳界面。** 它就是一个设置分区。
|
|
70
|
+
|
|
71
|
+
## 开发
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
pnpm install
|
|
75
|
+
pnpm test
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
测试锁定四类契约:`.env` 编码必须与 `node:util` 的 `parseEnv` 逐字节互逆(含恶意输入)、字段级接管、CIDR 匹配(IPv4/IPv6/映射/端口)、以及 Host 写入路径(符号链接、权限位、如实上报)。Host 部分用真实临时目录驱动 `apply()`,断言落在磁盘上。
|
|
79
|
+
|
|
80
|
+
发布:推一个 `v*` 标签,GitHub Actions 会跑测试、校验标签与 `package.json` 版本一致、检查打包内容后发到 npm。也可以在 Actions 里手动触发,默认 dry run。
|
|
81
|
+
|
|
82
|
+
## 许可
|
|
83
|
+
|
|
84
|
+
MIT
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## English
|
|
89
|
+
|
|
90
|
+
Adds a **proxy** section to DeepSeek Harness settings: point the engine's outbound requests at an HTTP proxy, and list what bypasses it — including the **CIDR ranges** the launcher-side matcher cannot read. The shipped `@deepseek-ai/dsh-http-proxy` resolves one policy at launch from the environment and has no UI; its bypass matcher compares hostname suffixes only, and its own documentation says CIDR "is not matched", so `10.0.0.0/8` in `no_proxy` does nothing.
|
|
91
|
+
|
|
92
|
+
**Install.** Prerequisite: dsh `^0.2.3-alpha.3`, Node `>= 22.5`.
|
|
93
|
+
|
|
94
|
+
```sh
|
|
95
|
+
dsh plugin --profile web add dsh-proxy-enhance
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Then restart `dsh` and refresh; the section appears as **Proxy**.
|
|
99
|
+
|
|
100
|
+
**What it does.** Configure `http_proxy`, `https_proxy`, `all_proxy`, and `no_proxy` from Settings → Proxy. They are written to `$DSH_HOME/.env` (both letter cases) so the value survives a restart, and applied to the running process immediately. This covers engine traffic — model requests, web search, HTTP MCP — not a terminal.
|
|
101
|
+
|
|
102
|
+
**How it relates to the shipped package.** No proxy logic is reimplemented. Resolution, validation, how `ALL_PROXY` covers both schemes, how HTTPS falls back to the HTTP proxy, SOCKS rejection, and the loopback bypass all come from `installProxyFromEnvironment`. This bundle replaces exactly one decision — whether a URL bypasses the proxy — adding a CIDR test beside the suffix test. A CIDR hit can only turn "proxied" into "direct", never the reverse, so the two rule sets cannot contradict each other.
|
|
103
|
+
|
|
104
|
+
**`no_proxy` syntax.** Separated by commas or spaces: `example.com` / `.example.com` / `*.example.com` cover a host and every subdomain; `10.0.0.0/8`, `192.168.0.0/16`, `fc00::/7` are ranges; `10.0.0.0/8:8080` a port-qualified range; `*` bypasses everything. Loopback is always direct. IPv4, IPv6, `::ffff:` mapped addresses, and port qualifiers are supported.
|
|
105
|
+
|
|
106
|
+
**Ownership.** A proxy you export, or wrote into `.env` by hand, keeps working; the page shows it and marks it as not managed by the form. A field becomes the form's only once you change it there. Editing one field never touches another.
|
|
107
|
+
|
|
108
|
+
**Credentials.** A proxy URL may carry a username and a password. The page stores it as typed and writes it to `~/.dsh/.env` — the launcher reads a proxy from the environment at start, so a restart needs the credential there. That file holds it in plaintext. The profile's configuration file keeps only the credentials-stripped URL, so that one stays safe to share. This plugin does not change `.env` permissions: the file is yours. Only a `.env` it creates is written as `600`. To make an existing one owner-only, run `chmod 600 ~/.dsh/.env`.
|
|
109
|
+
|
|
110
|
+
**Limitations.** CIDR works only inside this plugin's live policy — `curl`, `git`, and anything else reading `no_proxy` directly see a range entry as unparseable text. Engine traffic only; a spawned shell or subagent CLI inherits the environment, not this page. No SOCKS or PAC: a non-`http(s)` address is rejected on save rather than silently treated as "no proxy". No CA management: a TLS-intercepting proxy still needs `NODE_EXTRA_CA_CERTS` before launch. A policy cannot outlive a restart on its own, which is why `.env` is written. It is a settings section and nothing more.
|
|
111
|
+
|
|
112
|
+
**Development.** `pnpm install && pnpm test`. The suite pins four contracts: `.env` encoding round-trips through `node:util`'s `parseEnv` byte for byte (hostile input included), ownership stays field-scoped, CIDR matching holds for IPv4/IPv6/mapped/port forms, and the Host write path respects symlinks, modes, and honest failure reporting. Releasing: push a `v*` tag; the workflow runs tests, checks the tag against `package.json`, inspects the tarball, and publishes. It can also be started manually, defaulting to a dry run.
|
package/cidr.js
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// CIDR support for the no_proxy bypass list.
|
|
2
|
+
//
|
|
3
|
+
// The launcher-side matcher in @deepseek-ai/dsh-http-proxy compares hostnames as
|
|
4
|
+
// suffixes only — its own README says CIDR "is not matched", so `10.0.0.0/8`
|
|
5
|
+
// and `192.168.0.0/16` are silently inert there. An operating system's bypass
|
|
6
|
+
// list routinely carries exactly those entries, which makes copying one into
|
|
7
|
+
// `no_proxy` look like it worked while every private address is still proxied.
|
|
8
|
+
//
|
|
9
|
+
// This module answers the one question the official matcher cannot: does this
|
|
10
|
+
// host fall inside one of the configured ranges? It is pure and transport-free,
|
|
11
|
+
// so it is testable without a network.
|
|
12
|
+
//
|
|
13
|
+
// IPv6 is kept as an eight-group array rather than packed into numbers: 128 bits
|
|
14
|
+
// do not fit a double, and an earlier bit-shifting version silently matched the
|
|
15
|
+
// wrong addresses because JavaScript masks are 32-bit wide.
|
|
16
|
+
|
|
17
|
+
/** An IPv4 range carries a 32-bit `value`; an IPv6 range carries eight 16-bit `groups`. */
|
|
18
|
+
export function parseCidr(entry) {
|
|
19
|
+
const text = String(entry ?? '').trim()
|
|
20
|
+
if (text === '') return undefined
|
|
21
|
+
const slash = text.indexOf('/')
|
|
22
|
+
if (slash === -1) return undefined
|
|
23
|
+
|
|
24
|
+
// A trailing `:port` qualifies the range the way the official matcher's own
|
|
25
|
+
// `host:port` entries do. It must be recognised rather than dropped: silently
|
|
26
|
+
// ignoring the whole entry would leave the user believing it applied.
|
|
27
|
+
const prefixStart = slash + 1
|
|
28
|
+
const portAt = text.indexOf(':', prefixStart)
|
|
29
|
+
const prefixText = portAt === -1 ? text.slice(prefixStart) : text.slice(prefixStart, portAt)
|
|
30
|
+
let port
|
|
31
|
+
if (portAt !== -1) {
|
|
32
|
+
const portText = text.slice(portAt + 1)
|
|
33
|
+
if (!/^\d{1,5}$/.test(portText)) return undefined
|
|
34
|
+
port = Number.parseInt(portText, 10)
|
|
35
|
+
if (port < 1 || port > 65535) return undefined
|
|
36
|
+
}
|
|
37
|
+
if (!/^\d{1,3}$/.test(prefixText)) return undefined
|
|
38
|
+
const bits = Number.parseInt(prefixText, 10)
|
|
39
|
+
|
|
40
|
+
const base = text.slice(0, slash)
|
|
41
|
+
if (base.includes(':')) {
|
|
42
|
+
if (bits > 128) return undefined
|
|
43
|
+
const groups = parseIpv6(base)
|
|
44
|
+
return groups === undefined ? undefined : { family: 6, groups, bits, port }
|
|
45
|
+
}
|
|
46
|
+
if (bits > 32) return undefined
|
|
47
|
+
const value = parseIpv4(base)
|
|
48
|
+
return value === undefined ? undefined : { family: 4, value, bits, port }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Parse a dotted-quad IPv4 address into its 32-bit number. */
|
|
52
|
+
export function parseIpv4(text) {
|
|
53
|
+
const parts = String(text ?? '').split('.')
|
|
54
|
+
if (parts.length !== 4) return undefined
|
|
55
|
+
let value = 0
|
|
56
|
+
for (const part of parts) {
|
|
57
|
+
if (!/^\d{1,3}$/.test(part)) return undefined
|
|
58
|
+
const octet = Number.parseInt(part, 10)
|
|
59
|
+
if (octet > 255) return undefined
|
|
60
|
+
value = value * 256 + octet
|
|
61
|
+
}
|
|
62
|
+
return value
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Parse an IPv6 address into its eight 16-bit groups.
|
|
67
|
+
*
|
|
68
|
+
* Handles `::` compression and a trailing dotted-quad (`::ffff:127.0.0.1`).
|
|
69
|
+
* A zone suffix is rejected rather than guessed at: it names an interface on
|
|
70
|
+
* this machine and never appears in a bypass decision.
|
|
71
|
+
*
|
|
72
|
+
* @param text - the address, bracketed or not.
|
|
73
|
+
* @returns the eight groups, or undefined when the text is not IPv6.
|
|
74
|
+
*/
|
|
75
|
+
export function parseIpv6(text) {
|
|
76
|
+
let source = String(text ?? '').trim()
|
|
77
|
+
if (source.indexOf('%') !== -1) return undefined
|
|
78
|
+
if (source.startsWith('[') && source.endsWith(']')) source = source.slice(1, -1)
|
|
79
|
+
if (!source.includes(':')) return undefined
|
|
80
|
+
if (source.split('::').length > 2) return undefined
|
|
81
|
+
|
|
82
|
+
// A trailing dotted-quad is two hexadecimal groups written in decimal.
|
|
83
|
+
const tailGroups = []
|
|
84
|
+
let body = source
|
|
85
|
+
const lastColon = source.lastIndexOf(':')
|
|
86
|
+
const tail = source.slice(lastColon + 1)
|
|
87
|
+
if (tail.includes('.')) {
|
|
88
|
+
const v4 = parseIpv4(tail)
|
|
89
|
+
if (v4 === undefined) return undefined
|
|
90
|
+
tailGroups.push((v4 >>> 16) & 0xffff, v4 & 0xffff)
|
|
91
|
+
body = source.slice(0, lastColon)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const [headText, restText] = body.includes('::') ? body.split('::') : [body, undefined]
|
|
95
|
+
const toGroups = (part) => {
|
|
96
|
+
if (part === undefined || part === '') return []
|
|
97
|
+
const out = []
|
|
98
|
+
for (const group of part.split(':')) {
|
|
99
|
+
if (!/^[0-9a-fA-F]{1,4}$/.test(group)) return undefined
|
|
100
|
+
out.push(Number.parseInt(group, 16))
|
|
101
|
+
}
|
|
102
|
+
return out
|
|
103
|
+
}
|
|
104
|
+
const head = toGroups(headText)
|
|
105
|
+
const rest = toGroups(restText)
|
|
106
|
+
if (head === undefined || rest === undefined) return undefined
|
|
107
|
+
|
|
108
|
+
if (restText === undefined) {
|
|
109
|
+
const all = [...head, ...tailGroups]
|
|
110
|
+
return all.length === 8 ? all : undefined
|
|
111
|
+
}
|
|
112
|
+
// `::` absorbs the zero groups needed to reach eight; it must cover at least one.
|
|
113
|
+
const fill = 8 - head.length - rest.length - tailGroups.length
|
|
114
|
+
if (fill < 1) return undefined
|
|
115
|
+
return [...head, ...new Array(fill).fill(0), ...rest, ...tailGroups]
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Whether a host falls inside a parsed range.
|
|
120
|
+
*
|
|
121
|
+
* An IPv4-mapped address (`::ffff:a.b.c.d`, which `URL` produces for a bracketed
|
|
122
|
+
* literal) is unwrapped first, so an IPv4 range also covers its mapped spelling.
|
|
123
|
+
*
|
|
124
|
+
* @param range - a value from {@link parseCidr}.
|
|
125
|
+
* @param host - a URL hostname, bracketed or not.
|
|
126
|
+
* @returns true when the host is inside the range.
|
|
127
|
+
*/
|
|
128
|
+
export function cidrContains(range, host, port) {
|
|
129
|
+
const text = String(host ?? '').replace(/^\[|\]$/g, '')
|
|
130
|
+
if (text === '' || range === undefined) return false
|
|
131
|
+
// A range may name one port; the caller passes the URL's effective port.
|
|
132
|
+
if (range.port !== undefined && String(range.port) !== String(port)) return false
|
|
133
|
+
|
|
134
|
+
if (!text.includes(':')) {
|
|
135
|
+
if (range.family !== 4) return false
|
|
136
|
+
const value = parseIpv4(text)
|
|
137
|
+
return value === undefined ? false : matchesIpv4(range, value)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const groups = parseIpv6(text)
|
|
141
|
+
if (groups === undefined) return false
|
|
142
|
+
// `::ffff:a.b.c.d` — six zero groups, then `ffff`, then the IPv4 pair.
|
|
143
|
+
const mapped = range.family === 4
|
|
144
|
+
&& groups.slice(0, 5).every((group) => group === 0)
|
|
145
|
+
&& groups[5] === 0xffff
|
|
146
|
+
if (mapped) return matchesIpv4(range, groups[6] * 0x10000 + groups[7])
|
|
147
|
+
if (range.family !== 6) return false
|
|
148
|
+
return matchesGroups(range, groups)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Compare a 32-bit address against an IPv4 range. */
|
|
152
|
+
function matchesIpv4(range, candidate) {
|
|
153
|
+
if (range.bits === 0) return true
|
|
154
|
+
if (range.bits === 32) return candidate === range.value
|
|
155
|
+
// Build the mask as an unsigned 32-bit value; a shift by 32 is a no-op in JS,
|
|
156
|
+
// which is why /32 is answered above instead of falling through here.
|
|
157
|
+
const mask = (0xffffffff << (32 - range.bits)) >>> 0
|
|
158
|
+
return ((candidate & mask) >>> 0) === ((range.value & mask) >>> 0)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Compare eight 16-bit groups against an IPv6 range, prefix bit by prefix bit. */
|
|
162
|
+
function matchesGroups(range, candidate) {
|
|
163
|
+
let remaining = range.bits
|
|
164
|
+
for (let i = 0; i < 8 && remaining > 0; i += 1) {
|
|
165
|
+
if (remaining >= 16) {
|
|
166
|
+
if (candidate[i] !== range.groups[i]) return false
|
|
167
|
+
remaining -= 16
|
|
168
|
+
continue
|
|
169
|
+
}
|
|
170
|
+
// A partial group: compare only its high bits, keeping the mask 16-bit wide.
|
|
171
|
+
const mask = (0xffff << (16 - remaining)) & 0xffff
|
|
172
|
+
if ((candidate[i] & mask) !== (range.groups[i] & mask)) return false
|
|
173
|
+
remaining = 0
|
|
174
|
+
}
|
|
175
|
+
return true
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Whether a host is inside any CIDR entry of a bypass list.
|
|
180
|
+
*
|
|
181
|
+
* Non-CIDR entries are ignored here: the official matcher already owns suffix
|
|
182
|
+
* and `*` handling, and duplicating it would risk the two disagreeing.
|
|
183
|
+
*
|
|
184
|
+
* @param noProxy - the raw bypass list.
|
|
185
|
+
* @param host - a URL hostname.
|
|
186
|
+
* @returns true when the host must bypass the proxy.
|
|
187
|
+
*/
|
|
188
|
+
export function bypassesByCidr(noProxy, host, port) {
|
|
189
|
+
for (const raw of String(noProxy ?? '').split(/[,\s]+/)) {
|
|
190
|
+
const range = parseCidr(raw)
|
|
191
|
+
if (range === undefined) continue
|
|
192
|
+
if (cidrContains(range, host, port)) return true
|
|
193
|
+
}
|
|
194
|
+
return false
|
|
195
|
+
}
|