-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxyfix
More file actions
executable file
·95 lines (84 loc) · 2.23 KB
/
Copy pathproxyfix
File metadata and controls
executable file
·95 lines (84 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env bash
# proxyfix — unified Clash proxy detect & fix tool
set -euo pipefail
# Resolve symlink: BASH_SOURCE[0] may be ~/.local/bin/proxyfix
_src="${BASH_SOURCE[0]}"
while [[ -L $_src ]]; do
_dir=$(cd "$(dirname "$_src")" && pwd)
_src=$(readlink "$_src")
[[ $_src != /* ]] && _src="${_dir}/${_src}"
done
PROXYFIX_ROOT=$(cd "$(dirname "$_src")" && pwd)
export PROXYFIX_ROOT
usage() {
cat <<EOF
Usage: proxyfix [command] [options]
Commands:
fix Detect and repair proxy issues (default)
detect Check only; exit 1 if broken
status Human-readable status report
test Connectivity smoke tests
download URL Smart download (direct-first for large CDN files)
Options:
--quiet Minimal output (for systemd/hooks)
--app NAME Limit fix to: all|clash|cursor|steam|shell|pacman|discord
Examples:
proxyfix fix
proxyfix detect
proxyfix fix --app steam
proxyfix download https://example.com/file.bin
EOF
}
CMD="${1:-fix}"
shift || true
QUIET=""
APP_FILTER="all"
while [[ $# -gt 0 ]]; do
case "$1" in
--quiet|-q) QUIET=1; export QUIET ;;
--app) APP_FILTER="${2:?}"; shift ;;
-h|--help) usage; exit 0 ;;
*) break ;;
esac
shift
done
export APP_FILTER
# shellcheck source=lib/common.sh
source "${PROXYFIX_ROOT}/lib/common.sh"
case "$CMD" in
fix|"")
bash "${PROXYFIX_ROOT}/lib/fix.sh"
;;
detect)
bash "${PROXYFIX_ROOT}/lib/detect.sh"
;;
status)
bash "${PROXYFIX_ROOT}/lib/detect.sh" || true
printf '\n--- Shell ---\n'
if [[ -f $PROXY_SH ]]; then
# shellcheck source=/dev/null
source "$PROXY_SH"
proxy_status 2>/dev/null || true
fi
printf '\nPort: %s\n' "$(mixed_port)"
;;
test)
bash "${HOME}/.cursor/tools/test-network.sh" 2>/dev/null || {
curl -sS --max-time 10 -o /dev/null -w 'google: %{http_code}\n' https://www.google.com
curl -sS --max-time 10 -o /dev/null -w 'cursor: %{http_code}\n' https://api2.cursor.sh
}
;;
download)
URL="${1:?URL required}"
OUT="${2:-}"
exec bash "${PROXYFIX_ROOT}/bin/proxyfix-download" "$URL" ${OUT:+"$OUT"}
;;
help|-h|--help)
usage
;;
*)
echo "Unknown command: $CMD" >&2
usage >&2
exit 1
;;
esac