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

Function DialQuic

connection/quic.go:24–48  ·  view source on GitHub ↗
(
	ctx context.Context,
	quicConfig *quic.Config,
	tlsConfig *tls.Config,
	edgeAddr netip.AddrPort,
	localAddr net.IP,
	connIndex uint8,
	logger *zerolog.Logger,
	opts dialopts.DialOpts,
)

Source from the content-addressed store, hash-verified

22)
23
24func DialQuic(
25 ctx context.Context,
26 quicConfig *quic.Config,
27 tlsConfig *tls.Config,
28 edgeAddr netip.AddrPort,
29 localAddr net.IP,
30 connIndex uint8,
31 logger *zerolog.Logger,
32 opts dialopts.DialOpts,
33) (cfdquic.QUICConnection, error) {
34 udpConn, err := createUDPConnForConnIndex(connIndex, localAddr, edgeAddr, opts, logger)
35 if err != nil {
36 return nil, err
37 }
38
39 conn, err := quic.Dial(ctx, udpConn, net.UDPAddrFromAddrPort(edgeAddr), tlsConfig, quicConfig)
40 if err != nil {
41 // close the udp server socket in case of error connecting to the edge
42 _ = udpConn.Close()
43 return nil, &EdgeQuicDialError{Cause: err}
44 }
45
46 // wrap the session, so that the UDPConn is closed after session is closed.
47 return cfdquic.NewQUICConnection(conn, udpConn)
48}
49
50func createUDPConnForConnIndex(connIndex uint8, localIP net.IP, edgeIP netip.AddrPort, opts dialopts.DialOpts, logger *zerolog.Logger) (*net.UDPConn, error) {
51 listenNetwork := "udp"

Callers 4

serveQUICMethod · 0.92
DialQuicMethod · 0.92
testTunnelConnectionFunction · 0.85

Calls 3

DialMethod · 0.65
CloseMethod · 0.65

Tested by 2

testTunnelConnectionFunction · 0.68