mirror of
https://github.com/nxtrace/NTrace-core.git
synced 2026-11-27 23:23:47 +00:00
保留完整 8 位 TOS 参数,传播初始化失败,修复 Linux 策略路由选源与 MTR socket 轮换,并为 Windows 非零 ICMPv4 TOS 使用 WinDivert。补齐三平台抓包、Linux 隔离路由验收及平台文档。
28 lines
741 B
Go
28 lines
741 B
Go
//go:build linux && !android
|
|
|
|
package server
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"net"
|
|
"testing"
|
|
|
|
"github.com/nxtrace/NTrace-core/trace"
|
|
)
|
|
|
|
func TestTOSRouteUsesHTTPRequestContext(t *testing.T) {
|
|
previous := traceDomainLookupFn
|
|
t.Cleanup(func() { traceDomainLookupFn = previous })
|
|
traceDomainLookupFn = func(context.Context, string, string, string, bool) (net.IP, error) {
|
|
return net.ParseIP("127.0.0.1"), nil
|
|
}
|
|
ctx, cancel := context.WithCancel(t.Context())
|
|
cancel()
|
|
tos := 184
|
|
_, _, err := prepareTrace(ctx, traceRequest{Target: "127.0.0.1", DataProvider: "disable-geoip", TOS: &tos})
|
|
if trace.IsInitializationError(err) || !errors.Is(err, context.Canceled) {
|
|
t.Fatalf("source route ignored request cancellation: %v", err)
|
|
}
|
|
}
|