Add isolated SIP call tool, optional debug capture and split interface schemas

This commit is contained in:
2026-10-08 12:44:45 +08:00
parent 98b3fd469d
commit 385bda0822
49 changed files with 3688 additions and 28 deletions
+28
View File
@@ -0,0 +1,28 @@
package rpc
import (
"context"
"git.ipao.vip/rogee/go-sip/internal/asterisk"
"testing"
"time"
)
func TestRealCallDebugControlsExternalEvidenceOnly(t *testing.T) {
for _, debug := range []bool{false, true} {
t.Run(map[bool]string{false: "normal", true: "debug"}[debug], func(t *testing.T) {
fixture, _, _, _, approved := recordedMockFixture(t, nil, time.Second)
approved.CallerID, approved.DialedCallee, approved.RingTimeout = "BD93205882", "7089"+approved.Callee, time.Second
r := &ApprovedRecordedRealCall{Debug: debug, Mirror: asterisk.NewHEPMirror(), MaxWAVBytes: 4096, MediaPayloadType: 118, ReportTimeout: time.Second, Delivery: fixture.Delivery, originator: func(ctx context.Context, _ asterisk.NativeDial) (realMedia, error) {
t.Fatal("prepare must not dial")
return realMedia{}, nil
}}
_, err := r.Prepare(approved)
if debug && err == nil {
t.Fatal("debug must reject missing capture before accepting execution")
}
if !debug && err != nil {
t.Fatalf("normal calls must not depend on tcpdump: %v", err)
}
})
}
}
+4 -1
View File
@@ -24,6 +24,7 @@ type ApprovedRecordedRealCall struct {
Loader asterisk.Loader
MediaPayloadType uint8
EvidenceRoot string
Debug bool
MaxWAVBytes int64
ReportTimeout time.Duration
Delivery *agent.RecordingDelivery
@@ -61,6 +62,8 @@ func (r *ApprovedRecordedRealCall) Prepare(approved ApprovedExecution) (func(con
if r.Loader.ConfigDir == "" || r.Loader.Asterisk == "" || r.Loader.LibraryDir == "" {
return nil, errors.New("native Asterisk configuration required for real call")
}
}
if r.Debug {
if err := verifyCallEvidence(r.EvidenceRoot, approved.SourceEventID, approved.SelectedTrunkID, approved.Callee); err != nil {
return nil, err
}
@@ -103,7 +106,7 @@ func (r *ApprovedRecordedRealCall) Prepare(approved ApprovedExecution) (func(con
if ctx == nil || ctx.Err() != nil || !time.Now().Before(approved.DialBefore) {
return errors.New("real call instruction expired or cancelled before origination")
}
if r.originator == nil {
if r.Debug {
if err := verifyCallEvidence(r.EvidenceRoot, approved.SourceEventID, approved.SelectedTrunkID, approved.Callee); err != nil {
return err
}