Skip to content

Commit bd95556

Browse files
committed
chore (better way to handle PROXY args)
bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/develop/install-release.sh) -p "http://95.174.67.50:18080" 手动测试通过((( Signed-off-by: IceCodeNew <32576256+IceCodeNew@users.noreply.github.com>
1 parent 992095a commit bd95556

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

install-release.sh

+5-7
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,10 @@ judgment_parameters() {
171171
break
172172
;;
173173
'-p' | '--proxy')
174-
if ! echo "${2:?undefine var}" | grep -qEo '^(https?|socks4a?|socks5h?):\/\/'; then
175-
echo 'error: Please specify the correct proxy server address.'
174+
if [[ -z "${2:?error: Please specify the proxy server address.}" ]]; then
176175
exit 1
177176
fi
178-
PROXY="-x$2"
177+
PROXY="$2"
179178
shift
180179
;;
181180
*)
@@ -229,8 +228,7 @@ get_version() {
229228
fi
230229
# Get V2Ray release version number
231230
TMP_FILE="$(mktemp)"
232-
# DO NOT QUOTE THESE `${PROXY}` VARIABLES!
233-
if ! curl ${PROXY} -sS -H "Accept: application/vnd.github.v3+json" -o "$TMP_FILE" 'https://api.github.com/repos/v2fly/v2ray-core/releases/latest'; then
231+
if ! curl -x "${PROXY}" -sS -H "Accept: application/vnd.github.v3+json" -o "$TMP_FILE" 'https://api.github.com/repos/v2fly/v2ray-core/releases/latest'; then
234232
"rm" "$TMP_FILE"
235233
echo 'error: Failed to get release list, please check your network.'
236234
exit 1
@@ -273,12 +271,12 @@ get_version() {
273271
download_v2ray() {
274272
DOWNLOAD_LINK="https://github.com/v2fly/v2ray-core/releases/download/$RELEASE_VERSION/v2ray-linux-$MACHINE.zip"
275273
echo "Downloading V2Ray archive: $DOWNLOAD_LINK"
276-
if ! curl ${PROXY} -R -H 'Cache-Control: no-cache' -o "$ZIP_FILE" "$DOWNLOAD_LINK"; then
274+
if ! curl -x "${PROXY}" -R -H 'Cache-Control: no-cache' -o "$ZIP_FILE" "$DOWNLOAD_LINK"; then
277275
echo 'error: Download failed! Please check your network or try again.'
278276
return 1
279277
fi
280278
echo "Downloading verification file for V2Ray archive: $DOWNLOAD_LINK.dgst"
281-
if ! curl ${PROXY} -sSR -H 'Cache-Control: no-cache' -o "$ZIP_FILE.dgst" "$DOWNLOAD_LINK.dgst"; then
279+
if ! curl -x "${PROXY}" -sSR -H 'Cache-Control: no-cache' -o "$ZIP_FILE.dgst" "$DOWNLOAD_LINK.dgst"; then
282280
echo 'error: Download failed! Please check your network or try again.'
283281
return 1
284282
fi

0 commit comments

Comments
 (0)