core

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 4 more Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	AddrIPv4   uint8 = 1
	AddrIPv6         = 2
	AddrDomain       = 3
)

Variables

View Source
var (
	ErrorEmptyChain = errors.New("empty chain")
)
View Source
var (
	ErrorInvalidNode = errors.New("invalid node")
)

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, network, address string) (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 {
	Connect(ctx context.Context, conn net.Conn, network, address string) (net.Conn, error)
}

func UDPOverTCPTunnelConnector

func UDPOverTCPTunnelConnector() Connector

UDPOverTCPTunnelConnector creates a connector for UDP-over-TCP

type DatagramPacket

type DatagramPacket struct {
	Type       uint8  // [1]byte
	Host       string // [?]byte, first byte is length if it's a domain
	Port       uint16 // [2]byte
	DataLength uint16 // [2]byte
	Data       []byte // []byte
}

func NewDatagramPacket

func NewDatagramPacket(addr net.Addr, data []byte) *DatagramPacket

func ReadDatagramPacket

func ReadDatagramPacket(r io.Reader) (*DatagramPacket, error)

func (*DatagramPacket) Addr

func (addr *DatagramPacket) Addr() string

func (*DatagramPacket) Write

func (addr *DatagramPacket) Write(w io.Writer) error

type Handler

type Handler interface {
	Init(options ...HandlerOptionFunc)
	Handle(context.Context, net.Conn)
}

func TCPHandler

func TCPHandler() Handler

func TunHandler

func TunHandler(opts ...HandlerOptionFunc) Handler

type HandlerOptionFunc

type HandlerOptionFunc func(opts *HandlerOptions)

func ChainHandlerOption

func ChainHandlerOption(chain *Chain) HandlerOptionFunc

func IPRoutesHandlerOption

func IPRoutesHandlerOption(routes ...tun.IPRoute) HandlerOptionFunc

func NodeHandlerOption

func NodeHandlerOption(node *Node) HandlerOptionFunc

type HandlerOptions

type HandlerOptions struct {
	Chain    *Chain
	Node     *Node
	IPRoutes []tun.IPRoute
}

type Node

type Node struct {
	Addr      string
	Protocol  string
	Transport string
	Remote    string
	Values    url.Values
	Client    *Client
}

func ParseNode

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

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

func (*Node) Get

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

func (*Node) GetInt

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

type Server

type Server struct {
	Listener net.Listener
	Handler  Handler
}

func (*Server) Addr

func (s *Server) Addr() net.Addr

func (*Server) Close

func (s *Server) Close() error

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, h Handler) error

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