core

package
v2.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: MIT Imports: 36 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MaxSize = 1000
)

Variables

View Source
var (
	// RouteMapTCP map[srcIP]net.Conn Globe route table for inner ip
	RouteMapTCP = &sync.Map{}
	// TCPPacketChan tcp connects
	TCPPacketChan = make(chan *datagramPacket, MaxSize)
)
View Source
var (
	// ErrorEmptyChain is an error that implies the chain is empty.
	ErrorEmptyChain = errors.New("empty chain")
)
View Source
var ErrorInvalidNode = errors.New("invalid node")

Functions

func GvisorTCPListener

func GvisorTCPListener(addr string) (net.Listener, error)

func GvisorUDPListener

func GvisorUDPListener(addr string) (net.Listener, error)

func ICMPForwarder added in v2.3.1

func ICMPForwarder(s *stack.Stack, ctx context.Context) func(stack.TransportEndpointID, *stack.PacketBuffer) bool

func NewStack

func NewStack(ctx context.Context, tun stack.LinkEndpoint) *stack.Stack

func ParseProxyInfo

func ParseProxyInfo(conn net.Conn) (id stack.TransportEndpointID, err error)

ParseProxyInfo parse proxy info [20]byte

func TCPListener

func TCPListener(addr string) (net.Listener, error)

func UDPForwarder

func UDPForwarder(s *stack.Stack, ctx context.Context) func(id stack.TransportEndpointID, pkt *stack.PacketBuffer) bool

func WriteProxyInfo

func WriteProxyInfo(conn net.Conn, id stack.TransportEndpointID) error

Types

type Chain

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

func NewChain

func NewChain(retry int, node *Node) *Chain

func (*Chain) DialContext

func (c *Chain) DialContext(ctx context.Context) (conn net.Conn, err error)

func (*Chain) IsEmpty

func (c *Chain) IsEmpty() bool

func (*Chain) Node

func (c *Chain) Node() *Node

type Client

type Client struct {
	Connector
	Transporter
}

type ClientDevice

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

func (*ClientDevice) SetTunInboundHandler

func (d *ClientDevice) SetTunInboundHandler(handler func(tunInbound <-chan *DataElem, tunOutbound chan<- *DataElem))

func (*ClientDevice) Start

func (d *ClientDevice) Start(ctx context.Context)

type Connector

type Connector interface {
	ConnectContext(ctx context.Context, conn net.Conn) (net.Conn, error)
}

func UDPOverTCPTunnelConnector

func UDPOverTCPTunnelConnector() Connector

type DataElem

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

func NewDataElem

func NewDataElem(data []byte, length int, src net.IP, dst net.IP) *DataElem

func (*DataElem) Data

func (d *DataElem) Data() []byte

func (*DataElem) Length

func (d *DataElem) Length() int

type Device

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

func (*Device) Close

func (d *Device) Close()

func (*Device) SetTunInboundHandler

func (d *Device) SetTunInboundHandler(handler func(tunInbound <-chan *DataElem, tunOutbound chan<- *DataElem))

func (*Device) Start

func (d *Device) Start(ctx context.Context)

type Handler

type Handler interface {
	Handle(ctx context.Context, conn net.Conn)
}

func GvisorTCPHandler

func GvisorTCPHandler() Handler

func GvisorUDPHandler

func GvisorUDPHandler() Handler

func TCPHandler

func TCPHandler() Handler

func TunHandler

func TunHandler(chain *Chain, node *Node) Handler

TunHandler creates a handler for tun tunnel.

type Node

type Node struct {
	Addr     string
	Protocol string
	Remote   string // remote address, used by tcp/udp port forwarding
	Values   url.Values
	Client   *Client
}

func ParseNode

func ParseNode(s string) (*Node, error)

ParseNode pattern is [scheme://][user:pass@host]:port.

func (*Node) Get

func (node *Node) Get(key string) string

Get returns node parameter specified by key.

func (*Node) GetInt

func (node *Node) GetInt(key string) int

GetInt converts node parameter value to int.

type Peer

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

func (*Peer) Close

func (p *Peer) Close()

func (*Peer) Start

func (p *Peer) Start()

type Route

type Route struct {
	ServeNodes []string // -L tun
	ChainNode  string   // -F tcp
	Retries    int
}

Route example: -L "tcp://:10800" -L "tun://:8422?net=223.254.0.100/16" -L "tun:/10.233.24.133:8422?net=223.254.0.102/16&route=223.254.0.0/16" -L "tun:/127.0.0.1:8422?net=223.254.0.102/16&route=223.254.0.0/16,10.233.0.0/16" -F "tcp://127.0.0.1:10800"

func (*Route) GenerateServers

func (r *Route) GenerateServers() ([]Server, error)

type RouteMap added in v2.2.16

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

func NewRouteMap added in v2.2.16

func NewRouteMap() *RouteMap

func (*RouteMap) LoadOrStore added in v2.2.16

func (n *RouteMap) LoadOrStore(to net.IP, addr net.Addr) (result net.Addr, load bool)

func (*RouteMap) RouteTo added in v2.2.16

func (n *RouteMap) RouteTo(ip net.IP) net.Addr

type Server

type Server struct {
	Listener net.Listener
	Handler  Handler
}

type TCPUDPacket

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

type Transporter

type Transporter interface {
	Dial(ctx context.Context, addr string) (net.Conn, error)
}

func TCPTransporter

func TCPTransporter() Transporter

Jump to

Keyboard shortcuts

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