netproxy

package
v0.0.0-...-b6031a6 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2025 License: AGPL-3.0 Imports: 14 Imported by: 6

Documentation

Index

Constants

View Source
const MagicNetworkType = 0

Variables

View Source
var (
	DialTimeout = 10 * time.Second
)
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

func NewDialTimeoutContext

func NewDialTimeoutContext() (context.Context, context.CancelFunc)

func NewDialTimeoutContextFrom

func NewDialTimeoutContextFrom(ctx context.Context) (context.Context, context.CancelFunc)

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
}

type Dialer

type Dialer interface {
	DialContext(ctx context.Context, network, 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 interface {
	net.PacketConn
	net.Conn
}

func NewFakeNetPacketConn

func NewFakeNetPacketConn(conn PacketConn, LAddr net.Addr, RAddr net.Addr) FakeNetPacketConn

type FullConn

type FullConn interface {
	Conn
	PacketConn
}

type MagicNetwork

type MagicNetwork struct {
	Network string
	Mark    uint32
	Mptcp   bool
}

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
}

type ReadWrapper

type ReadWrapper struct {
	ReadFunc func([]byte) (int, error)
}

func (*ReadWrapper) Read

func (r *ReadWrapper) Read(p []byte) (n int, err error)

Read implements io.Reader.

Jump to

Keyboard shortcuts

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