tailscale.comtailscale.com/types/nettype Index | Files

package nettype

import "tailscale.com/types/nettype"

Package nettype defines an interface that doesn't exist in the Go net package.

Index

Types

type ConnPacketConn

type ConnPacketConn interface {
	net.Conn
	net.PacketConn
}

ConnPacketConn is the interface that's a superset of net.Conn and net.PacketConn.

type PacketConn

type PacketConn interface {
	WriteToUDPAddrPort([]byte, netip.AddrPort) (int, error)
	ReadFromUDPAddrPort([]byte) (int, netip.AddrPort, error)
	io.Closer
	LocalAddr() net.Addr
	SetDeadline(time.Time) error
	SetReadDeadline(time.Time) error
	SetWriteDeadline(time.Time) error
}

PacketConn is like a net.PacketConn but uses the newer netip.AddrPort write/read methods.

type PacketListener

type PacketListener interface {
	ListenPacket(ctx context.Context, network, address string) (net.PacketConn, error)
}

PacketListener defines the ListenPacket method as implemented by net.ListenConfig, net.ListenPacket, and tstest/natlab.

type PacketListenerWithNetIP

type PacketListenerWithNetIP interface {
	ListenPacket(ctx context.Context, network, address string) (PacketConn, error)
}

func MakePacketListenerWithNetIP

func MakePacketListenerWithNetIP(ln PacketListener) PacketListenerWithNetIP

type Std

type Std struct{}

Std implements PacketListener using the Go net package's ListenPacket func.

func (Std) ListenPacket

func (Std) ListenPacket(ctx context.Context, network, address string) (net.PacketConn, error)

Source Files

nettype.go

Version
v1.84.0 (latest)
Published
May 21, 2025
Platform
linux/amd64
Imports
5 packages
Last checked
1 day ago

Tools for package owners.