TUN-6666: Define packet package

This package defines IP and ICMP packet, decoders, encoder and flow
This commit is contained in:
cthuang
2022-08-17 16:46:49 +01:00
parent 20ed7557f9
commit bad2e8e812
242 changed files with 49761 additions and 2642 deletions

View File

@@ -15,7 +15,7 @@ import (
"github.com/stretchr/testify/require"
"golang.org/x/sync/errgroup"
quicpogs "github.com/cloudflare/cloudflared/quic"
"github.com/cloudflare/cloudflared/packet"
)
var (
@@ -29,7 +29,7 @@ func TestManagerServe(t *testing.T) {
remoteUnregisterMsg = "eyeball closed connection"
)
requestChan := make(chan *quicpogs.SessionDatagram)
requestChan := make(chan *packet.Session)
transport := mockQUICTransport{
sessions: make(map[uuid.UUID]chan []byte),
}
@@ -241,9 +241,9 @@ type mockQUICTransport struct {
sessions map[uuid.UUID]chan []byte
}
func (me *mockQUICTransport) MuxSession(id uuid.UUID, payload []byte) error {
session := me.sessions[id]
session <- payload
func (me *mockQUICTransport) MuxSession(session *packet.Session) error {
s := me.sessions[session.ID]
s <- session.Payload
return nil
}
@@ -255,9 +255,9 @@ type mockEyeballSession struct {
respReceiver <-chan []byte
}
func (me *mockEyeballSession) serve(ctx context.Context, requestChan chan *quicpogs.SessionDatagram) error {
func (me *mockEyeballSession) serve(ctx context.Context, requestChan chan *packet.Session) error {
for i := 0; i < me.expectedMsgCount; i++ {
requestChan <- &quicpogs.SessionDatagram{
requestChan <- &packet.Session{
ID: me.id,
Payload: me.expectedMsg,
}