fix(traffic,server,sandbox): fix TCP/53 false positives, add error-traffic storage toggle, and fix spawn_task/sandbox polling

- 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.
This commit is contained in:
ji ruo committed 2026-12-02 15:17:42 +08:00
1 parent 07309e4530
commit d5926d6420
22 files changed
+1189 -101

No files matched your search

+15
View File
@@ -42,6 +42,7 @@ type GatewayPolicySnapshot struct {
PassthroughHosts []string `json:"passthrough_hosts,omitempty"`
UDPPolicy string `json:"udp_policy"`
DNSUpstream string `json:"dns_upstream,omitempty"`
StoreErrorTraffic bool `json:"store_error_traffic"`
}
// GatewayEventBatch is posted by artex-gateway to POST /api/internal/gateway/events.
@@ -65,6 +66,7 @@ type RemotePolicyState struct {
passthroughHosts map[string]struct{}
udpPolicy string
dnsUpstream string
storeErrorTraffic bool
dnsCache *dnsReverseCache
gatewayToken string
onNetFlow func(NetFlowRecord)
@@ -171,6 +173,7 @@ func (s *RemotePolicyState) Apply(snap GatewayPolicySnapshot) {
s.passthroughHosts = pass
s.udpPolicy = NormalizeUDPPolicy(snap.UDPPolicy)
s.dnsUpstream = strings.TrimSpace(snap.DNSUpstream)
s.storeErrorTraffic = snap.StoreErrorTraffic
s.mu.Unlock()
}
@@ -253,12 +256,18 @@ func (s *RemotePolicyState) RememberDNS(ip, domain string) {
}
func (s *RemotePolicyState) RecordNetFlow(rec NetFlowRecord) {
if strings.EqualFold(strings.TrimSpace(rec.Action), "error") && !s.StoreErrorTraffic() {
return
}
if s.onNetFlow != nil {
s.onNetFlow(rec)
}
}
func (s *RemotePolicyState) RecordDNSQuery(rec DNSQueryRecord) {
if strings.EqualFold(strings.TrimSpace(rec.Action), "error") && !s.StoreErrorTraffic() {
return
}
if s.onDNSQuery != nil {
s.onDNSQuery(rec)
}
@@ -282,6 +291,12 @@ func (s *RemotePolicyState) DNSUpstream() string {
return s.dnsUpstream
}
func (s *RemotePolicyState) StoreErrorTraffic() bool {
s.mu.RLock()
defer s.mu.RUnlock()
return s.storeErrorTraffic
}
func (s *RemotePolicyState) GatewayToken() string {
return s.gatewayToken
}