chore: init SIP research repo (Asterisk & LiveKit)

This commit is contained in:
杨豪
2026-08-31 13:46:57 +08:00
commit 5a54d9fa0c
23 changed files with 1594 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
#!/bin/bash
# 端到端外呼验证: mock-agent(ARI+RTP) → Asterisk → PJSIP trunk → mock-provider(应答) → 双向 RTP 统计
# 用法: ./call.sh [被叫号码] [时长秒] [asterisk节点 1|2]
set -euo pipefail
cd "$(dirname "$0")/.."
NUMBER="${1:-+15105550123}"
DURATION="${2:-15}"
NODE="${3:-1}"
NET="asterisk-ari_astari"
NAME="mock-agent-$$"
docker run --rm --name "$NAME" --network "$NET" \
-v "$PWD/mock:/app/mock:ro" -w /app \
python:3.12-alpine python mock/mock-agent.py \
--ari-base "http://asterisk${NODE}:8088" \
--external-host "${NAME}:40001" \
--number "$NUMBER" --duration "$DURATION"
+44
View File
@@ -0,0 +1,44 @@
#!/bin/bash
# 运行状态检测: 容器 + ARI REST + PJSIP trunk 探活(qualify) + 活动呼叫数
set -uo pipefail
USER="outbound"; SECRET="ari_mock_7c3f9e1b5a2d4806"
ok=0; fail=0
pass() { echo "PASS $1"; ok=$((ok+1)); }
faill() { echo "FAIL $1"; fail=$((fail+1)); }
running() { [ -n "$(docker ps -q -f name=$1)" ]; }
echo "== 容器状态"
docker ps --filter "name=ast" --format "{{.Names}}\t{{.Status}}"
echo "== ARI REST"
for n in "ast1 8088" "ast2 8089"; do
set -- $n
if running "$1"; then
c=$(curl -s -o /dev/null -w "%{http_code}" -u "$USER:$SECRET" --max-time 3 "http://127.0.0.1:$2/ari/asterisk/info")
[ "$c" = 200 ] && pass "$1 ARI /asterisk/info ($c)" || faill "$1 ARI /asterisk/info ($c)"
else
echo "SKIP $1 (未运行)"
fi
done
echo "== PJSIP trunk 探活 (OPTIONS qualify)"
for c in ast1 ast2; do
if running "$c"; then
out=$(docker exec "$c" asterisk -rx "pjsip show contacts" 2>/dev/null | grep mock-provider) || true
if echo "$out" | grep -q "Avail"; then
pass "$c trunk mock-provider Avail"
else
faill "$c trunk mock-provider (contact: ${out:-none})"
fi
fi
done
echo "== 活动呼叫 (ARI channels)"
if running ast1; then
n=$(curl -s -u "$USER:$SECRET" --max-time 3 http://127.0.0.1:8088/ari/channels | python3 -c 'import json,sys; print(len(json.load(sys.stdin)))' 2>/dev/null)
[ -n "$n" ] && pass "ast1 active channels=$n" || faill "ast1 active channels"
fi
echo
echo "result: ok=$ok fail=$fail"
[ $fail -eq 0 ]