core

package
v1.1.20 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SPool = &sync.Pool{
		New: func() interface{} {
			return make([]byte, config.SmallBufferSize)
		},
	}
	MPool = &sync.Pool{
		New: func() interface{} {
			return make([]byte, config.MediumBufferSize)
		},
	}
	LPool = &sync.Pool{
		New: func() interface{} {
			return make([]byte, config.LargeBufferSize)
		},
	}
)
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 Server8422, _ = net.ResolveUDPAddr("udp", "127.0.0.1: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 Handler

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

func TCPHandler

func TCPHandler() Handler

TCPHandler creates a server 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 Server

type Server struct {
	Listener net.Listener
	Handler  Handler
}

func (*Server) Serve

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

Serve serves as a proxy server.

type Transporter

type Transporter interface {
	Dial(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