tcp

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: GPL-3.0 Imports: 27 Imported by: 4

Documentation

Index

Constants

View Source
const (
	CHAIN         = "<=CHAIN=>"
	AddrMask byte = 0xf
)

Variables

View Source
var (
	SOCKS5_REPY   = []byte{0x05, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x08, 0x43}
	GLOBALTIMEOUT = 1000
	// GLOBALPROTOCOL   = "tls"
	// smuxConfig = smux.DefaultConfig()
	ServeHandle func(host string, con net.Conn)
)
View Source
var (
	PASWD              = "" /* 4544-byte string literal not displayed */
	CENTRY_SERVER_ADDR = ""
)
View Source
var (
	FrpWebsocketPath2 = "/image123124x123214_download"
	FrpWebsocketPath  = "/benchmark_1000MB.bin"
	PreDomain         = ""
)
View Source
var (
	ErrWebsocketListenerClosed = errors.New("websocket listener closed")
)

Functions

func AddConfigs

func AddConfigs(old []interface{}, new interface{}) (out []interface{})

func Average

func Average(ch chan *smux.Session, ttl int) net.Conn

func ConnectTo

func ConnectTo(protocl, dst string) (con net.Conn, err error)

func Copy

func Copy(dst io.Writer, src io.Reader) (written int64, err error)

Base -=-------------------------------------------------------------------------------------

func ExpressDial

func ExpressDial(dst string, configs ...interface{}) (con net.Conn, reply []byte, err error)

func ExpressPipeTo

func ExpressPipeTo(localConn net.Conn, remoteAddr string, configs ...interface{}) error

func ExpressSocks5ListenerTo

func ExpressSocks5ListenerTo(listenAddr string, remoteAddr string, configs ...interface{})

func GetMainDomain

func GetMainDomain(urlOrHost string) string

func ParseSocks5Header

func ParseSocks5Header(conn net.Conn) (rawaddr []byte, host string, err error)

func Pipe

func Pipe(p1, p2 net.Conn)

func SetGlobalTimeout

func SetGlobalTimeout(i int)

func SetPaswd

func SetPaswd(pas string)

func SetReadTimeout

func SetReadTimeout(c net.Conn)

func SetSocks5Handle added in v1.0.1

func SetSocks5Handle(f func(host string, con net.Conn))

func SetWriteTimeout

func SetWriteTimeout(c *net.Conn)

func Socks5ConnectedReply

func Socks5ConnectedReply(p1 net.Conn) (err error)

func Socks5HandShake

func Socks5HandShake(conn net.Conn) (err error)

func Socks5Padding

func Socks5Padding(payload string, ports ...int) []byte

func Socks5Serve

func Socks5Serve(lc net.Conn, configs ...interface{}) (err error)

func SplitAddr

func SplitAddr(addr string) (h string, port int)

func T

func T(i ...interface{})

func TcpEnd

func TcpEnd(toDst string, conFrom net.Conn, midledata []byte) error

func UpdateConfig

func UpdateConfig(old, new *Config)

UpdateConfig : Useful for command line to override options specified in config file Debug is not updated.

func UpdateSession

func UpdateSession(proxy string, con *smux.Session)

func WithASession

func WithASession(protocol, proxy string, chs chan *smux.Session) (*smux.Session, error)

func WrapCloseNotifyConn

func WrapCloseNotifyConn(c net.Conn, closeFn func()) net.Conn

closeFn will be only called once

Types

type CloseNotifyConn

type CloseNotifyConn struct {
	net.Conn
	// contains filtered or unexported fields
}

func (*CloseNotifyConn) Close

func (cc *CloseNotifyConn) Close() (err error)

type Config

type Config struct {
	Server       interface{} `json:"server"`
	ServerPort   int         `json:"server_port"`
	LocalPort    int         `json:"local_port"`
	LocalAddress string      `json:"local_address"`
	Password     string      `json:"password"`
	Method       string      `json:"method"` // encryption method

	// following options are only used by server
	PortPassword map[string]string `json:"port_password"`
	Timeout      int               `json:"timeout"`

	// The order of servers in the client config is significant, so use array
	// instead of map to preserve the order.
	ServerPassword string `json:"server_password"`
}

func ParseConfig

func ParseConfig(path string) (config *Config, err error)

ParseConfig parse path to json

func ParseURI

func ParseURI(u string) (config *Config)

func (*Config) GetServerArray

func (config *Config) GetServerArray() []string

GetServerArray get server

func (*Config) ToCertAndKey

func (config *Config) ToCertAndKey(name string) (crt_key_paths []string)

will cache to locl file syste,with ${tmp}/name.crt | ${tmp}/name.key

func (*Config) ToFile

func (config *Config) ToFile(dst string) (err error)

func (*Config) ToJson

func (config *Config) ToJson() string

func (*Config) ToString

func (config *Config) ToString() string

func (*Config) ToTlsConfig

func (config *Config) ToTlsConfig() (tlsConfig *TlsConfig, err error)

func (*Config) ToUri

func (config *Config) ToUri() string

type ExpressListener

type ExpressListener struct {
	Sessions chan *smux.Session
	// contains filtered or unexported fields
}

func ExpressListenWith

func ExpressListenWith(addr string, configs ...interface{}) (lst *ExpressListener, err error)

func (*ExpressListener) Accept

func (expressLst *ExpressListener) Accept() (con net.Conn, err error)

func (*ExpressListener) Addr

func (expressLst *ExpressListener) Addr() net.Addr

Addr returns the listener's network address.

func (*ExpressListener) Backend

func (lst *ExpressListener) Backend()

func (*ExpressListener) Close

func (expressLst *ExpressListener) Close() error

Close closes the listener. Any blocked Accept operations will be unblocked and return errors.

type TlsConfig

type TlsConfig struct {
	Ca     x509.CertPool
	Cert   tls.Certificate
	Server string
	// contains filtered or unexported fields
}

func UseDefaultTlsConfig

func UseDefaultTlsConfig(addr string) (tlsConfig *TlsConfig)

func (*TlsConfig) GenerateConfig

func (tlsConfig *TlsConfig) GenerateConfig() (config tls.Config)

func (*TlsConfig) WithConn

func (tlsConfig *TlsConfig) WithConn() (conn *tls.Conn, err error)

func (*TlsConfig) WithTlsListener

func (tlsConfig *TlsConfig) WithTlsListener() (listenr net.Listener, err error)

type WebsocketListener

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

func NewWebsocketListener

func NewWebsocketListener(ln net.Listener, certFile_keyFile ...string) (wl *WebsocketListener)

NewWebsocketListener to handle websocket connections ln: tcp listener for websocket connections

func UseWebSocketListener

func UseWebSocketListener(listenAddr string, useTls bool) (*WebsocketListener, error)

func (*WebsocketListener) Accept

func (p *WebsocketListener) Accept() (net.Conn, error)

func (*WebsocketListener) Addr

func (p *WebsocketListener) Addr() net.Addr

func (*WebsocketListener) Close

func (p *WebsocketListener) Close() error

Directories

Path Synopsis
Package websocket implements a client and server for the WebSocket protocol as specified in RFC 6455.
Package websocket implements a client and server for the WebSocket protocol as specified in RFC 6455.

Jump to

Keyboard shortcuts

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