Files

25 lines
1.5 KiB
Bash
Raw Permalink Normal View History

set -u
TOKEN=$(/usr/local/bin/node /opt/dshs/mksess.cjs guest 2>&1 | tail -1)
if [ ${#TOKEN} -ne 64 ]; then echo "mksess 失败: $TOKEN"; exit 1; fi
echo "临时会话已建(token 长度 ${#TOKEN})"
echo
echo "=== [1] 平台直连 3080(Host=guest.ai1net.com,带 cookie)==="
curl -s -o /tmp/_a -w "code=%{http_code} size=%{size_download} loc=%{redirect_url}\n" --max-time 20 \
-H "Host: guest.ai1net.com" -H "Accept: text/html" -H "Cookie: sid=$TOKEN" http://127.0.0.1:3080/
head -c 120 /tmp/_a | tr -d '\n'; echo
echo
echo "=== [2] 完整链路 nginx443(--resolve 直指本机,Host=guest.ai1net.com)==="
curl -sk -o /tmp/_b -w "code=%{http_code} size=%{size_download} loc=%{redirect_url}\n" --max-time 20 \
--resolve guest.ai1net.com:443:127.0.0.1 -H "Accept: text/html" -H "Cookie: sid=$TOKEN" \
https://guest.ai1net.com/
head -c 120 /tmp/_b | tr -d '\n'; echo
echo
echo "=== [3] 旧域对照(Host=guest.alotbuy.com,同 cookie)==="
curl -sk -o /tmp/_c -w "code=%{http_code} size=%{size_download} loc=%{redirect_url}\n" --max-time 20 \
--resolve guest.alotbuy.com:443:127.0.0.1 -H "Accept: text/html" -H "Cookie: sid=$TOKEN" \
https://guest.alotbuy.com/
head -c 120 /tmp/_c | tr -d '\n'; echo
echo
echo "=== [4] 清理临时会话 ==="
sudo -u postgres psql -p 15432 -d dshs -Atc "DELETE FROM sessions WHERE user_agent='poc-curl2'" 2>&1 | grep -v 'could not change'
sudo -u postgres psql -p 15432 -d dshs -Atc "SELECT count(*) FROM sessions WHERE user_agent='poc-curl2'" 2>&1 | grep -v 'could not change'