claude-cac 1.0.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 nmhjklnm
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 ADDED
@@ -0,0 +1,254 @@
1
+ <div align="center">
2
+
3
+ # cac — Claude Code Cloak
4
+
5
+ **Privacy Cloak + CLI Proxy for Claude Code**
6
+
7
+ **[中文](#中文) | [English](#english)**
8
+
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
10
+ [![Platform](https://img.shields.io/badge/Platform-macOS%20%7C%20Linux-lightgrey.svg)]()
11
+ [![Shell](https://img.shields.io/badge/Shell-Bash-green.svg)]()
12
+
13
+ </div>
14
+
15
+ ---
16
+
17
+ <a id="中文"></a>
18
+
19
+ ## 中文
20
+
21
+ > **[Switch to English](#english)**
22
+
23
+ ### 为什么需要 cac
24
+
25
+ Claude Code 在运行过程中会读取并上报设备标识符(硬件 UUID、安装 ID、网络出口 IP 等)。cac 通过 wrapper 机制拦截所有 `claude` 调用,在进程层面同时解决两个问题:
26
+
27
+ **A. 隐私隔离** — 每个配置对外呈现独立的设备身份,彻底隔离真实设备指纹。
28
+
29
+ **B. CLI 专属代理** — 进程级注入代理,`claude` 流量直连远端代理服务器。无需 Clash / Shadowrocket 等本地代理工具,无需中转,无需起本地服务端。配合静态住宅 IP,获得固定、干净的出口身份。
30
+
31
+ ### 特性一览
32
+
33
+ | | 特性 | 说明 |
34
+ |:---|:---|:---|
35
+ | **A** | 硬件 UUID 隔离 | macOS: 拦截 `ioreg` / Linux: 拦截 `machine-id` |
36
+ | **A** | hostname / MAC 隔离 | 拦截 `hostname` 和 `ifconfig` 命令 |
37
+ | **A** | stable_id / userID 隔离 | 切换配置时自动写入独立标识 |
38
+ | **A** | 时区 / 语言伪装 | 根据代理出口地区自动匹配 |
39
+ | **A** | NS 层级遥测拦截 | DNS guard 拦截 `statsig.anthropic.com` 等遥测域名 |
40
+ | **A** | 12 层环境变量保护 | 全面禁用遥测、错误上报、非必要流量 |
41
+ | **A** | fetch 遥测拦截 | 替换原生 fetch,防止绕过 DNS 拦截 |
42
+ | **A** | mTLS 客户端证书 | 自签 CA + 每环境独立客户端证书 |
43
+ | **B** | 进程级代理 | 支持 HTTP/HTTPS/SOCKS5 代理 |
44
+ | **B** | 免本地服务端 | 无需 Clash / Shadowrocket / TUN,CLI 直连 |
45
+ | **B** | 静态住宅 IP 支持 | 配置固定代理 → 固定出口 IP |
46
+ | **B** | 启动前连通检测 | 代理不可达时拒绝启动,真实 IP 零泄漏 |
47
+ | **B** | 本地代理冲突检测 | `cac check` 自动检测 Clash/TUN 冲突 |
48
+
49
+ 所有 `claude` 调用(含 Agent 子进程)均通过 wrapper 拦截。零入侵 Claude Code 源代码。
50
+
51
+ ### 安装
52
+
53
+ **一键安装(推荐):**
54
+
55
+ ```bash
56
+ curl -fsSL https://raw.githubusercontent.com/nmhjklnm/cac/master/install.sh | bash
57
+ ```
58
+
59
+ **手动安装:**
60
+
61
+ ```bash
62
+ git clone https://github.com/nmhjklnm/cac.git
63
+ cd cac
64
+ bash install.sh
65
+ ```
66
+
67
+ 安装完成后重开终端,或执行 `source ~/.zshrc`。
68
+
69
+ ### 使用
70
+
71
+ ```bash
72
+ # 添加配置
73
+ cac add us1 1.2.3.4:1080:username:password
74
+ cac add us2 "socks5://username:password@1.2.3.4:1080"
75
+
76
+ # 切换配置
77
+ cac us1
78
+
79
+ # 检查状态(含代理冲突检测)
80
+ cac check
81
+
82
+ # 启动 Claude Code
83
+ claude
84
+ ```
85
+
86
+ 首次使用需在 Claude Code 内执行 `/login` 完成账号登录。
87
+
88
+ ### 命令
89
+
90
+ | 命令 | 说明 |
91
+ |:---|:---|
92
+ | `cac add <名字> <host:port:u:p>` | 添加配置 |
93
+ | `cac <名字>` | 切换配置,刷新所有隐私参数 |
94
+ | `cac ls` | 列出所有配置 |
95
+ | `cac check` | 检查代理 + 安全防护 + 冲突检测 |
96
+ | `cac stop` | 临时停用保护 |
97
+ | `cac -c` | 恢复保护 |
98
+
99
+ ### 工作原理
100
+
101
+ ```
102
+ cac wrapper (进程级,零入侵源代码)
103
+ ┌──────────────────────────────────────┐
104
+ claude ──────►│ 12 层环境变量遥测保护 │──── 直连远端代理 ────► Anthropic API
105
+ │ NODE_OPTIONS --require DNS guard │ (静态住宅 IP)
106
+ │ PATH 前置 shim(设备指纹隔离) │
107
+ │ mTLS 客户端证书注入 │
108
+ │ 启动前代理连通性检测 │
109
+ └──────────────────────────────────────┘
110
+ ↑ dns.lookup / net.connect / fetch 遥测拦截
111
+ ↑ macOS: ioreg/hostname/ifconfig shim
112
+ ↑ Linux: cat/hostname/ifconfig shim
113
+ ```
114
+
115
+ ### 文件结构
116
+
117
+ ```
118
+ ~/.cac/
119
+ ├── bin/claude # wrapper(拦截所有 claude 调用)
120
+ ├── shim-bin/ # ioreg / hostname / ifconfig / cat shim
121
+ ├── cac-dns-guard.js # NS 层级 DNS 拦截 + mTLS 注入 + fetch 补丁
122
+ ├── blocked_hosts # HOSTALIASES 遥测域名拦截(备用层)
123
+ ├── ca/ # mTLS 自签 CA 证书
124
+ ├── real_claude # 真实 claude 二进制路径
125
+ ├── current # 当前激活的配置名
126
+ └── envs/<name>/
127
+ ├── proxy # 代理地址
128
+ ├── uuid / stable_id / user_id # 独立身份标识
129
+ ├── machine_id / hostname / mac_address # 独立设备指纹
130
+ ├── client_cert.pem / client_key.pem # mTLS 客户端证书
131
+ └── tz / lang # 时区 / 语言
132
+ ```
133
+
134
+ ### 注意事项
135
+
136
+ > **本地代理工具共存**
137
+ > 若同时使用 Clash / Shadowrocket 等 TUN 模式,需为代理服务器 IP 添加 DIRECT 规则。`cac check` 会自动检测冲突并给出修复建议。
138
+
139
+ > **第三方 API 配置**
140
+ > wrapper 启动时自动清除 `ANTHROPIC_BASE_URL` / `ANTHROPIC_AUTH_TOKEN` / `ANTHROPIC_API_KEY`。
141
+
142
+ > **IPv6**
143
+ > 建议在系统层关闭 IPv6,防止真实出口 IPv6 地址被暴露。
144
+
145
+ ---
146
+
147
+ <a id="english"></a>
148
+
149
+ ## English
150
+
151
+ > **[切换到中文](#中文)**
152
+
153
+ ### Why cac
154
+
155
+ Claude Code reads and reports device identifiers at runtime (hardware UUID, installation ID, network egress IP, etc.). cac intercepts all `claude` invocations via a wrapper, solving two problems at the process level — without modifying any Claude Code source code:
156
+
157
+ **A. Privacy Cloak** — Each profile presents an independent device identity, fully isolating your real device fingerprint.
158
+
159
+ **B. CLI Proxy** — Process-level proxy injection; `claude` traffic connects directly to the remote proxy server. No Clash / Shadowrocket or any local proxy tools needed.
160
+
161
+ ### Features
162
+
163
+ | | Feature | Description |
164
+ |:---|:---|:---|
165
+ | **A** | Hardware UUID isolation | macOS: intercepts `ioreg` / Linux: intercepts `machine-id` |
166
+ | **A** | hostname / MAC isolation | Intercepts `hostname` and `ifconfig` commands |
167
+ | **A** | stable_id / userID isolation | Writes independent identifiers on profile switch |
168
+ | **A** | Timezone / locale spoofing | Auto-detected from proxy exit region |
169
+ | **A** | NS-level telemetry blocking | DNS guard blocks `statsig.anthropic.com` and other telemetry domains |
170
+ | **A** | 12-layer env var protection | Disables telemetry, error reporting, non-essential traffic |
171
+ | **A** | fetch telemetry interception | Replaces native fetch to prevent DNS interception bypass |
172
+ | **A** | mTLS client certificates | Self-signed CA + per-profile client certificates |
173
+ | **B** | Process-level proxy | Supports HTTP/HTTPS/SOCKS5 proxies |
174
+ | **B** | No local server needed | No Clash / Shadowrocket / TUN — direct CLI connection |
175
+ | **B** | Static residential IP support | Fixed proxy config = fixed egress IP |
176
+ | **B** | Pre-launch connectivity check | Blocks startup if proxy unreachable — zero real IP leakage |
177
+ | **B** | Local proxy conflict detection | `cac check` detects Clash/TUN conflicts automatically |
178
+
179
+ All `claude` invocations (including Agent subprocesses) are intercepted. Zero invasion of Claude Code source code.
180
+
181
+ ### Installation
182
+
183
+ **One-line install (recommended):**
184
+
185
+ ```bash
186
+ curl -fsSL https://raw.githubusercontent.com/nmhjklnm/cac/master/install.sh | bash
187
+ ```
188
+
189
+ **Manual install:**
190
+
191
+ ```bash
192
+ git clone https://github.com/nmhjklnm/cac.git
193
+ cd cac
194
+ bash install.sh
195
+ ```
196
+
197
+ After installation, restart your terminal or run `source ~/.zshrc`.
198
+
199
+ ### Usage
200
+
201
+ ```bash
202
+ cac add us1 1.2.3.4:1080:username:password
203
+ cac us1
204
+ cac check # includes proxy conflict detection
205
+ claude
206
+ ```
207
+
208
+ On first use, run `/login` inside Claude Code to authenticate.
209
+
210
+ ### Commands
211
+
212
+ | Command | Description |
213
+ |:---|:---|
214
+ | `cac add <name> <host:port:u:p>` | Add profile |
215
+ | `cac <name>` | Switch profile, refresh all privacy parameters |
216
+ | `cac ls` | List all profiles |
217
+ | `cac check` | Check proxy + security + conflict detection |
218
+ | `cac stop` | Temporarily disable protection |
219
+ | `cac -c` | Re-enable protection |
220
+
221
+ ### How It Works
222
+
223
+ ```
224
+ cac wrapper (process-level, zero source invasion)
225
+ ┌──────────────────────────────────────┐
226
+ claude ──────►│ 12-layer env var telemetry protection │──── Direct to remote ────► Anthropic API
227
+ │ NODE_OPTIONS --require DNS guard │ (static residential)
228
+ │ PATH-prepended shims (fingerprint) │
229
+ │ mTLS client cert injection │
230
+ │ Pre-flight proxy check │
231
+ └──────────────────────────────────────┘
232
+ ↑ dns.lookup / net.connect / fetch telemetry interception
233
+ ↑ macOS: ioreg/hostname/ifconfig shim
234
+ ↑ Linux: cat/hostname/ifconfig shim
235
+ ```
236
+
237
+ ### Notes
238
+
239
+ > **Coexisting with local proxy tools**
240
+ > If you also use Clash / Shadowrocket in TUN mode, add a DIRECT rule for the proxy server IP. `cac check` will detect conflicts and provide fix suggestions.
241
+
242
+ > **Third-party API configuration**
243
+ > The wrapper automatically clears `ANTHROPIC_BASE_URL` / `ANTHROPIC_AUTH_TOKEN` / `ANTHROPIC_API_KEY` on startup.
244
+
245
+ > **IPv6**
246
+ > It is recommended to disable IPv6 at the system level to prevent your real IPv6 egress address from being exposed.
247
+
248
+ ---
249
+
250
+ <div align="center">
251
+
252
+ MIT License
253
+
254
+ </div>