mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-12-03 04:11:51 +08:00
- Route external TCP/53 through netstack deferred handshake and real-target DNS inspection (RFC 7766 single-write framing) instead of hijacking to host DNS. - Preserve explicit targetServer in ProcessDNSQueryToTarget under upstream proxy so external UDP/53 probes never fall back to host DNSUpstream. - Default error traffic storage (net_flows/dns_queries action=error) to off with hot-toggle controls synced across gateway, Proxy & Egress, and Traffic pages. - Restore json.Unmarshal in spawn_task orchestration tool and poll live sandbox container state in chat/task controls.
48 lines
1.5 KiB
Go
48 lines
1.5 KiB
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestToolSpawnTaskUnmarshalsInput(t *testing.T) {
|
|
s := &Server{m: &Manager{tasks: map[string]*Task{}}}
|
|
tool := s.toolSpawnTask()
|
|
|
|
t.Run("missing goal rejected", func(t *testing.T) {
|
|
res, err := tool.Call(context.Background(), json.RawMessage(`{"description":"端口探测"}`), nil)
|
|
if err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
if !res.IsError || !strings.Contains(res.Flatten(), "goal 为必填") {
|
|
t.Fatalf("expected goal required error, got isError=%v text=%q", res.IsError, res.Flatten())
|
|
}
|
|
})
|
|
|
|
t.Run("invalid json rejected", func(t *testing.T) {
|
|
res, err := tool.Call(context.Background(), json.RawMessage(`{invalid`), nil)
|
|
if err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
if !res.IsError || !strings.Contains(res.Flatten(), "参数无效") {
|
|
t.Fatalf("expected invalid json error, got isError=%v text=%q", res.IsError, res.Flatten())
|
|
}
|
|
})
|
|
|
|
t.Run("valid goal parsed past required check", func(t *testing.T) {
|
|
res, err := tool.Call(context.Background(), json.RawMessage(`{
|
|
"description": "47.116.200.74 端口探测",
|
|
"goal": "仅对 47.116.200.74 做端口探测",
|
|
"source_task_ids": ["99999"]
|
|
}`), nil)
|
|
if err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
if !res.IsError || !strings.Contains(res.Flatten(), "关联任务 #99999 不存在") {
|
|
t.Fatalf("expected source_task_ids check after parsing goal, got isError=%v text=%q", res.IsError, res.Flatten())
|
|
}
|
|
})
|
|
}
|