netproxy

package
v0.0.0-...-e5d0cd3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MagicNetworkType = 0

Variables

View Source
var SoMark = func(fd int, mark int) error {
	if err := syscall.SetsockoptInt(fd, syscall.SOL_SOCKET, fwmarkIoctl, mark); err != nil {
		return err
	}
	return nil
}

SoMark is replacable. Replacibility is useful for Android.

View Source
var SoMarkControl = func(c syscall.RawConn, mark int) error {
	var sockOptErr error
	controlErr := c.Control(func(fd uintptr) {
		err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, fwmarkIoctl, mark)
		if err != nil {
			sockOptErr = fmt.Errorf("error setting SO_MARK socket option: %w", err)
		}
	})
	if controlErr != nil {
		return fmt.Errorf("error invoking socket control function: %w", controlErr)
	}
	return sockOptErr
}

SoMarkControl is replacable. Replacibility is useful for Android.

View Source
var (
	UnknownMagicNetworkEncodingError = fmt.Errorf("unknown magic network encoding")
)
View Source
var UnsupportedTunnelTypeError = net.UnknownNetworkError("unsupported tunnel type")

Functions

This section is empty.

Types

type Conn

type Conn interface {
	Read(b []byte) (n int, err error)
	Write(b []byte) (n int, err error)
	Close() error
	SetDeadline(t time.Time) error
	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error
}

func DialContext

func DialContext(ctx context.Context, network, addr string, dial func(network, addr string) (Conn, error)) (Conn, error)

type ContextDialer

type ContextDialer interface {
	Dial(network string, addr string) (c Conn, err error)
	DialContext(ctx context.Context, network, addr string) (c Conn, err error)
}

type ContextDialerConverter

type ContextDialerConverter struct {
	Dialer
}

func (*ContextDialerConverter) DialContext

func (d *ContextDialerConverter) DialContext(ctx context.Context, network, addr string) (c Conn, err error)

type Dialer

type Dialer interface {
	Dial(network string, addr string) (c Conn, err error)
}

A Dialer is a means to establish a connection. Custom dialers should also implement ContextDialer.

type FakeNetConn

type FakeNetConn struct {
	Conn
	LAddr net.Addr
	RAddr net.Addr
}

func (*FakeNetConn) LocalAddr

func (conn *FakeNetConn) LocalAddr() net.Addr

func (*FakeNetConn) RemoteAddr

func (conn *FakeNetConn) RemoteAddr() net.Addr

type FakeNetPacketConn

type FakeNetPacketConn struct {
	PacketConn
	LAddr net.Addr
	RAddr net.Addr
}

func (*FakeNetPacketConn) LocalAddr

func (conn *FakeNetPacketConn) LocalAddr() net.Addr

func (*FakeNetPacketConn) ReadFrom

func (conn *FakeNetPacketConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)

func (*FakeNetPacketConn) ReadMsgUDP

func (conn *FakeNetPacketConn) ReadMsgUDP(b []byte, oob []byte) (n int, oobn int, flags int, addr *net.UDPAddr, err error)

ReadMsgUDP implements quic.OOBCapablePacketConn.

func (*FakeNetPacketConn) RemoteAddr

func (conn *FakeNetPacketConn) RemoteAddr() net.Addr

func (*FakeNetPacketConn) SetReadBuffer

func (conn *FakeNetPacketConn) SetReadBuffer(size int) error

func (*FakeNetPacketConn) SetWriteBuffer

func (conn *FakeNetPacketConn) SetWriteBuffer(size int) error

func (*FakeNetPacketConn) SyscallConn

func (conn *FakeNetPacketConn) SyscallConn() (syscall.RawConn, error)

func (*FakeNetPacketConn) WriteMsgUDP

func (conn *FakeNetPacketConn) WriteMsgUDP(b []byte, oob []byte, addr *net.UDPAddr) (n int, oobn int, err error)

WriteMsgUDP implements quic.OOBCapablePacketConn.

func (*FakeNetPacketConn) WriteTo

func (conn *FakeNetPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error)

type FullConn

type FullConn interface {
	Conn
	PacketConn
}

type MagicNetwork

type MagicNetwork struct {
	Network string
	Mark    uint32
}

func ParseMagicNetwork

func ParseMagicNetwork(network string) (mn *MagicNetwork, err error)

func (MagicNetwork) Encode

func (mn MagicNetwork) Encode() string

type PacketConn

type PacketConn interface {
	Read(b []byte) (n int, err error)
	Write(b []byte) (n int, err error)
	ReadFrom(p []byte) (n int, addr netip.AddrPort, err error)
	WriteTo(p []byte, addr string) (n int, err error)
	Close() error
	SetDeadline(t time.Time) error
	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error
}

Jump to

Keyboard shortcuts

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