Skip to content

Commit

Permalink
Check GitHub API status code (#271)
Browse files Browse the repository at this point in the history
Co-authored-by: IceCodeNew <[email protected]>
  • Loading branch information
rzr8i and IceCodeNew authored Feb 20, 2023
1 parent 5b7125e commit b3cbf91
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion install-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,17 @@ get_version() {
fi
# Get V2Ray release version number
TMP_FILE="$(mktemp)"
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
if ! curl -x "${PROXY}" -sS -i -H "Accept: application/vnd.github.v3+json" -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
fi
HTTP_STATUS_CODE=$(awk 'NR==1 {print $2}' "$TMP_FILE")
if [[ $HTTP_STATUS_CODE -lt 200 ]] || [[ $HTTP_STATUS_CODE -gt 299 ]]; then
"rm" "$TMP_FILE"
echo "error: Failed to get release list, GitHub API response code: $HTTP_STATUS_CODE"
exit 1
fi
RELEASE_LATEST="$(sed 'y/,/\n/' "$TMP_FILE" | grep 'tag_name' | awk -F '"' '{print $4}')"
"rm" "$TMP_FILE"
RELEASE_VERSION="v${RELEASE_LATEST#v}"
Expand Down

0 comments on commit b3cbf91

Please sign in to comment.