server

package
v0.0.0-...-711df2b Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory interface {
	Name() string
	New(params map[string][]string, headers map[string][]string) (Slave, error)
}

type InitMessage

type InitMessage struct {
	Arguments string `json:"Arguments,omitempty"`
	AuthToken string `json:"AuthToken,omitempty"`
}

type Options

type Options struct {
	Address             string       `hcl:"address" flagName:"address" flagSName:"a" flagDescribe:"IP address to listen" default:"0.0.0.0"`
	Port                string       `hcl:"port" flagName:"port" flagSName:"p" flagDescribe:"Port number to liten" default:"8080"`
	Path                string       `hcl:"path" flagName:"path" flagSName:"m" flagDescribe:"Base path" default:"/"`
	PermitWrite         bool         `` /* 135-byte string literal not displayed */
	EnableBasicAuth     bool         `hcl:"enable_basic_auth" default:"false"`
	Credential          string       `` /* 148-byte string literal not displayed */
	EnableRandomUrl     bool         `hcl:"enable_random_url" flagName:"random-url" flagSName:"r" flagDescribe:"Add a random string to the URL" default:"false"`
	RandomUrlLength     int          `hcl:"random_url_length" flagName:"random-url-length" flagDescribe:"Random URL length" default:"8"`
	EnableTLS           bool         `hcl:"enable_tls" flagName:"tls" flagSName:"t" flagDescribe:"Enable TLS/SSL" default:"false"`
	TLSCrtFile          string       `hcl:"tls_crt_file" flagName:"tls-crt" flagDescribe:"TLS/SSL certificate file path" default:"~/.gotty.crt"`
	TLSKeyFile          string       `hcl:"tls_key_file" flagName:"tls-key" flagDescribe:"TLS/SSL key file path" default:"~/.gotty.key"`
	EnableTLSClientAuth bool         `hcl:"enable_tls_client_auth" default:"false"`
	TLSCACrtFile        string       `` /* 138-byte string literal not displayed */
	IndexFile           string       `hcl:"index_file" flagName:"index" flagDescribe:"Custom index.html file" default:""`
	TitleFormat         string       `` /* 142-byte string literal not displayed */
	EnableReconnect     bool         `hcl:"enable_reconnect" flagName:"reconnect" flagDescribe:"Enable reconnection" default:"false"`
	ReconnectTime       int          `hcl:"reconnect_time" flagName:"reconnect-time" flagDescribe:"Time to reconnect" default:"10"`
	MaxConnection       int          `hcl:"max_connection" flagName:"max-connection" flagDescribe:"Maximum connection to gotty" default:"0"`
	Once                bool         `hcl:"once" flagName:"once" flagDescribe:"Accept only one client and exit on disconnection" default:"false"`
	Timeout             int          `hcl:"timeout" flagName:"timeout" flagDescribe:"Timeout seconds for waiting a client(0 to disable)" default:"0"`
	PermitArguments     bool         `` /* 182-byte string literal not displayed */
	PassHeaders         bool         `` /* 158-byte string literal not displayed */
	Width               int          `hcl:"width" flagName:"width" flagDescribe:"Static width of the screen, 0(default) means dynamically resize" default:"0"`
	Height              int          `hcl:"height" flagName:"height" flagDescribe:"Static height of the screen, 0(default) means dynamically resize" default:"0"`
	WSOrigin            string       `` /* 188-byte string literal not displayed */
	EnableWebGL         bool         `hcl:"enable_webgl" flagName:"enable-webgl" flagDescribe:"Enable WebGL renderer" default:"true"`
	Quiet               bool         `hcl:"quiet" flagName:"quiet" flagDescribe:"Don't log" default:"false"`
	Listener            net.Listener `hcl:"-"`

	TitleVariables map[string]interface{}
}

func (*Options) Validate

func (options *Options) Validate() error

type RunOption

type RunOption func(*RunOptions)

RunOption is an option of Server.Run().

func WithGracefullContext

func WithGracefullContext(ctx context.Context) RunOption

WithGracefullContext accepts a context to shutdown a Server with care for existing client connections.

type RunOptions

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

RunOptions holds a set of configurations for Server.Run().

type Server

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

Server provides a webtty HTTP endpoint.

func New

func New(factory Factory, options *Options) (*Server, error)

New creates a new instance of Server. Server will use the New() of the factory provided to handle each request.

func (*Server) Run

func (server *Server) Run(ctx context.Context, options ...RunOption) error

Run starts the main process of the Server. The cancelation of ctx will shutdown the server immediately with aborting existing connections. Use WithGracefullContext() to support gracefull shutdown.

type Slave

type Slave interface {
	webtty.Slave

	Close() error
}

Slave is webtty.Slave with some additional methods.

Jump to

Keyboard shortcuts

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