proxyctl 0.1.0__tar.gz

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.
@@ -0,0 +1,75 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ .venv/
8
+ build/
9
+ develop-eggs/
10
+ dist/
11
+ downloads/
12
+ eggs/
13
+ .eggs/
14
+ # 注意:不忽略项目自身的 lib/(Python 模板默认忽略 lib/ 是给 C extension 用的)
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+
23
+ # 配置文件(包含敏感信息)
24
+ config.yaml
25
+ *.json.bak
26
+ *.log
27
+
28
+ # 缓存文件
29
+ .ipgeo-audit-cache
30
+ .ipgeo-cache
31
+ cache.db
32
+ *.db
33
+
34
+ # 日志文件
35
+ *.log
36
+ dns-watchdog.log
37
+ subscription-update.log
38
+
39
+ # 临时文件
40
+ /tmp/
41
+ *.tmp
42
+ *.swp
43
+ *.swo
44
+ *~
45
+
46
+ # IDE
47
+ .vscode/
48
+ .idea/
49
+ *.pem
50
+
51
+ # 订阅文件(包含私有 URL)
52
+ subscription.yaml
53
+ mitang-subscription.yaml
54
+ n2ray-subscription.yaml
55
+
56
+ # UI 构建产物(可选,源文件可能在其他地方)
57
+ ui/_nuxt/
58
+ ui/_fonts/
59
+
60
+ # 特定于用户的配置(运行时生成的文件)
61
+ /engine
62
+ claude-proxy.json
63
+ claude-proxy.err
64
+ claude-proxy.log
65
+
66
+ # macOS
67
+ .DS_Store
68
+
69
+ # 测试
70
+ .pytest_cache/
71
+ .coverage
72
+ .coverage.*
73
+ htmlcov/
74
+ coverage.xml
75
+ junit.xml
proxyctl-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 crhan
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.
@@ -0,0 +1,218 @@
1
+ Metadata-Version: 2.4
2
+ Name: proxyctl
3
+ Version: 0.1.0
4
+ Summary: Proxy configuration lifecycle management for macOS and Linux
5
+ Project-URL: Homepage, https://github.com/crhan/proxyctl
6
+ Project-URL: Issues, https://github.com/crhan/proxyctl/issues
7
+ Author-email: crhan <crhan123@gmail.com>
8
+ License: MIT
9
+ License-File: LICENSE
10
+ Keywords: clash,cli,lifecycle,mihomo,proxy,sing-box
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: System Administrators
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: MacOS
16
+ Classifier: Operating System :: POSIX :: Linux
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: System :: Networking
23
+ Classifier: Topic :: Utilities
24
+ Requires-Python: >=3.10
25
+ Requires-Dist: pyyaml>=6.0
26
+ Description-Content-Type: text/markdown
27
+
28
+ # proxyctl
29
+
30
+ **Proxy configuration lifecycle management** — 不是静态配置,而是配置演进框架。
31
+
32
+ ## 定位
33
+
34
+ proxyctl 是一套 macOS 代理管理工具,核心价值在于提供**配置生命周期管理**:
35
+
36
+ ```
37
+ 配置变更 → 验证 (check) → 调试 (trace) → 优化 (audit) → 回滚
38
+ ```
39
+
40
+ 它不告诉你"用什么配置",而是帮你"管好配置"。
41
+
42
+ ## 核心功能
43
+
44
+ ### 状态面板
45
+ ```bash
46
+ proxyctl status
47
+ ```
48
+ - 引擎状态、端口监听、TUN 接口
49
+ - DNS 状态、系统代理、网络环境
50
+ - Tailscale 内网连通性
51
+
52
+ ### 健康检查
53
+ ```bash
54
+ proxyctl check
55
+ ```
56
+ 四阶段检查:
57
+ 1. 基础状态(daemon、端口)
58
+ 2. 代理组状态(节点延迟、存活率)
59
+ 3. 连通性测试(google/github/国内网站)
60
+ 4. 出口 IP 验证(分流是否正确)
61
+
62
+ ### 链路诊断
63
+ ```bash
64
+ proxyctl trace example.com
65
+ ```
66
+ - DNS 解析(fakeip/realip)
67
+ - 规则匹配预测
68
+ - 连通性测试
69
+ - 实际连接验证
70
+
71
+ ### 配置审计
72
+ ```bash
73
+ proxyctl audit 7 # 扫描最近 7 天日志
74
+ proxyctl audit apply # 自动应用优化建议
75
+ ```
76
+ 找出"走代理但实际是国内 IP"的域名,建议添加到直连规则。
77
+
78
+ ### 节点测速
79
+ ```bash
80
+ proxyctl bench # 测所有组
81
+ proxyctl bench proxy claude # 测指定组
82
+ ```
83
+
84
+ ## 安装
85
+
86
+ ### 快速安装
87
+
88
+ ```bash
89
+ # 1. 克隆仓库
90
+ git clone https://github.com/crhan/proxyctl.git
91
+ cd proxyctl
92
+
93
+ # 2. 运行安装脚本
94
+ ./install.sh
95
+
96
+ # 3. 配置 API
97
+ nano ~/.config/proxyctl/config.yaml
98
+ # 填入 api_secret: your-clash-api-secret
99
+
100
+ # 4. 验证
101
+ proxyctl --help
102
+ proxyctl status
103
+ ```
104
+
105
+ ### 手动安装
106
+
107
+ ```bash
108
+ # 1. 克隆仓库
109
+ git clone https://github.com/crhan/proxyctl.git
110
+ cd proxyctl
111
+
112
+ # 2. 复制文件
113
+ cp bin/proxyctl ~/.local/bin/
114
+ chmod +x ~/.local/bin/proxyctl
115
+
116
+ # 3. 配置
117
+ mkdir -p ~/.config/proxyctl
118
+ cp config.yaml.example ~/.config/proxyctl/config.yaml
119
+ # 编辑 config.yaml,填入 api_secret
120
+ ```
121
+
122
+ ### 安装后端
123
+
124
+ ```bash
125
+ # Mihomo 后端(首发支持)
126
+ brew install mihomo
127
+
128
+ # 或者 Sing-box 后端(预留)
129
+ brew install sing-box
130
+ ```
131
+
132
+ 详细安装指南请参考 [docs/INSTALL.md](docs/INSTALL.md)
133
+
134
+ ## 配置示例
135
+
136
+ ```yaml
137
+ # ~/.config/proxyctl/config.yaml
138
+
139
+ # 后端选择:mihomo (默认) | singbox
140
+ backend: mihomo
141
+
142
+ # Clash API 配置
143
+ api_base: http://127.0.0.1:9090
144
+ api_secret: your-clash-api-secret
145
+
146
+ # 配置目录
147
+ config_dir: /Users/yourname/.config
148
+
149
+ # DNS 看门狗配置
150
+ dns_lock_label: com.proxyctl.dns-lock
151
+ ```
152
+
153
+ ## 命令速查
154
+
155
+ | 命令 | 功能 |
156
+ |---|---|
157
+ | `proxyctl start/stop/restart` | 启停后端 |
158
+ | `proxyctl status` | 系统状态面板 |
159
+ | `proxyctl check` | 全面健康检查 |
160
+ | `proxyctl trace <domain>` | 域名链路诊断 |
161
+ | `proxyctl audit [days]` | 代理链路审计 |
162
+ | `proxyctl bench [groups]` | 代理组测速 |
163
+ | `proxyctl fix` | 修复 DNS/代理 |
164
+ | `proxyctl recover` | 切网后软恢复 |
165
+ | `proxyctl mode tun\|proxy` | 切换模式 |
166
+ | `proxyctl dns-lock` | 启动 DNS 看门狗 |
167
+
168
+ ## 架构设计
169
+
170
+ ### 后端抽象
171
+ ```
172
+ Backend (接口)
173
+ ├── MihomoBackend (首发实现)
174
+ └── SingboxBackend (预留)
175
+ ```
176
+
177
+ ### DNS 防线体系
178
+ 三层修复对抗 DNS 覆盖:
179
+ 1. `networksetup` — 对抗 DHCP
180
+ 2. 劫持 AnyConnect DNS 条目 — 对抗 VPN
181
+ 3. scutil 兜底注入 — 对抗其他覆盖源
182
+
183
+ ### 配置即代码
184
+ - 版本控制 (git)
185
+ - CI/CD (`proxyctl check` 当测试)
186
+ - 回滚机制 (config.bak)
187
+ - 变更日志
188
+
189
+ ## 后端支持
190
+
191
+ | 功能 | Mihomo | Sing-box |
192
+ |---|---|---|
193
+ | status | ✅ | ✅ |
194
+ | check | ✅ | ✅ |
195
+ | trace | ✅ | ✅ |
196
+ | audit | ✅ | ✅ |
197
+ | bench | ✅ | ⚠️ |
198
+ | recover | ✅ | ❌ |
199
+ | mode 切换 | ✅ | ✅ |
200
+
201
+ ## 开发
202
+
203
+ ```bash
204
+ # 本地测试
205
+ python3 bin/proxyctl status
206
+
207
+ # 调试模式
208
+ export PROXYCTL_DEBUG=1
209
+ ```
210
+
211
+ ## License
212
+
213
+ MIT
214
+
215
+ ## 致谢
216
+
217
+ - [Mihomo](https://github.com/MetaCubeX/mihomo) - Clash Meta 内核
218
+ - [Sing-box](https://github.com/SagerNet/sing-box) - 下一代代理内核
@@ -0,0 +1,191 @@
1
+ # proxyctl
2
+
3
+ **Proxy configuration lifecycle management** — 不是静态配置,而是配置演进框架。
4
+
5
+ ## 定位
6
+
7
+ proxyctl 是一套 macOS 代理管理工具,核心价值在于提供**配置生命周期管理**:
8
+
9
+ ```
10
+ 配置变更 → 验证 (check) → 调试 (trace) → 优化 (audit) → 回滚
11
+ ```
12
+
13
+ 它不告诉你"用什么配置",而是帮你"管好配置"。
14
+
15
+ ## 核心功能
16
+
17
+ ### 状态面板
18
+ ```bash
19
+ proxyctl status
20
+ ```
21
+ - 引擎状态、端口监听、TUN 接口
22
+ - DNS 状态、系统代理、网络环境
23
+ - Tailscale 内网连通性
24
+
25
+ ### 健康检查
26
+ ```bash
27
+ proxyctl check
28
+ ```
29
+ 四阶段检查:
30
+ 1. 基础状态(daemon、端口)
31
+ 2. 代理组状态(节点延迟、存活率)
32
+ 3. 连通性测试(google/github/国内网站)
33
+ 4. 出口 IP 验证(分流是否正确)
34
+
35
+ ### 链路诊断
36
+ ```bash
37
+ proxyctl trace example.com
38
+ ```
39
+ - DNS 解析(fakeip/realip)
40
+ - 规则匹配预测
41
+ - 连通性测试
42
+ - 实际连接验证
43
+
44
+ ### 配置审计
45
+ ```bash
46
+ proxyctl audit 7 # 扫描最近 7 天日志
47
+ proxyctl audit apply # 自动应用优化建议
48
+ ```
49
+ 找出"走代理但实际是国内 IP"的域名,建议添加到直连规则。
50
+
51
+ ### 节点测速
52
+ ```bash
53
+ proxyctl bench # 测所有组
54
+ proxyctl bench proxy claude # 测指定组
55
+ ```
56
+
57
+ ## 安装
58
+
59
+ ### 快速安装
60
+
61
+ ```bash
62
+ # 1. 克隆仓库
63
+ git clone https://github.com/crhan/proxyctl.git
64
+ cd proxyctl
65
+
66
+ # 2. 运行安装脚本
67
+ ./install.sh
68
+
69
+ # 3. 配置 API
70
+ nano ~/.config/proxyctl/config.yaml
71
+ # 填入 api_secret: your-clash-api-secret
72
+
73
+ # 4. 验证
74
+ proxyctl --help
75
+ proxyctl status
76
+ ```
77
+
78
+ ### 手动安装
79
+
80
+ ```bash
81
+ # 1. 克隆仓库
82
+ git clone https://github.com/crhan/proxyctl.git
83
+ cd proxyctl
84
+
85
+ # 2. 复制文件
86
+ cp bin/proxyctl ~/.local/bin/
87
+ chmod +x ~/.local/bin/proxyctl
88
+
89
+ # 3. 配置
90
+ mkdir -p ~/.config/proxyctl
91
+ cp config.yaml.example ~/.config/proxyctl/config.yaml
92
+ # 编辑 config.yaml,填入 api_secret
93
+ ```
94
+
95
+ ### 安装后端
96
+
97
+ ```bash
98
+ # Mihomo 后端(首发支持)
99
+ brew install mihomo
100
+
101
+ # 或者 Sing-box 后端(预留)
102
+ brew install sing-box
103
+ ```
104
+
105
+ 详细安装指南请参考 [docs/INSTALL.md](docs/INSTALL.md)
106
+
107
+ ## 配置示例
108
+
109
+ ```yaml
110
+ # ~/.config/proxyctl/config.yaml
111
+
112
+ # 后端选择:mihomo (默认) | singbox
113
+ backend: mihomo
114
+
115
+ # Clash API 配置
116
+ api_base: http://127.0.0.1:9090
117
+ api_secret: your-clash-api-secret
118
+
119
+ # 配置目录
120
+ config_dir: /Users/yourname/.config
121
+
122
+ # DNS 看门狗配置
123
+ dns_lock_label: com.proxyctl.dns-lock
124
+ ```
125
+
126
+ ## 命令速查
127
+
128
+ | 命令 | 功能 |
129
+ |---|---|
130
+ | `proxyctl start/stop/restart` | 启停后端 |
131
+ | `proxyctl status` | 系统状态面板 |
132
+ | `proxyctl check` | 全面健康检查 |
133
+ | `proxyctl trace <domain>` | 域名链路诊断 |
134
+ | `proxyctl audit [days]` | 代理链路审计 |
135
+ | `proxyctl bench [groups]` | 代理组测速 |
136
+ | `proxyctl fix` | 修复 DNS/代理 |
137
+ | `proxyctl recover` | 切网后软恢复 |
138
+ | `proxyctl mode tun\|proxy` | 切换模式 |
139
+ | `proxyctl dns-lock` | 启动 DNS 看门狗 |
140
+
141
+ ## 架构设计
142
+
143
+ ### 后端抽象
144
+ ```
145
+ Backend (接口)
146
+ ├── MihomoBackend (首发实现)
147
+ └── SingboxBackend (预留)
148
+ ```
149
+
150
+ ### DNS 防线体系
151
+ 三层修复对抗 DNS 覆盖:
152
+ 1. `networksetup` — 对抗 DHCP
153
+ 2. 劫持 AnyConnect DNS 条目 — 对抗 VPN
154
+ 3. scutil 兜底注入 — 对抗其他覆盖源
155
+
156
+ ### 配置即代码
157
+ - 版本控制 (git)
158
+ - CI/CD (`proxyctl check` 当测试)
159
+ - 回滚机制 (config.bak)
160
+ - 变更日志
161
+
162
+ ## 后端支持
163
+
164
+ | 功能 | Mihomo | Sing-box |
165
+ |---|---|---|
166
+ | status | ✅ | ✅ |
167
+ | check | ✅ | ✅ |
168
+ | trace | ✅ | ✅ |
169
+ | audit | ✅ | ✅ |
170
+ | bench | ✅ | ⚠️ |
171
+ | recover | ✅ | ❌ |
172
+ | mode 切换 | ✅ | ✅ |
173
+
174
+ ## 开发
175
+
176
+ ```bash
177
+ # 本地测试
178
+ python3 bin/proxyctl status
179
+
180
+ # 调试模式
181
+ export PROXYCTL_DEBUG=1
182
+ ```
183
+
184
+ ## License
185
+
186
+ MIT
187
+
188
+ ## 致谢
189
+
190
+ - [Mihomo](https://github.com/MetaCubeX/mihomo) - Clash Meta 内核
191
+ - [Sing-box](https://github.com/SagerNet/sing-box) - 下一代代理内核
@@ -0,0 +1,79 @@
1
+ [project]
2
+ name = "proxyctl"
3
+ version = "0.1.0"
4
+ description = "Proxy configuration lifecycle management for macOS and Linux"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = { text = "MIT" }
8
+ authors = [{ name = "crhan", email = "crhan123@gmail.com" }]
9
+ keywords = ["proxy", "mihomo", "clash", "sing-box", "lifecycle", "cli"]
10
+ classifiers = [
11
+ "Development Status :: 4 - Beta",
12
+ "Environment :: Console",
13
+ "Intended Audience :: System Administrators",
14
+ "License :: OSI Approved :: MIT License",
15
+ "Operating System :: MacOS",
16
+ "Operating System :: POSIX :: Linux",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.10",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Programming Language :: Python :: 3.13",
22
+ "Topic :: System :: Networking",
23
+ "Topic :: Utilities",
24
+ ]
25
+ dependencies = ["pyyaml>=6.0"]
26
+
27
+ [project.urls]
28
+ Homepage = "https://github.com/crhan/proxyctl"
29
+ Issues = "https://github.com/crhan/proxyctl/issues"
30
+
31
+ [project.scripts]
32
+ proxyctl = "proxyctl.cli:main"
33
+
34
+ [dependency-groups]
35
+ dev = [
36
+ "pytest>=8.0",
37
+ "pytest-cov>=5.0",
38
+ ]
39
+
40
+ [build-system]
41
+ requires = ["hatchling"]
42
+ build-backend = "hatchling.build"
43
+
44
+ [tool.hatch.build.targets.wheel]
45
+ packages = ["src/proxyctl"]
46
+
47
+ [tool.hatch.build.targets.sdist]
48
+ include = ["src/proxyctl", "README.md", "LICENSE", "pyproject.toml"]
49
+
50
+ [tool.pytest.ini_options]
51
+ minversion = "8.0"
52
+ testpaths = ["tests"]
53
+ addopts = [
54
+ "-ra",
55
+ "--strict-markers",
56
+ "--strict-config",
57
+ ]
58
+ markers = [
59
+ "slow: marks tests as slow (deselect with '-m \"not slow\"')",
60
+ ]
61
+
62
+ [tool.coverage.run]
63
+ branch = true
64
+ source = ["proxyctl"]
65
+ omit = [
66
+ "*/tests/*",
67
+ "*/__init__.py",
68
+ ]
69
+
70
+ [tool.coverage.report]
71
+ exclude_lines = [
72
+ "pragma: no cover",
73
+ "raise NotImplementedError",
74
+ "if __name__ == .__main__.:",
75
+ "if TYPE_CHECKING:",
76
+ ]
77
+ show_missing = true
78
+ skip_covered = false
79
+ precision = 1
@@ -0,0 +1,3 @@
1
+ """proxyctl — Proxy configuration lifecycle management."""
2
+
3
+ __version__ = "0.1.0"