claude-cac 1.5.3 → 1.5.5

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.
Files changed (2) hide show
  1. package/cac +67 -10
  2. package/package.json +1 -1
package/cac CHANGED
@@ -11,7 +11,7 @@ VERSIONS_DIR="$CAC_DIR/versions"
11
11
  # ── utils: colors, read/write, UUID, proxy parsing ───────────────────────
12
12
 
13
13
  # shellcheck disable=SC2034 # used in build-concatenated cac script
14
- CAC_VERSION="1.5.3"
14
+ CAC_VERSION="1.5.5"
15
15
 
16
16
  _read() { [[ -f "$1" ]] && tr -d '[:space:]' < "$1" || echo "${2:-}"; }
17
17
  _die() { printf '%b\n' "$(_red "error:") $*" >&2; exit 1; }
@@ -86,11 +86,30 @@ _get_real_cmd() {
86
86
  }
87
87
 
88
88
  # host:port:user:pass → http://user:pass@host:port
89
- # or pass a full URL directly (http://, https://, socks5://)
89
+ # socks5://host:port:user:pass socks5://user:pass@host:port
90
+ # or pass a standard URL directly (http://, https://, socks5://)
90
91
  _parse_proxy() {
91
92
  local raw="$1"
92
- # Already a full URL, return as-is
93
+ local proto rest
94
+
95
+ [[ -n "$raw" ]] || return 0
96
+
97
+ # Normalize protocol-prefixed legacy form:
98
+ # socks5://host:port:user:pass -> socks5://user:pass@host:port
93
99
  if [[ "$raw" =~ ^(http|https|socks5):// ]]; then
100
+ proto="${raw%%://*}"
101
+ rest="${raw#*://}"
102
+ if [[ "$rest" != *"@"* ]] && [[ "$rest" == *:*:* ]]; then
103
+ local host port user pass
104
+ host=$(echo "$rest" | cut -d: -f1)
105
+ port=$(echo "$rest" | cut -d: -f2)
106
+ user=$(echo "$rest" | cut -d: -f3)
107
+ pass=$(echo "$rest" | cut -d: -f4-)
108
+ if [[ -n "$host" ]] && [[ -n "$port" ]] && [[ -n "$user" ]]; then
109
+ echo "${proto}://${user}:${pass}@${host}:${port}"
110
+ return
111
+ fi
112
+ fi
94
113
  echo "$raw"
95
114
  return
96
115
  fi
@@ -109,7 +128,9 @@ _parse_proxy() {
109
128
 
110
129
  # socks5://user:pass@host:port → host:port
111
130
  _proxy_host_port() {
112
- echo "$1" | sed 's|.*@||' | sed 's|.*://||'
131
+ local normalized
132
+ normalized=$(_parse_proxy "$1")
133
+ echo "$normalized" | sed 's|.*@||' | sed 's|.*://||'
113
134
  }
114
135
 
115
136
  _proxy_reachable() {
@@ -1044,6 +1065,9 @@ _write_env_settings() {
1044
1065
  "statusLine": {
1045
1066
  "type": "command",
1046
1067
  "command": "bash $CLAUDE_CONFIG_DIR/statusline-command.sh"
1068
+ },
1069
+ "env": {
1070
+ "DISABLE_AUTOUPDATER": "1"
1047
1071
  }
1048
1072
  }
1049
1073
  SETTINGS_EOF
@@ -1141,13 +1165,26 @@ fi
1141
1165
  PROXY=""
1142
1166
  if [[ -f "$_env_dir/proxy" ]]; then
1143
1167
  PROXY=$(tr -d '[:space:]' < "$_env_dir/proxy")
1168
+ if [[ "$PROXY" =~ ^(http|https|socks5):// ]]; then
1169
+ _proto="${PROXY%%://*}"
1170
+ _rest="${PROXY#*://}"
1171
+ if [[ "$_rest" != *"@"* ]] && [[ "$_rest" == *:*:* ]]; then
1172
+ _phost=$(echo "$_rest" | cut -d: -f1)
1173
+ _pport=$(echo "$_rest" | cut -d: -f2)
1174
+ _puser=$(echo "$_rest" | cut -d: -f3)
1175
+ _ppass=$(echo "$_rest" | cut -d: -f4-)
1176
+ if [[ -n "$_phost" ]] && [[ -n "$_pport" ]] && [[ -n "$_puser" ]]; then
1177
+ PROXY="${_proto}://${_puser}:${_ppass}@${_phost}:${_pport}"
1178
+ fi
1179
+ fi
1180
+ fi
1144
1181
  fi
1145
1182
 
1146
1183
  if [[ -n "$PROXY" ]]; then
1147
1184
  # pre-flight: proxy connectivity (pure bash, no fork)
1148
1185
  _hp="${PROXY##*@}"; _hp="${_hp##*://}"
1149
1186
  _host="${_hp%%:*}"
1150
- _port="${_hp##*:}"
1187
+ _port=$(echo "$_hp" | cut -d: -f2)
1151
1188
  if ! (echo >/dev/tcp/"$_host"/"$_port") 2>/dev/null; then
1152
1189
  echo "[cac] error: [$_name] proxy $_hp unreachable, refusing to start." >&2
1153
1190
  echo "[cac] hint: run 'cac check' to diagnose, or 'cac stop' to disable temporarily" >&2
@@ -1603,6 +1640,25 @@ _ensure_initialized() {
1603
1640
  rm -f "$CAC_DIR/blocked_hosts" 2>/dev/null || true
1604
1641
  _write_blocked_hosts 2>/dev/null || true
1605
1642
 
1643
+ # Patch all existing envs: ensure DISABLE_AUTOUPDATER=1 in settings.json
1644
+ local _sf
1645
+ for _sf in "$ENVS_DIR"/*/.claude/settings.json; do
1646
+ [[ -f "$_sf" ]] || continue
1647
+ grep -q '"DISABLE_AUTOUPDATER"' "$_sf" 2>/dev/null && continue
1648
+ python3 - "$_sf" << 'PYEOF' 2>/dev/null || true
1649
+ import json, sys
1650
+ path = sys.argv[1]
1651
+ with open(path) as f:
1652
+ d = json.load(f)
1653
+ if d.get('env', {}).get('DISABLE_AUTOUPDATER') == '1':
1654
+ sys.exit(0)
1655
+ d.setdefault('env', {})['DISABLE_AUTOUPDATER'] = '1'
1656
+ with open(path, 'w') as f:
1657
+ json.dump(d, f, indent=2)
1658
+ f.write('\n')
1659
+ PYEOF
1660
+ done
1661
+
1606
1662
  # PATH (idempotent — always ensure it's in rc file)
1607
1663
  local rc_file; rc_file=$(_detect_rc_file)
1608
1664
  _write_path_to_rc "$rc_file" >/dev/null 2>&1 || true
@@ -1869,7 +1925,7 @@ _env_cmd_ls() {
1869
1925
  [[ -d "$env_dir" ]] || continue
1870
1926
  names+=("$(basename "$env_dir")")
1871
1927
  versions+=("$(_read "$env_dir/version" "system")")
1872
- local p; p=$(_read "$env_dir/proxy" "")
1928
+ local p; p=$(_parse_proxy "$(_read "$env_dir/proxy" "")")
1873
1929
  if [[ -n "$p" ]] && [[ "$p" == *"://"*"@"* ]]; then
1874
1930
  p=$(echo "$p" | sed 's|://[^@]*@|://***@|')
1875
1931
  fi
@@ -2104,7 +2160,7 @@ cmd_env() {
2104
2160
  _relay_start() {
2105
2161
  local name="${1:-$(_current_env)}"
2106
2162
  local env_dir="$ENVS_DIR/$name"
2107
- local proxy; proxy=$(_read "$env_dir/proxy")
2163
+ local proxy; proxy=$(_parse_proxy "$(_read "$env_dir/proxy")")
2108
2164
  [[ -z "$proxy" ]] && return 1
2109
2165
 
2110
2166
  local relay_js="$CAC_DIR/relay.js"
@@ -2267,7 +2323,7 @@ cmd_relay() {
2267
2323
 
2268
2324
  # --route flag: add direct route
2269
2325
  if [[ "$flag" == "--route" ]]; then
2270
- local proxy; proxy=$(_read "$env_dir/proxy")
2326
+ local proxy; proxy=$(_parse_proxy "$(_read "$env_dir/proxy")")
2271
2327
  _relay_add_route "$proxy"
2272
2328
  fi
2273
2329
 
@@ -2337,7 +2393,7 @@ cmd_check() {
2337
2393
  fi
2338
2394
 
2339
2395
  local env_dir="$ENVS_DIR/$current"
2340
- local proxy; proxy=$(_read "$env_dir/proxy" "")
2396
+ local proxy; proxy=$(_parse_proxy "$(_read "$env_dir/proxy" "")")
2341
2397
 
2342
2398
  # Resolve version
2343
2399
  local ver; ver=$(_read "$env_dir/version" "")
@@ -2542,7 +2598,8 @@ cmd_check() {
2542
2598
  fi
2543
2599
  fi
2544
2600
  else
2545
- printf "\r $(_green "") exit IP $(_dim "run again to detect exit IP")\033[K\n"
2601
+ printf "\r $(_red "") exit IP $(_dim "unable to verify via proxy")\033[K\n"
2602
+ problems+=("exit IP undetected via proxy")
2546
2603
  fi
2547
2604
 
2548
2605
  # TUN conflict detection
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-cac",
3
- "version": "1.5.3",
3
+ "version": "1.5.5",
4
4
  "description": "Isolate, protect, and manage your Claude Code — versions, environments, identity, and proxy.",
5
5
  "bin": {
6
6
  "cac": "cac"