mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 18:19:57 +00:00
TUN-6696: Refactor flow into funnel and close idle funnels
A funnel is an abstraction for 1 source to many destinations. As part of this refactoring, shared logic between Darwin and Linux are moved into icmp_posix
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
//go:build linux
|
||||
|
||||
package ingress
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
"net/netip"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cloudflare/cloudflared/packet"
|
||||
)
|
||||
|
||||
func TestCloseIdleFlow(t *testing.T) {
|
||||
const (
|
||||
echoID = 19234
|
||||
idleTimeout = time.Millisecond * 100
|
||||
)
|
||||
conn, err := newICMPConn(localhostIP)
|
||||
require.NoError(t, err)
|
||||
flow := packet.Flow{
|
||||
Src: netip.MustParseAddr("172.16.0.1"),
|
||||
}
|
||||
icmpFlow := newICMPFlow(conn, &flow, echoID, &noopLogger)
|
||||
shutdownC := make(chan struct{})
|
||||
flowErr := make(chan error)
|
||||
go func() {
|
||||
flowErr <- icmpFlow.serve(shutdownC, idleTimeout)
|
||||
}()
|
||||
|
||||
require.Equal(t, errFlowInactive, <-flowErr)
|
||||
}
|
||||
|
||||
func TestCloseConnStopFlow(t *testing.T) {
|
||||
const (
|
||||
echoID = 19234
|
||||
)
|
||||
conn, err := newICMPConn(localhostIP)
|
||||
require.NoError(t, err)
|
||||
flow := packet.Flow{
|
||||
Src: netip.MustParseAddr("172.16.0.1"),
|
||||
}
|
||||
icmpFlow := newICMPFlow(conn, &flow, echoID, &noopLogger)
|
||||
shutdownC := make(chan struct{})
|
||||
conn.Close()
|
||||
|
||||
err = icmpFlow.serve(shutdownC, defaultCloseAfterIdle)
|
||||
require.True(t, errors.Is(err, net.ErrClosed))
|
||||
}
|
Reference in New Issue
Block a user