MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / TestUnified_TransparentOnlyNoTLSConfig

Function TestUnified_TransparentOnlyNoTLSConfig

internal/sniproxy/unified_test.go:81–111  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

79}
80
81func TestUnified_TransparentOnlyNoTLSConfig(t *testing.T) {
82 // 只有透明路由时不需要 TLSConfig
83 backend := startEchoTLS(t, "x.example.com")
84 proxy := &UnifiedProxy{Addr: "127.0.0.1:0"}
85 proxy.SetRoutes([]Route{{SNI: "x.example.com", Backend: backend, Mode: ModeTransparent}})
86
87 ln, _ := net.Listen("tcp", "127.0.0.1:0")
88 addr := ln.Addr().String()
89 _ = ln.Close()
90 proxy.Addr = addr
91
92 ctx, cancel := context.WithCancel(context.Background())
93 defer cancel()
94 var wg sync.WaitGroup
95 wg.Add(1)
96 go func() { defer wg.Done(); _ = proxy.Serve(ctx) }()
97 t.Cleanup(func() { cancel(); wg.Wait() })
98
99 waitForListen(t, addr)
100
101 conn, err := net.Dial("tcp", addr)
102 if err != nil {
103 t.Fatal(err)
104 }
105 defer conn.Close()
106 tc := tls.Client(conn, &tls.Config{ServerName: "x.example.com", InsecureSkipVerify: true})
107 _ = tc.SetDeadline(time.Now().Add(3 * time.Second))
108 if err := tc.Handshake(); err != nil {
109 t.Fatalf("handshake: %v", err)
110 }
111}
112
113func TestUnified_HotReloadSwitchesMode(t *testing.T) {
114 // 先配成透明,再热切到终止

Callers

nothing calls this directly

Calls 11

SetRoutesMethod · 0.95
ServeMethod · 0.95
startEchoTLSFunction · 0.85
waitForListenFunction · 0.85
AddrMethod · 0.80
AddMethod · 0.80
CleanupMethod · 0.80
DialMethod · 0.80
CloseMethod · 0.65
DoneMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected