MCPcopy
hub / github.com/cloudflare/cloudflared / quicClient

Function quicClient

quic/safe_stream_test.go:61–96  ·  view source on GitHub ↗
(t *testing.T, addr net.Addr)

Source from the content-addressed store, hash-verified

59}
60
61func quicClient(t *testing.T, addr net.Addr) {
62 tlsConf := &tls.Config{
63 InsecureSkipVerify: true,
64 NextProtos: []string{"argotunnel"},
65 }
66 ctx, cancel := context.WithCancel(context.Background())
67 defer cancel()
68 session, err := quic.DialAddr(ctx, addr.String(), tlsConf, testQUICConfig)
69 require.NoError(t, err)
70
71 var wg sync.WaitGroup
72 for exchange := 0; exchange < exchanges; exchange++ {
73 quicStream, err := session.AcceptStream(context.Background())
74 require.NoError(t, err)
75 wg.Add(1)
76
77 go func(iter int) {
78 defer wg.Done()
79
80 log := zerolog.Nop()
81 stream := NewSafeStreamCloser(quicStream, 30*time.Second, &log)
82 defer stream.Close()
83
84 // Do a bunch of round trips over this stream that should work.
85 for msg := 0; msg < msgsPerExchange; msg++ {
86 clientRoundTrip(t, stream, true)
87 }
88 // And one that won't work necessarily, but shouldn't break other streams in the session.
89 if iter%2 == 0 {
90 clientRoundTrip(t, stream, false)
91 }
92 }(exchange)
93 }
94
95 wg.Wait()
96}
97
98func quicServer(t *testing.T, serverReady *sync.WaitGroup, conn net.PacketConn) {
99 ctx, cancel := context.WithCancel(context.Background())

Callers 1

TestSafeStreamCloseFunction · 0.85

Calls 7

CloseMethod · 0.95
NewSafeStreamCloserFunction · 0.85
clientRoundTripFunction · 0.85
WaitMethod · 0.80
StringMethod · 0.65
AcceptStreamMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected