tunnel

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 注册
	MethodRegister = 1
	// 准备接收任务
	MethodConn = 2
)
View Source
const (
	Delim = '\n'
)

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(addr string, handler Handler) error

func LocalIP

func LocalIP() (internet net.IP, intranet net.IP)

func NewUUID added in v0.0.5

func NewUUID() string

func SetConnectTimeout

func SetConnectTimeout(conn net.Conn, readTimeout, writeTimeout time.Duration) net.Conn

Types

type Handler

type Handler interface {
	Serve(conn net.Conn)
}

A Handler of Conn

type HandlerFunc

type HandlerFunc func(conn net.Conn)

For quickly defining Handler

func (HandlerFunc) Serve

func (f HandlerFunc) Serve(conn net.Conn)

Implement Handler

type NodeInfo added in v0.0.3

type NodeInfo struct {
	Id       string `json:"id"`
	Group    string `json:"group"`
	Name     string `json:"name"`
	Password string `json:"password"`
	Cipher   string `json:"cipher"`
}

func ParseUser added in v0.2.0

func ParseUser(str string) (*NodeInfo, error)

func (*NodeInfo) Account added in v0.2.0

func (n *NodeInfo) Account() string

func (*NodeInfo) ProxyAuth added in v0.2.0

func (n *NodeInfo) ProxyAuth() (*proxy.Auth, error)

func (*NodeInfo) User added in v0.2.0

func (n *NodeInfo) User() string

type Request added in v0.0.3

type Request struct {
	ServiceId string `json:"serviceId"`
	// connect | register
	Method     int             `json:"method"`
	Attachment json.RawMessage `json:"attachment"`
}

type Server

type Server struct {
	Addr    string
	Handler Handler
}

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

func (*Server) Serve

func (s *Server) Serve(l net.Listener) error

type Session added in v0.0.3

type Session struct {
	// origin conn
	net.Conn
	// context
	Context context.Context
	// cancel
	Cancel context.CancelFunc
	// request
	*Request
	// serviceInfo
	*NodeInfo
	// logger
	Logger *logrus.Entry
}

func NewSession added in v0.0.3

func NewSession(conn net.Conn) (*Session, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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