connpool

package
v4.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2019 License: BSD-3-Clause, GPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TMPLSESS = `` /* 2445-byte string literal not displayed */

	TMPLADDR = `` /* 760-byte string literal not displayed */

)

Variables

View Source
var (
	ErrSessionNotFound = errors.New("session not found.")
	ErrNoSession       = errors.New("session in pool but can't pick one.")
	ErrAuthFailed      = errors.New("auth failed")
)
View Source
var (
	MSG_OK = []byte{0x00}
)

Functions

func PickAddr

func PickAddr(addresses string) (addr string, err error)

Types

type Client

type Client struct {
	*Pool
	Servers []*ServerDefine
	MinSess int
	MaxConn int
	// contains filtered or unexported fields
}

func NewClient

func NewClient(Servers []*ServerDefine, MinSess, MaxConn int) (cli *Client)

func (*Client) Dial

func (cli *Client) Dial(network, address string) (conn net.Conn, err error)

func (*Client) DialTimeout

func (cli *Client) DialTimeout(network, address string, timeout time.Duration) (conn net.Conn, err error)

func (*Client) Start

func (cli *Client) Start()

type LoginRequest

type LoginRequest struct {
	Username  string
	Time      int64
	Signature []byte
}

func GenLoginRequest

func GenLoginRequest(username, password string) (lreq *LoginRequest)

func (*LoginRequest) GenSignature

func (lreq *LoginRequest) GenSignature(password string) (sig []byte)

func (*LoginRequest) Verify

func (lreq *LoginRequest) Verify(password string) (ok bool)

type Pool

type Pool struct {
	Xchg common.Exchanger
	// contains filtered or unexported fields
}

func NewPool

func NewPool() (pool *Pool)

func (*Pool) Add

func (pool *Pool) Add(tun tunnel.Tunnel)

func (*Pool) CutAll

func (pool *Pool) CutAll()

func (*Pool) GetSize

func (pool *Pool) GetSize() int

func (*Pool) GetTun

func (pool *Pool) GetTun(s string) (tun tunnel.Tunnel)

func (*Pool) GetTunnels

func (pool *Pool) GetTunnels() (tuns TunSlice)

func (*Pool) HandlerCloseConn

func (pool *Pool) HandlerCloseConn(w http.ResponseWriter, req *http.Request)

func (*Pool) HandlerCloseTun

func (pool *Pool) HandlerCloseTun(w http.ResponseWriter, req *http.Request)

func (*Pool) HandlerCutoff

func (pool *Pool) HandlerCutoff(w http.ResponseWriter, req *http.Request)

func (*Pool) HandlerLookup

func (pool *Pool) HandlerLookup(w http.ResponseWriter, req *http.Request)

func (*Pool) HandlerMain

func (pool *Pool) HandlerMain(w http.ResponseWriter, req *http.Request)

func (*Pool) Register

func (pool *Pool) Register(mux *http.ServeMux)

func (*Pool) Remove

func (pool *Pool) Remove(tun tunnel.Tunnel) (err error)

func (*Pool) ServeConn

func (pool *Pool) ServeConn(conn net.Conn) (err error)

type ServerDefine

type ServerDefine struct {
	Server      string
	ServerName  string
	CryptMode   string
	RootCAs     string
	CertFile    string
	CertKeyFile string
	Cipher      string
	Key         string
	Username    string
	Password    string
	// contains filtered or unexported fields
}

func (*ServerDefine) CreateConn

func (sd *ServerDefine) CreateConn() (conn net.Conn, err error)

type TimeSignClient

type TimeSignClient struct {
	common.Dialer
	// contains filtered or unexported fields
}

func NewTimeSignClient

func NewTimeSignClient(dialer common.Dialer, username, password string) (tscli *TimeSignClient)

func (*TimeSignClient) Dial

func (tscli *TimeSignClient) Dial(network, address string) (conn net.Conn, err error)

func (*TimeSignClient) DialTimeout

func (tscli *TimeSignClient) DialTimeout(network, address string, timeout time.Duration) (conn net.Conn, err error)

func (*TimeSignClient) Handshake

func (tscli *TimeSignClient) Handshake(conn net.Conn) (err error)

type TimeSignServer

type TimeSignServer struct {
	common.Handler
	// contains filtered or unexported fields
}

func NewTimeSignServer

func NewTimeSignServer(handler common.Handler, auth *map[string]string) (tssrv *TimeSignServer)

func (*TimeSignServer) Handshake

func (tssrv *TimeSignServer) Handshake(conn net.Conn) (err error)

func (*TimeSignServer) ServeConn

func (tssrv *TimeSignServer) ServeConn(conn net.Conn) (err error)

type TunSlice

type TunSlice []tunnel.Tunnel

func (TunSlice) Len

func (ts TunSlice) Len() int

func (TunSlice) Less

func (ts TunSlice) Less(i, j int) bool

func (TunSlice) Swap

func (ts TunSlice) Swap(i, j int)

Jump to

Keyboard shortcuts

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