Spaces:
Sleeping
Sleeping
background request processing, no sleep loop, instant re-poll
Browse files1 unmodified line234556719 unmodified lines272829313031322 unmodified lines3536374038424344454647484950513940414243444546474849505354511 unmodified lineSERVER="https://mtsky-free-server-docker.hf.space"LOCAL_CGI="${LOCAL_CGI:-http://192.168.1.1/cgi-bin/api}"TMPDIR="/tmp/wstunnel"POLL_INTERVAL="${POLL_INTERVAL:-1}"UCLIENT="uclient-fetch -q -O - -T 10"
mkdir -p "$TMPDIR"19 unmodified lines rc=$? if [ "$rc" != "0" ] || [ -z "$resp" ] || [ "$resp" = "{}" ]; then [ "$rc" != "0" ] && log "poll rc=$rc" sleep "$POLL_INTERVAL" continue fi
2 unmodified lines
if [ -n "$rid" ] && [ -n "$url_enc" ]; then local_url="${LOCAL_CGI}?url=${url_enc}" log "request $rid" body_file="$TMPDIR/body-$rid" $UCLIENT "$local_url" > "$body_file" 2>&1 u_rc=$? if [ "$u_rc" = "0" ] && [ -s "$body_file" ]; then log "success" respond "$rid" "200" "text/html" "$body_file" & else log "local failed (rc=$u_rc)" echo "fetch failed rc=$u_rc" > "$body_file" respond "$rid" "502" "text/plain" "$body_file" & fi ( $UCLIENT "$local_url" > "$body_file" 2>&1 u_rc=$? if [ "$u_rc" = "0" ] && [ -s "$body_file" ]; then respond "$rid" "200" "text/html" "$body_file" >/dev/null 2>&1 else echo "fetch failed rc=$u_rc" > "$body_file" respond "$rid" "502" "text/plain" "$body_file" >/dev/null 2>&1 fi rm -f "$body_file" ) & fi
sleep "$POLL_INTERVAL"donetunnel_client.sh+11-15