claude-cac 1.5.4 → 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 +45 -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.4"
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() {
@@ -1144,13 +1165,26 @@ fi
1144
1165
  PROXY=""
1145
1166
  if [[ -f "$_env_dir/proxy" ]]; then
1146
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
1147
1181
  fi
1148
1182
 
1149
1183
  if [[ -n "$PROXY" ]]; then
1150
1184
  # pre-flight: proxy connectivity (pure bash, no fork)
1151
1185
  _hp="${PROXY##*@}"; _hp="${_hp##*://}"
1152
1186
  _host="${_hp%%:*}"
1153
- _port="${_hp##*:}"
1187
+ _port=$(echo "$_hp" | cut -d: -f2)
1154
1188
  if ! (echo >/dev/tcp/"$_host"/"$_port") 2>/dev/null; then
1155
1189
  echo "[cac] error: [$_name] proxy $_hp unreachable, refusing to start." >&2
1156
1190
  echo "[cac] hint: run 'cac check' to diagnose, or 'cac stop' to disable temporarily" >&2
@@ -1891,7 +1925,7 @@ _env_cmd_ls() {
1891
1925
  [[ -d "$env_dir" ]] || continue
1892
1926
  names+=("$(basename "$env_dir")")
1893
1927
  versions+=("$(_read "$env_dir/version" "system")")
1894
- local p; p=$(_read "$env_dir/proxy" "")
1928
+ local p; p=$(_parse_proxy "$(_read "$env_dir/proxy" "")")
1895
1929
  if [[ -n "$p" ]] && [[ "$p" == *"://"*"@"* ]]; then
1896
1930
  p=$(echo "$p" | sed 's|://[^@]*@|://***@|')
1897
1931
  fi
@@ -2126,7 +2160,7 @@ cmd_env() {
2126
2160
  _relay_start() {
2127
2161
  local name="${1:-$(_current_env)}"
2128
2162
  local env_dir="$ENVS_DIR/$name"
2129
- local proxy; proxy=$(_read "$env_dir/proxy")
2163
+ local proxy; proxy=$(_parse_proxy "$(_read "$env_dir/proxy")")
2130
2164
  [[ -z "$proxy" ]] && return 1
2131
2165
 
2132
2166
  local relay_js="$CAC_DIR/relay.js"
@@ -2289,7 +2323,7 @@ cmd_relay() {
2289
2323
 
2290
2324
  # --route flag: add direct route
2291
2325
  if [[ "$flag" == "--route" ]]; then
2292
- local proxy; proxy=$(_read "$env_dir/proxy")
2326
+ local proxy; proxy=$(_parse_proxy "$(_read "$env_dir/proxy")")
2293
2327
  _relay_add_route "$proxy"
2294
2328
  fi
2295
2329
 
@@ -2359,7 +2393,7 @@ cmd_check() {
2359
2393
  fi
2360
2394
 
2361
2395
  local env_dir="$ENVS_DIR/$current"
2362
- local proxy; proxy=$(_read "$env_dir/proxy" "")
2396
+ local proxy; proxy=$(_parse_proxy "$(_read "$env_dir/proxy" "")")
2363
2397
 
2364
2398
  # Resolve version
2365
2399
  local ver; ver=$(_read "$env_dir/version" "")
@@ -2564,7 +2598,8 @@ cmd_check() {
2564
2598
  fi
2565
2599
  fi
2566
2600
  else
2567
- 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")
2568
2603
  fi
2569
2604
 
2570
2605
  # TUN conflict detection
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-cac",
3
- "version": "1.5.4",
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"