easy-claude 1.3.1 → 1.3.3
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/CHANGELOG.md +10 -0
- package/README.md +6 -6
- package/README.zh-CN.md +6 -6
- package/native/Overlay.swift +29 -8
- package/native/build/EasyClaudeOverlay.app/Contents/Info.plist +1 -1
- package/native/build/EasyClaudeOverlay.app/Contents/MacOS/EasyClaudeOverlay +0 -0
- package/package.json +1 -1
- package/src/ip-guard/guard.js +20 -6
- package/src/ip-guard/service.js +9 -7
- package/src/public-ip.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# 更新记录
|
|
2
2
|
|
|
3
|
+
## 1.3.3
|
|
4
|
+
|
|
5
|
+
- Expand exit IP protection probes to four rotating IPv4-only endpoints (`www.cloudflare.com/cdn-cgi/trace`, `ipv4.icanhazip.com`, `checkip.amazonaws.com`, `api.ipify.org`) with 4-second per-source timeout and independent 10-minute 429 cooldowns; any valid non-allowlisted IP still blocks immediately without failing over.
|
|
6
|
+
- Support shorter protection check intervals (`10s / 15s / 30s / 60s`, default `15s`) and reduce the minimum recheck cooldown from 60 seconds to 3 seconds.
|
|
7
|
+
- Filter initial and duplicate `NWPathMonitor` callbacks with 300ms debounce so startup or minor route jitter no longer revokes an active IP check; show a dedicated waiting-to-recheck state during cooldown.
|
|
8
|
+
|
|
9
|
+
## 1.3.2
|
|
10
|
+
|
|
11
|
+
- Increase public IP query timeouts to 10-second connect, 20-second total, and 30-second subprocess limit; keep ipinfo-to-ipify fallback, proxy routing, TLS/IP validation, and unknown fallback city/time zone.
|
|
12
|
+
|
|
3
13
|
## 1.3.1
|
|
4
14
|
|
|
5
15
|
- Shorten public IP connection/total timeouts to 3/5 seconds (7-second process limit), allowing faster ipinfo-to-ipify fallback. Preserve proxy routing, TLS/IP checks and unknown fallback city/time zone.
|
package/README.md
CHANGED
|
@@ -18,13 +18,13 @@ Below Local proxy, click green Start Claude proxy to back up and configure Deskt
|
|
|
18
18
|
|
|
19
19
|
[Setup, proxy configuration and removal](docs/exit-ip-protection.md) · [Development verification](docs/版本/出口IP保护开发管理.md)
|
|
20
20
|
|
|
21
|
-
## v1.3.
|
|
21
|
+
## v1.3.3 release notes
|
|
22
22
|
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
23
|
+
- Rotate exit IP protection checks across four IPv4 endpoints (`www.cloudflare.com/cdn-cgi/trace`, `ipv4.icanhazip.com`, `checkip.amazonaws.com`, `api.ipify.org`) with 4-second per-source timeouts and per-source 10-minute 429 cooldowns; any valid non-allowlisted IP still blocks immediately.
|
|
24
|
+
- Add shorter protection check intervals (`10s / 15s / 30s / 60s`, default `15s`) and lower the minimum recheck cooldown from 60 seconds to 3 seconds.
|
|
25
|
+
- Ignore initial/unchanged `NWPathMonitor` callbacks with 300ms debounce to avoid self-revoking checks at startup or on minor route jitter; keep `ipinfo.io` for 300-second geography/time-zone lookups.
|
|
26
26
|
|
|
27
|
-
[Release history](CHANGELOG.md) · [1.3.
|
|
27
|
+
[Release history](CHANGELOG.md) · [1.3.3 verification](docs/版本/1.3.3开发管理.md)
|
|
28
28
|
|
|
29
29
|
## Install and run
|
|
30
30
|
|
|
@@ -71,7 +71,7 @@ The CLI uses the same saved preference. `EASY_LANGUAGE=en` or `EASY_LANGUAGE=zh`
|
|
|
71
71
|
|
|
72
72
|
## Network exit and IP time zone
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
The primary `https://ipinfo.io/json` reads the public IP, city and IANA time zone. On failure, `https://api.ipify.org?format=json` provides IP only; fallback city/time zone remain unknown. Each source has a 3-second connection and 5-second total timeout. The panel displays `City·IP`, refreshing at startup, every five minutes or on demand. A failed lookup shows an explicit error rather than an old IP. IP history is not saved.
|
|
75
75
|
|
|
76
76
|
**Follow IP time zone** is off by default. Enable it to hide manual zone choices and use the validated IP time zone and returned city. Failed lookups temporarily restore the saved manual time; successful lookups resume following. Disable it to restore manual choices. Proxy routing can make this exit differ from AI traffic; geolocation may be inaccurate or rate-limited.
|
|
77
77
|
|
package/README.zh-CN.md
CHANGED
|
@@ -20,13 +20,13 @@ Claude App 与 Claude Code CLI 共用固定本机代理 **http://127.0.0.1:18197
|
|
|
20
20
|
|
|
21
21
|
[安装、代理配置、关闭与卸载](docs/出口IP保护.md) · [开发验证记录](docs/版本/出口IP保护开发管理.md)
|
|
22
22
|
|
|
23
|
-
## v1.3.
|
|
23
|
+
## v1.3.3 更新说明
|
|
24
24
|
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
25
|
+
- 出口 IP 保护改为 4 个纯 IPv4 源轮转探测(`www.cloudflare.com/cdn-cgi/trace`、`ipv4.icanhazip.com`、`checkip.amazonaws.com`、`api.ipify.org`),单源超时 4 秒、单源 429 独立冷却 10 分钟;任一源返回合法但不在白名单的 IP 仍立即阻断,绝不切其他源放通。
|
|
26
|
+
- 保护复查间隔支持 `10 / 15 / 30 / 60 秒`(默认 `15 秒`),最小重查间隔由 60 秒缩短至 3 秒;普通地理/时区查询继续保留 `ipinfo.io`(300 秒)。
|
|
27
|
+
- 过滤 `NWPathMonitor` 启动首次回调与无实质变化的路径抖动(300ms 防抖),避免刚发起的检测被自己撤销;冷却等待期间明确提示“等待重查…”。
|
|
28
28
|
|
|
29
|
-
历史见[CHANGELOG](CHANGELOG.md),本版见[开发与发布记录](docs/版本/1.3.
|
|
29
|
+
历史见[CHANGELOG](CHANGELOG.md),本版见[开发与发布记录](docs/版本/1.3.3开发管理.md)。
|
|
30
30
|
|
|
31
31
|
## 安装与使用
|
|
32
32
|
|
|
@@ -108,7 +108,7 @@ npm run build:overlay
|
|
|
108
108
|
|
|
109
109
|
## 公网IP与城市
|
|
110
110
|
|
|
111
|
-
菜单显示“城市名称·IP
|
|
111
|
+
菜单显示“城市名称·IP地址”,主源 `https://ipinfo.io/json` 同时获取IP、城市和时区;失败改用 `https://api.ipify.org?format=json`,备用仅返回IP、城市和时区未知。每个源连接超时3秒、总超时5秒;城市名称按接口返回显示。启动和每5分钟刷新,点击该菜单项可立即重查。IP取不到显示“IP异常”;城市取不到显示“城市未知”。
|
|
112
112
|
|
|
113
113
|
查询遵循已有HTTPS/ALL代理环境或macOS系统HTTPS代理。这里显示查询服务看到的网络出口;Clash分流时可能与AI请求不同,城市不代表电脑所在地,关闭“跟随IP时区”时不改变时钟时区。不主动保存IP历史,不发送账号凭据。
|
|
114
114
|
|
package/native/Overlay.swift
CHANGED
|
@@ -744,7 +744,7 @@ struct ControlPanelView: View {
|
|
|
744
744
|
Text(L("复查间隔", "Check interval"))
|
|
745
745
|
Spacer()
|
|
746
746
|
Picker("", selection: $owner.protectionInterval) {
|
|
747
|
-
ForEach([
|
|
747
|
+
ForEach([10, 15, 30, 60], id: \.self) { value in Text("\(value)s").tag(value) }
|
|
748
748
|
}.labelsHidden().frame(width: 85)
|
|
749
749
|
.onChange(of: owner.protectionInterval) { _, _ in owner.protectionConfigurationChanged() }
|
|
750
750
|
}.font(.system(size: 11)).controlSize(.small)
|
|
@@ -948,7 +948,9 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate, UNUserNoti
|
|
|
948
948
|
guard protectionError == nil, let report = protectionReport else { return L("IP 未知", "IP unknown") }
|
|
949
949
|
// 保护检测是地址展示的唯一来源,独立地理查询不能覆盖它。
|
|
950
950
|
if let ip = report.ip, report.state == "allowed" || (report.state == "blocked" && report.reason == "出口不在白名单") { return ip }
|
|
951
|
-
|
|
951
|
+
if report.state == "checking" { return L("正在检测…", "Checking…") }
|
|
952
|
+
if report.reason?.contains("最小查询间隔") == true { return L("等待重查…", "Waiting to recheck…") }
|
|
953
|
+
return L("IP 未知", "IP unknown")
|
|
952
954
|
}
|
|
953
955
|
var allowedIPSummary: String {
|
|
954
956
|
let values = protectionIPs.components(separatedBy: CharacterSet(charactersIn: ",,\n ")).filter { !$0.isEmpty }
|
|
@@ -966,7 +968,12 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate, UNUserNoti
|
|
|
966
968
|
}
|
|
967
969
|
@Published var protectionEnabled = UserDefaults.standard.bool(forKey: "ipProtectionEnabled")
|
|
968
970
|
@Published var protectionIPs = UserDefaults.standard.string(forKey: "ipProtectionAddresses") ?? ""
|
|
969
|
-
@Published var protectionInterval
|
|
971
|
+
@Published var protectionInterval: Int = {
|
|
972
|
+
let saved = UserDefaults.standard.object(forKey: "ipProtectionInterval") as? Int
|
|
973
|
+
if let saved, [10, 15, 30, 60].contains(saved) { return saved }
|
|
974
|
+
if let saved, saved > 60 { return 60 }
|
|
975
|
+
return 15
|
|
976
|
+
}()
|
|
970
977
|
@Published var protectionReport: ProtectionReport?
|
|
971
978
|
@Published var protectionError: String?
|
|
972
979
|
var protectionProcess: Process?
|
|
@@ -974,6 +981,8 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate, UNUserNoti
|
|
|
974
981
|
var protectionOutput: FileHandle?
|
|
975
982
|
var protectionBuffer = Data()
|
|
976
983
|
var protectionEditTimer: Timer?
|
|
984
|
+
var networkChangeTimer: Timer?
|
|
985
|
+
var lastNetworkPathSignature: String?
|
|
977
986
|
var protectionHeartbeat: TimeInterval = 0
|
|
978
987
|
let protectionPathMonitor = NWPathMonitor()
|
|
979
988
|
var protectionStateText: String {
|
|
@@ -1054,8 +1063,8 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate, UNUserNoti
|
|
|
1054
1063
|
node = args[1]; script = args[2]; searchPath = args[3]
|
|
1055
1064
|
claudeHome = args.count > 4 ? args[4] : ""
|
|
1056
1065
|
let prefs = UserDefaults.standard
|
|
1057
|
-
if let previous = prefs.object(forKey: "ipProtectionInterval") as? Int,
|
|
1058
|
-
prefs.set(60, forKey: "ipProtectionInterval")
|
|
1066
|
+
if let previous = prefs.object(forKey: "ipProtectionInterval") as? Int, ![10, 15, 30, 60].contains(previous) {
|
|
1067
|
+
prefs.set(previous > 60 ? 60 : 15, forKey: "ipProtectionInterval")
|
|
1059
1068
|
}
|
|
1060
1069
|
if prefs.object(forKey: "leftInset") != nil {
|
|
1061
1070
|
inset = CGPoint(x: prefs.double(forKey: "leftInset"), y: prefs.double(forKey: "bottomInset"))
|
|
@@ -1122,8 +1131,10 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate, UNUserNoti
|
|
|
1122
1131
|
if let timer { RunLoop.main.add(timer, forMode: .common) }
|
|
1123
1132
|
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(hide), name: NSWorkspace.didDeactivateApplicationNotification, object: nil)
|
|
1124
1133
|
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(protectionNetworkChanged), name: NSWorkspace.didWakeNotification, object: nil)
|
|
1125
|
-
protectionPathMonitor.pathUpdateHandler = { [weak self]
|
|
1126
|
-
|
|
1134
|
+
protectionPathMonitor.pathUpdateHandler = { [weak self] path in
|
|
1135
|
+
let interfaces = path.availableInterfaces.map { "\($0.type):\($0.name)" }.sorted().joined(separator: ",")
|
|
1136
|
+
let signature = "\(path.status)|\(interfaces)"
|
|
1137
|
+
Task { @MainActor in self?.handleNetworkPathUpdate(signature) }
|
|
1127
1138
|
}
|
|
1128
1139
|
protectionPathMonitor.start(queue: DispatchQueue(label: "easy-claude.network"))
|
|
1129
1140
|
startProtectionService()
|
|
@@ -1164,6 +1175,16 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate, UNUserNoti
|
|
|
1164
1175
|
try input.write(contentsOf: data)
|
|
1165
1176
|
} catch { protectionError = L("保护控制通信失败。", "Protection control connection failed."); protectionProcess?.terminate() }
|
|
1166
1177
|
}
|
|
1178
|
+
func handleNetworkPathUpdate(_ signature: String) {
|
|
1179
|
+
// 忽略启动时首次静态路径回调和无实际变化的抖动,避免刚发起的检测被自己撤销。
|
|
1180
|
+
guard let previous = lastNetworkPathSignature else { lastNetworkPathSignature = signature; return }
|
|
1181
|
+
guard signature != previous else { return }
|
|
1182
|
+
lastNetworkPathSignature = signature
|
|
1183
|
+
networkChangeTimer?.invalidate()
|
|
1184
|
+
networkChangeTimer = Timer.scheduledTimer(withTimeInterval: 0.3, repeats: false) { [weak self] _ in
|
|
1185
|
+
Task { @MainActor in self?.protectionNetworkChanged() }
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1167
1188
|
@objc func protectionNetworkChanged() {
|
|
1168
1189
|
if protectionEnabled { sendProtection(["action": "invalidate"]) }
|
|
1169
1190
|
ipQuery?.terminate(); ipQuery = nil
|
|
@@ -1783,7 +1804,7 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate, UNUserNoti
|
|
|
1783
1804
|
}
|
|
1784
1805
|
@objc func quit() { NSApp.terminate(nil) }
|
|
1785
1806
|
func applicationWillTerminate(_ notification: Notification) {
|
|
1786
|
-
protectionEditTimer?.invalidate(); protectionPathMonitor.cancel()
|
|
1807
|
+
protectionEditTimer?.invalidate(); networkChangeTimer?.invalidate(); protectionPathMonitor.cancel()
|
|
1787
1808
|
protectionOutput?.readabilityHandler = nil
|
|
1788
1809
|
try? protectionInput?.close()
|
|
1789
1810
|
ipQuery?.terminate()
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<key>CFBundleIdentifier</key><string>com.unionschool.easy-claude.overlay</string>
|
|
6
6
|
<key>CFBundleName</key><string>Easy Claude Overlay</string>
|
|
7
7
|
<key>CFBundlePackageType</key><string>APPL</string>
|
|
8
|
-
<key>CFBundleShortVersionString</key><string>1.3.
|
|
8
|
+
<key>CFBundleShortVersionString</key><string>1.3.3</string>
|
|
9
9
|
<key>LSMinimumSystemVersion</key><string>14.0</string>
|
|
10
10
|
<key>CFBundleLocalizations</key><array><string>en</string><string>zh-Hans</string><string>zh-Hant</string></array>
|
|
11
11
|
<key>LSUIElement</key><true/>
|
|
Binary file
|
package/package.json
CHANGED
package/src/ip-guard/guard.js
CHANGED
|
@@ -14,7 +14,12 @@ export function normalizeIP(value) {
|
|
|
14
14
|
|
|
15
15
|
export function parseIPResponse(raw) {
|
|
16
16
|
if (Buffer.byteLength(raw) > 8192) throw new Error('响应过大');
|
|
17
|
-
|
|
17
|
+
const trimmed = raw.trim();
|
|
18
|
+
if (!trimmed) throw new Error('空响应');
|
|
19
|
+
if (trimmed.startsWith('{')) return normalizeIP(JSON.parse(trimmed)?.ip);
|
|
20
|
+
const trace = trimmed.match(/^ip=([^\r\n]+)$/m);
|
|
21
|
+
if (trace) return normalizeIP(trace[1].trim());
|
|
22
|
+
return normalizeIP(trimmed);
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
export function probeHTTPS(url, { signal, family = 4, ca, timeout = 1000 } = {}) {
|
|
@@ -48,16 +53,25 @@ export function probeHTTPS(url, { signal, family = 4, ca, timeout = 1000 } = {})
|
|
|
48
53
|
});
|
|
49
54
|
}
|
|
50
55
|
|
|
51
|
-
export const EXIT_IP_URLS = [
|
|
56
|
+
export const EXIT_IP_URLS = [
|
|
57
|
+
'https://www.cloudflare.com/cdn-cgi/trace',
|
|
58
|
+
'https://ipv4.icanhazip.com',
|
|
59
|
+
'https://checkip.amazonaws.com',
|
|
60
|
+
'https://api.ipify.org?format=json'
|
|
61
|
+
];
|
|
52
62
|
|
|
53
|
-
export function createExitIPProbe({ request = probeHTTPS, now = () => performance.now() } = {}) {
|
|
63
|
+
export function createExitIPProbe({ request = probeHTTPS, now = () => performance.now(), urls = EXIT_IP_URLS, timeout = 4000 } = {}) {
|
|
54
64
|
const retryAt = new Map();
|
|
65
|
+
let cursor = 0;
|
|
55
66
|
return async signal => {
|
|
56
|
-
|
|
67
|
+
const start = cursor;
|
|
68
|
+
cursor = (cursor + 1) % urls.length;
|
|
69
|
+
for (let offset = 0; offset < urls.length; offset++) {
|
|
70
|
+
const url = urls[(start + offset) % urls.length];
|
|
57
71
|
if (signal.aborted) throw new Error('检测已取消');
|
|
58
72
|
if (now() < (retryAt.get(url) ?? 0)) continue;
|
|
59
73
|
try {
|
|
60
|
-
const ip = await request(url, { signal, family: 4, timeout
|
|
74
|
+
const ip = await request(url, { signal, family: 4, timeout });
|
|
61
75
|
if (signal.aborted) throw new Error('检测已取消');
|
|
62
76
|
return normalizeIP(ip);
|
|
63
77
|
} catch (error) {
|
|
@@ -65,7 +79,7 @@ export function createExitIPProbe({ request = probeHTTPS, now = () => performanc
|
|
|
65
79
|
if (error.rateLimited) retryAt.set(url, now() + 600000);
|
|
66
80
|
}
|
|
67
81
|
}
|
|
68
|
-
const rateLimited =
|
|
82
|
+
const rateLimited = urls.every(url => now() < (retryAt.get(url) ?? 0));
|
|
69
83
|
throw Object.assign(new Error(rateLimited ? '出口 IP 查询服务均不可用(限流,10分钟后重试)' : '出口 IP 查询服务均不可用'), { rateLimited });
|
|
70
84
|
};
|
|
71
85
|
}
|
package/src/ip-guard/service.js
CHANGED
|
@@ -6,16 +6,18 @@ import { Guard, normalizeIP, createExitIPProbe } from './guard.js';
|
|
|
6
6
|
import { createGateway } from './gateway.js';
|
|
7
7
|
import { controlPath, DEFAULT_PROXY_PORT } from './launcher.js';
|
|
8
8
|
|
|
9
|
+
export const MIN_CHECK_INTERVAL = 3000;
|
|
10
|
+
|
|
9
11
|
export async function startService({ input = process.stdin, output = process.stdout, path = controlPath(), proxyPort = DEFAULT_PROXY_PORT,
|
|
10
12
|
probe = createExitIPProbe(), now = () => performance.now(),
|
|
11
13
|
heartbeatTimeout = 15000 } = {}) {
|
|
12
|
-
const guard = new Guard({ allowed: [], probe, ttl:
|
|
14
|
+
const guard = new Guard({ allowed: [], probe, ttl: 25000, timeout: 13000, cooldown: 600000, now });
|
|
13
15
|
// 服务一开始先阻断,收到界面配置前绝不接受转发。
|
|
14
16
|
guard.enable();
|
|
15
17
|
const gateway = createGateway(guard);
|
|
16
18
|
await new Promise((resolve, reject) => { gateway.server.once('error', reject); gateway.server.listen(proxyPort, '127.0.0.1', resolve); });
|
|
17
19
|
const port = gateway.server.address().port;
|
|
18
|
-
let fault = '', checkedAt = null, interval =
|
|
20
|
+
let fault = '', checkedAt = null, interval = 15000;
|
|
19
21
|
let lastCheck = -Infinity, heartbeat = now(), stopped = false, holding = false, verification = 0, requested = false;
|
|
20
22
|
const status = () => {
|
|
21
23
|
const ready = guard.usable() && !fault;
|
|
@@ -27,8 +29,8 @@ export async function startService({ input = process.stdin, output = process.std
|
|
|
27
29
|
if (!guard.enabled || stopped || holding) return;
|
|
28
30
|
if (!keepLease) requested = true;
|
|
29
31
|
if (guard.controller || now() < guard.retryAt) return;
|
|
30
|
-
if (now() - lastCheck <
|
|
31
|
-
if (!keepLease) { guard.reason = '等待
|
|
32
|
+
if (now() - lastCheck < MIN_CHECK_INTERVAL) {
|
|
33
|
+
if (!keepLease) { guard.reason = '等待3秒最小查询间隔'; report(); }
|
|
32
34
|
return;
|
|
33
35
|
}
|
|
34
36
|
requested = false;
|
|
@@ -82,8 +84,8 @@ export async function startService({ input = process.stdin, output = process.std
|
|
|
82
84
|
if (!command.enabled) { holding = false; guard.disable(); fault = ''; report(); return; }
|
|
83
85
|
const ips = command.ips.map(normalizeIP);
|
|
84
86
|
if (!ips.length || ips.length > 20 || ips.some(ip => net.isIP(ip) !== 4)) throw new Error('请输入 IPv4 白名单;当前版本关闭 IPv6 转发');
|
|
85
|
-
if (!Number.isInteger(command.interval) || command.interval <
|
|
86
|
-
guard.changeAllowed(ips); guard.ttl = command.interval * 1000 +
|
|
87
|
+
if (!Number.isInteger(command.interval) || command.interval < 10 || command.interval > 300) throw new Error('复查间隔应为10至300秒');
|
|
88
|
+
guard.changeAllowed(ips); guard.ttl = command.interval * 1000 + 10000;
|
|
87
89
|
interval = command.interval * 1000; holding = false; guard.enable(); fault = ''; void verify();
|
|
88
90
|
} else if (command.action === 'invalidate' || command.action === 'verify') {
|
|
89
91
|
if (guard.enabled) { verification++; guard.revoke('网络变化或重新检测'); report(); void verify(); }
|
|
@@ -101,7 +103,7 @@ export async function startService({ input = process.stdin, output = process.std
|
|
|
101
103
|
if (now() - heartbeat >= heartbeatTimeout) { void stop(); return; }
|
|
102
104
|
const wasAllowed = guard.state === 'allowed'; guard.usable();
|
|
103
105
|
if (wasAllowed && guard.state !== 'allowed') report();
|
|
104
|
-
if (guard.enabled && !fault && now() >= guard.retryAt && now() - lastCheck >= (requested ?
|
|
106
|
+
if (guard.enabled && !fault && now() >= guard.retryAt && now() - lastCheck >= (requested ? MIN_CHECK_INTERVAL : interval)) void verify(!requested);
|
|
105
107
|
}, 500);
|
|
106
108
|
report();
|
|
107
109
|
return { guard, port, status, stop, verify };
|
package/src/public-ip.js
CHANGED
|
@@ -13,8 +13,8 @@ export async function readPublicIP({ run = promisify(execFile), env = process.en
|
|
|
13
13
|
// 限制主源等待,让备用仍有机会及时返回,不在同一源反复重试。
|
|
14
14
|
const request = async url => {
|
|
15
15
|
const { stdout } = await run('/usr/bin/curl', ['-q', '--silent', '--show-error', '--fail', '--proto', '=https',
|
|
16
|
-
'--connect-timeout', '
|
|
17
|
-
timeout:
|
|
16
|
+
'--connect-timeout', '10', '--max-time', '20', '--max-redirs', '0', url], {
|
|
17
|
+
timeout: 30000, maxBuffer: 8192, env: proxy ? { ...env, https_proxy: proxy } : env
|
|
18
18
|
});
|
|
19
19
|
return stdout;
|
|
20
20
|
};
|