core

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2020 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OptAdd   = 1
	OptDel   = 2
	OptReset = 3
	OptPing  = 9
)

MUCmd opt id

View Source
const (
	ResOK  = 1
	ResErr = 2
)

MURes res id

Variables

View Source
var (
	//SIP003
	ErrBrokenSIP003Args = errors.New("invalid SIP003 args")

	//smux
	ErrTooManyStreams = errors.New("opened too many streams")
)

err

Functions

func FormatSSPluginOptions

func FormatSSPluginOptions(spo string) ([]string, error)

FormatSSPluginOptions formats SS_PLUGIN_OPTIONS to command alike formation, `-s -a value`

Types

type Args added in v0.5.4

type Args struct {
	Path string `json:"path,omitempty"`
	Dst  string `json:"dst,omitempty"`
}

type Client

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

Client represents a client instance

func NewClient

func NewClient(c *ClientConfig) (*Client, error)

NewClient inits a client instance

func (*Client) Close

func (client *Client) Close() error

Close shutdown client

func (*Client) ForwardConn added in v0.5.5

func (client *Client) ForwardConn(c net.Conn) error

ForwardConn forwards this connection to server. It will block until server-side connection is closed or c is closed

func (*Client) Start

func (client *Client) Start() error

Start starts the client, it block

type ClientConfig

type ClientConfig struct {
	BindAddr   string
	RemoteAddr string

	EnableWSS    bool
	WSSPath      string
	EnableMux    bool
	MuxMaxStream int

	ServerName         string
	InsecureSkipVerify bool

	Timeout     time.Duration
	EnableTFO   bool
	VpnMode     bool
	FallbackDNS string
	Verbose     bool
}

ClientConfig is a config

type MUCmd added in v0.5.4

type MUCmd struct {
	Opt int `json:"opt,omitempty"`

	ArgsBunch []Args `json:"args_bunch,omitempty"`
}

MUCmd is a control command

type MURes added in v0.5.4

type MURes struct {
	Res          int    `json:"res,omitempty"`
	ErrString    string `json:"err_string,omitempty"`
	CurrentUsers int    `json:"current_users,omitempty"`
}

MURes is a update result

type MUServer added in v0.5.4

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

MUServer is a multi-user server

func NewMUServer added in v0.5.4

func NewMUServer(conf *MUServerConfig) (*MUServer, error)

NewMUServer init a multi-user server

func (*MUServer) CloseController added in v0.5.4

func (mus *MUServer) CloseController() error

func (*MUServer) CloseServer added in v0.5.4

func (mus *MUServer) CloseServer() error

func (*MUServer) ServeHTTP added in v0.5.4

func (mus *MUServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*MUServer) StartController added in v0.5.4

func (mus *MUServer) StartController() error

StartController starts the controller of the server

func (*MUServer) StartServer added in v0.5.5

func (mus *MUServer) StartServer() error

StartServer starts the server

type MUServerConfig added in v0.5.4

type MUServerConfig struct {
	ServerAddr         string
	ServerBindUnix     bool
	HTTPControllerAddr string

	Key        string
	Cert       string
	ServerName string
	DisableTLS bool

	EnableMux bool

	EnableTFO bool
	Timeout   time.Duration
	Verbose   bool
}

MUServerConfig multi-user server config

type SIP003Args

type SIP003Args struct {
	SS_REMOTE_HOST    string
	SS_REMOTE_PORT    string
	SS_LOCAL_HOST     string
	SS_LOCAL_PORT     string
	SS_PLUGIN_OPTIONS string
	VPN               bool
	TFO               bool
}

SIP003Args contains sip003 args

func GetSIP003Args

func GetSIP003Args() (*SIP003Args, error)

GetSIP003Args get sip003 args from os.Environ(), if no args, returns nil

func (*SIP003Args) GetLocalAddr

func (args *SIP003Args) GetLocalAddr() string

func (*SIP003Args) GetRemoteAddr

func (args *SIP003Args) GetRemoteAddr() string

type Server

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

Server represents a Server instance

func NewServer

func NewServer(c *ServerConfig) (*Server, error)

func (*Server) ActiveAndServe added in v0.5.5

func (server *Server) ActiveAndServe(l net.Listener) error

func (*Server) Close

func (server *Server) Close() error

Close shutdown server

func (*Server) ServeHTTP

func (server *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler interface

func (*Server) Start

func (server *Server) Start() error

type ServerConfig

type ServerConfig struct {
	BindAddr string
	BindUnix bool
	DstAddr  string

	EnableWSS bool
	WSSPath   string
	EnableMux bool

	Key        string
	Cert       string
	ServerName string
	DisableTLS bool

	Timeout   time.Duration
	EnableTFO bool
	Verbose   bool
}

ServerConfig is a config

Jump to

Keyboard shortcuts

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