Documentation
¶
Overview ¶
Package sockettest provides an unprivileged, in-process harness for the wsvpn data path: real socket adapters talking over loopback, attached to fake TUN/TAP devices instead of kernel interfaces.
Index ¶
- Constants
- Variables
- func NewAdapterPair(tb testing.TB, transport string) (server adapters.SocketAdapter, client adapters.SocketAdapter)
- func NewSocketPair(tb testing.TB, opts PairOptions) (server *Peer, client *Peer)
- func SelfSignedTLS(tb testing.TB) (serverConfig *tls.Config, clientConfig *tls.Config)
- type FakeTun
- type PairOptions
- type Peer
Constants ¶
const ( TransportWS = "ws" TransportWSS = "wss" TransportWebTransport = "webtransport" )
Transport names accepted by NewAdapterPair.
Variables ¶
var ErrTimeout = errors.New("timed out waiting for packet")
var Transports = []string{TransportWS, TransportWSS, TransportWebTransport}
Functions ¶
func NewAdapterPair ¶
func NewAdapterPair(tb testing.TB, transport string) (server adapters.SocketAdapter, client adapters.SocketAdapter)
NewAdapterPair connects a server and a client adapter over loopback using the given transport. Everything is torn down via tb.Cleanup.
func NewSocketPair ¶
func NewSocketPair(tb testing.TB, opts PairOptions) (server *Peer, client *Peer)
NewSocketPair connects two sockets over the configured transport, each with a fake TUN device attached, and waits until both completed version negotiation and are ready to pass data.
Types ¶
type FakeTun ¶
type FakeTun struct {
Out chan []byte
// contains filtered or unexported fields
}
FakeTun stands in for a kernel TUN/TAP device. Packets passed to Inject are returned from Read (as if the kernel routed them into the tunnel); packets the socket writes to the device are delivered to Out.
func NewFakeTun ¶
func NewFakeTun() *FakeTun
func (*FakeTun) Wrapper ¶
func (f *FakeTun) Wrapper() *iface.WaterInterfaceWrapper
Wrapper returns an interface wrapper backed by this fake device.