lwip

package module
v0.0.0-...-af1ce48 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MTU = 1500
)

Variables

This section is empty.

Functions

func OpenTun

func OpenTun(ifn string) (io.ReadWriteCloser, error)

If NET_CAP or owner, open the tun.

Types

type CloseWriter

type CloseWriter interface {
	CloseWrite() error
}

type LWIPTun

type LWIPTun struct {
	// contains filtered or unexported fields
}

LWIPTun adapts the LWIP interfaces - in particular UDPConn

func NewTUNFD

func NewTUNFD(tunDev io.ReadWriteCloser, handler TUNHandler, udpNat UDPHandler) *LWIPTun

func (*LWIPTun) Connect

func (t *LWIPTun) Connect(conn core.UDPConn, target *net.UDPAddr) error

Called by udp_conn.newUDPConn. conn will hold a chan of packets. If err != nil - conn will be closed Else ReceiveTo will be called on each pending packet.

func (*LWIPTun) Handle

func (t *LWIPTun) Handle(conn net.Conn, target *net.TCPAddr) error

func (*LWIPTun) ReceiveTo

func (t *LWIPTun) ReceiveTo(conn core.UDPConn, data []byte, addr *net.UDPAddr) error

Will get pending packets for 'connections'. The handling of udpRecvFn: - convert srcAddr/dstAddr params - srcAddr used to construct a 'connection' - if not found - construct one.

func (*LWIPTun) WriteTo

func (t *LWIPTun) WriteTo(data []byte, dst *net.UDPAddr, src *net.UDPAddr) (int, error)

Inject a packet into the UDP stack. dst us a local address, corresponding to an open local UDP port. TODO: find con from connect, close the conn periodically

type TUNHandler

type TUNHandler interface {
	HandleTUN(conn net.Conn, target *net.TCPAddr, la *net.TCPAddr) error
}

Interface implemented by TUNHandler. Important: for android the system makes sure tun is the default route, but packets from the VPN app are excluded.

On Linux we need a similar setup. This still requires iptables to mark packets from istio-proxy, and use 2 routing tables.

type TunConfig

type TunConfig struct {
	Name string

	Sniff bool

	UDPHandler UDPHandler
	TCPHandler TUNHandler
}

type UDPHandler

type UDPHandler interface {
	HandleUdp(dstAddr net.IP, dstPort uint16,
		localAddr net.IP, localPort uint16,
		data []byte)
}

Interface implemented by TUNHandler.

type UdpWriter

type UdpWriter interface {
	WriteTo(data []byte, dstAddr *net.UDPAddr, srcAddr *net.UDPAddr) (int, error)
}

UdpWriter is the interface implemented by the TunTransport, to send packets back to the virtual interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL