From 56f37614f47e22ce2d980e54bb2db53f8859b514 Mon Sep 17 00:00:00 2001 From: IceCodeNew <32576256+IceCodeNew@users.noreply.github.com> Date: Fri, 12 Jun 2020 12:56:53 +0800 Subject: [PATCH] Fix wrongly handling proxy parameters given to curl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 巧了,正好是我手贱把原来好好的 curl 参数顺序调乱了搞得脚本不指定代理就无法正常工作。 结果我意外因为这个发现脚本原本写的提供给 curl 的代理参数多了个空格,所以原来脚本是给了代理参数就不能正常工作的( --- ` curl '-x socks5h://1.1.1.1:9999' https://ipinfo.io ` > curl: (5) Unsupported proxy syntax in ' socks5h://1.1.1.1:9999' 注意这里报错消息里的空格。 --- install-release.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/install-release.sh b/install-release.sh index 9971d87..8c75fad 100644 --- a/install-release.sh +++ b/install-release.sh @@ -149,7 +149,7 @@ judgment_parameters() { exit 1 ;; esac - PROXY="-x $2" + PROXY="-x$2" # Parameters available through a proxy server if [[ "$#" -gt '2' ]]; then case "$3" in @@ -230,7 +230,7 @@ get_version() { # Get V2Ray release version number TMP_FILE="$(mktemp)" install_software curl - if ! curl -s "${PROXY}" -o "$TMP_FILE" https://api.github.com/repos/v2fly/v2ray-core/releases/latest; then + if ! curl ${PROXY} -s -o "$TMP_FILE" 'https://api.github.com/repos/v2fly/v2ray-core/releases/latest'; then rm "$TMP_FILE" echo 'error: Failed to get release list, please check your network.' exit 1 @@ -278,12 +278,12 @@ download_v2ray() { mkdir "$TMP_DIRECTORY" DOWNLOAD_LINK="https://github.com/v2fly/v2ray-core/releases/download/$RELEASE_VERSION/v2ray-linux-$MACHINE.zip" echo "Downloading V2Ray archive: $DOWNLOAD_LINK" - if ! curl "${PROXY}" -L -H 'Cache-Control: no-cache' -o "$ZIP_FILE" "$DOWNLOAD_LINK"; then + if ! curl ${PROXY} -L -H 'Cache-Control: no-cache' -o "$ZIP_FILE" "$DOWNLOAD_LINK"; then echo 'error: Download failed! Please check your network or try again.' return 1 fi echo "Downloading verification file for V2Ray archive: $DOWNLOAD_LINK.dgst" - if ! curl "${PROXY}" -L -H 'Cache-Control: no-cache' -o "$ZIP_FILE.dgst" "$DOWNLOAD_LINK.dgst"; then + if ! curl ${PROXY} -L -H 'Cache-Control: no-cache' -o "$ZIP_FILE.dgst" "$DOWNLOAD_LINK.dgst"; then echo 'error: Download failed! Please check your network or try again.' return 1 fi @@ -354,11 +354,11 @@ install_startup_service_file() { if [[ ! -f '/etc/systemd/system/v2ray.service' ]]; then mkdir "${TMP_DIRECTORY}systemd/system/" install_software curl - if ! curl -s "${PROXY}" -o "${TMP_DIRECTORY}systemd/system/v2ray.service" https://raw.githubusercontent.workers.dev/v2fly/fhs-install-v2ray/master/systemd/system/v2ray.service; then + if ! curl ${PROXY} -s -o "${TMP_DIRECTORY}systemd/system/v2ray.service" 'https://raw.githubusercontent.workers.dev/v2fly/fhs-install-v2ray/master/systemd/system/v2ray.service'; then echo 'error: Failed to start service file download! Please check your network or try again.' exit 1 fi - if ! curl -s "${PROXY}" -o "${TMP_DIRECTORY}systemd/system/v2ray@.service" https://raw.githubusercontent.workers.dev/v2fly/fhs-install-v2ray/master/systemd/system/v2ray@.service; then + if ! curl ${PROXY} -s -o "${TMP_DIRECTORY}systemd/system/v2ray@.service" 'https://raw.githubusercontent.workers.dev/v2fly/fhs-install-v2ray/master/systemd/system/v2ray@.service'; then echo 'error: Failed to start service file download! Please check your network or try again.' exit 1 fi