diff --git a/scripts/libs/set_proxy.sh b/scripts/libs/set_proxy.sh new file mode 100644 index 00000000..44a083bb --- /dev/null +++ b/scripts/libs/set_proxy.sh @@ -0,0 +1,8 @@ + +setproxy(){ + [ -n "$(pidof CrashCore)" ] && { + [ -n "$authentication" ] && auth="$authentication@" + [ -z "$mix_port" ] && mix_port=7890 + export https_proxy="http://${auth}127.0.0.1:$mix_port" + } +} \ No newline at end of file diff --git a/scripts/libs/web_json.sh b/scripts/libs/web_json.sh new file mode 100644 index 00000000..5521733d --- /dev/null +++ b/scripts/libs/web_json.sh @@ -0,0 +1,18 @@ +. "$CRASHDIR"/libs/set_proxy.sh +#$1:目标地址 $2:json字符串 +web_json_get() { + setproxy + if curl --version >/dev/null 2>&1; then + curl -ksSl --connect-timeout 3 "$1" 2>/dev/null + else + wget -Y on -q --timeout=3 -O - "$1" + fi +} +web_json_post() { + setproxy + if curl --version >/dev/null 2>&1; then + curl -ksSl -X POST --connect-timeout 3 -H "Content-Type: application/json; charset=utf-8" "$1" -d "$2" >/dev/null 2>&1 + else + wget -Y on -q --timeout=3 --method=POST --header="Content-Type: application/json; charset=utf-8" --body-data="$2" "$1" + fi +}