MCPcopy Index your code
hub / github.com/cloudflare/cloudflared / TestDatagram

Function TestDatagram

quic/datagram_test.go:64–114  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

62}
63
64func TestDatagram(t *testing.T) {
65 maxPayload := make([]byte, maxDatagramPayloadSize)
66 noPayloadSession := uuid.New()
67 maxPayloadSession := uuid.New()
68 sessionToPayload := []*packet.Session{
69 {
70 ID: noPayloadSession,
71 Payload: make([]byte, 0),
72 },
73 {
74 ID: maxPayloadSession,
75 Payload: maxPayload,
76 },
77 }
78
79 packets := []packet.ICMP{
80 {
81 IP: &packet.IP{
82 Src: netip.MustParseAddr("172.16.0.1"),
83 Dst: netip.MustParseAddr("192.168.0.1"),
84 Protocol: layers.IPProtocolICMPv4,
85 },
86 Message: &icmp.Message{
87 Type: ipv4.ICMPTypeTimeExceeded,
88 Code: 0,
89 Body: &icmp.TimeExceeded{
90 Data: []byte("original packet"),
91 },
92 },
93 },
94 {
95 IP: &packet.IP{
96 Src: netip.MustParseAddr("172.16.0.2"),
97 Dst: netip.MustParseAddr("192.168.0.2"),
98 Protocol: layers.IPProtocolICMPv4,
99 },
100 Message: &icmp.Message{
101 Type: ipv4.ICMPTypeEcho,
102 Code: 0,
103 Body: &icmp.Echo{
104 ID: 6182,
105 Seq: 9151,
106 Data: []byte("Test ICMP echo"),
107 },
108 },
109 },
110 }
111
112 testDatagram(t, 1, sessionToPayload, nil)
113 testDatagram(t, 2, sessionToPayload, packets)
114}
115
116func testDatagram(t *testing.T, version uint8, sessionToPayloads []*packet.Session, packets []packet.ICMP) {
117 quicConfig := &quic.Config{

Callers

nothing calls this directly

Calls 1

testDatagramFunction · 0.85

Tested by

no test coverage detected