core

package
v1.1.30 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxSize   = 1024
	MaxThread = 10
)

Variables

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")
)
View Source
var (
	// RouteNAT Globe route table for inner ip
	RouteNAT = NewNAT()
)
View Source
var Server8422, _ = net.ResolveUDPAddr("udp", "localhost:8422")

Functions

func TCPListener

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

Types

type Chain

type Chain struct {
	Retries int
	// 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 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
}

type Device

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

func (*Device) Close

func (d *Device) Close()

func (*Device) Start

func (d *Device) Start()

type Handler

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

func TCPHandler

func TCPHandler() Handler

func TunHandler

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

TunHandler creates a handler for tun tunnel.

type NAT

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

func NewNAT

func NewNAT() *NAT

func (*NAT) LoadOrStore

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

func (*NAT) Range

func (n *NAT) Range(f func(key string, v []net.Addr))

func (*NAT) Remove

func (n *NAT) Remove(ip net.IP, addr net.Addr)

func (*NAT) RemoveAddr

func (n *NAT) RemoveAddr(addr net.Addr) (count int)

func (*NAT) RouteTo

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

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 Server

type Server struct {
	Listener net.Listener
	Handler  Handler
}

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