proxyctl 0.1.0__py3-none-any.whl
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.
- proxyctl/__init__.py +3 -0
- proxyctl/audit.py +385 -0
- proxyctl/builtin_plugins/__init__.py +5 -0
- proxyctl/builtin_plugins/connectivity_basic.py +35 -0
- proxyctl/builtin_plugins/corp_network.py +57 -0
- proxyctl/check.py +761 -0
- proxyctl/cli.py +1355 -0
- proxyctl/core/__init__.py +1 -0
- proxyctl/core/plugin.py +287 -0
- proxyctl/engine/__init__.py +12 -0
- proxyctl/engine/base.py +85 -0
- proxyctl/engine/mihomo.py +127 -0
- proxyctl/engine/singbox.py +135 -0
- proxyctl/status.py +523 -0
- proxyctl/trace.py +558 -0
- proxyctl-0.1.0.dist-info/METADATA +218 -0
- proxyctl-0.1.0.dist-info/RECORD +20 -0
- proxyctl-0.1.0.dist-info/WHEEL +4 -0
- proxyctl-0.1.0.dist-info/entry_points.txt +2 -0
- proxyctl-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -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,20 @@
|
|
|
1
|
+
proxyctl/__init__.py,sha256=kMwX2ctr2ag1nZ-ngxnaIs_a645rw9iJEiBqnUQUqW8,84
|
|
2
|
+
proxyctl/audit.py,sha256=bjNRgdm0Egc7_Eg-xdJV0vWzNbOUgrycYvYNr_5T1FI,13251
|
|
3
|
+
proxyctl/check.py,sha256=uCDj3wrL0-UjvBXfqs7LVIFSyj13ZL1wG5CNP8ktTsQ,30475
|
|
4
|
+
proxyctl/cli.py,sha256=d5ptumo89tgPB-tn44Ju7kZH1Mm1GnQ679x0hQrVsrQ,57295
|
|
5
|
+
proxyctl/status.py,sha256=h9OCQEZwFRm1URxc1C1kpWAnGcayTSWJLmq1TXeKpn4,19745
|
|
6
|
+
proxyctl/trace.py,sha256=y0cZQvZMbNRd_3L6_KRkzkmcrk1ppWC3lDARbtfvxKQ,21362
|
|
7
|
+
proxyctl/builtin_plugins/__init__.py,sha256=743TULYZxX2p6vtBhGONjuaioFyYuGp-y0BhL21-adk,205
|
|
8
|
+
proxyctl/builtin_plugins/connectivity_basic.py,sha256=SvpMNc6pSv5C08vgkU-Vw5qWPpBWzO9a6Rr3sCGdRso,1391
|
|
9
|
+
proxyctl/builtin_plugins/corp_network.py,sha256=ZZASxJZRomRE7Oza57feN1x5TIV7sdOZBl1kyIMjKh8,1942
|
|
10
|
+
proxyctl/core/__init__.py,sha256=1bSr06TiWSHDnG7wCjZqtSPnYDhEB0jLvwfl0oKu7XA,73
|
|
11
|
+
proxyctl/core/plugin.py,sha256=98aUkMNGQUjZUycY-3HtB7UgXdo4_jiKxmTNk7smY7s,11708
|
|
12
|
+
proxyctl/engine/__init__.py,sha256=BbYI6e7G3AgZZUDAcCSQ5WbJxFNfWzoDwx5aM5yH6dY,272
|
|
13
|
+
proxyctl/engine/base.py,sha256=QZLfDetPssGF5EKiIbIyeqjUT43T5OH9-WQLO3v_Qbw,1929
|
|
14
|
+
proxyctl/engine/mihomo.py,sha256=OMsClLFSwb4ZwcbdQ0YT2HDxfWQguOf_7qzzD91Mt9o,3752
|
|
15
|
+
proxyctl/engine/singbox.py,sha256=J77bQ_PJ7rIbnt6YSU-WV4u_VH8re4KG5ytNHJ4ky9U,3915
|
|
16
|
+
proxyctl-0.1.0.dist-info/METADATA,sha256=8tOe9_6BEdB1p-mKLsdGwqGjnzoRK5ZCqM0hxs7SsG8,4959
|
|
17
|
+
proxyctl-0.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
18
|
+
proxyctl-0.1.0.dist-info/entry_points.txt,sha256=9HShIth5D1f7ECPnxYLXMCNW4jiqjpraJmN4QB-Gpug,47
|
|
19
|
+
proxyctl-0.1.0.dist-info/licenses/LICENSE,sha256=scC-b_caxbJBCkr0ioJkMF_8fTKUNDEcR463CD0TWhQ,1062
|
|
20
|
+
proxyctl-0.1.0.dist-info/RECORD,,
|
|
@@ -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.
|