Documentation ¶
Index ¶
- Constants
- Variables
- func PipeEndpoints(e1, e2 Endpoint)
- func Timestamp() string
- type AssocPair
- type Config
- type Endpoint
- type LaunchedProcess
- type LogFunc
- type LogLevel
- type LogScope
- func (l *LogScope) Access(category string, msg string, args ...interface{})
- func (l *LogScope) Associate(key string, value string)
- func (l *LogScope) Debug(category string, msg string, args ...interface{})
- func (l *LogScope) Error(category string, msg string, args ...interface{})
- func (l *LogScope) Fatal(category string, msg string, args ...interface{})
- func (l *LogScope) Info(category string, msg string, args ...interface{})
- func (parent *LogScope) NewLevel(logFunc LogFunc) *LogScope
- func (l *LogScope) Trace(category string, msg string, args ...interface{})
- type ProcessEndpoint
- type RemoteInfo
- type URLInfo
- type WebSocketEndpoint
- type WebsocketdHandler
- type WebsocketdServer
Constants ¶
const ( LogDebug = iota LogTrace LogAccess LogInfo LogError LogFatal LogNone = 126 LogUnknown = 127 )
const (
License = license
)
Variables ¶
var ConsoleContent = defaultConsoleContent
var ForkNotAllowedError = errors.New("too many forks active")
var ScriptNotFoundError = errors.New("script not found")
Functions ¶
func PipeEndpoints ¶ added in v0.2.9
func PipeEndpoints(e1, e2 Endpoint)
Types ¶
type Config ¶
type Config struct { // base initiaization fields StartupTime time.Time // Server startup time (used for dev console caching). CommandName string // Command to execute. CommandArgs []string // Additional args to pass to command. ServerSoftware string // Value to pass to SERVER_SOFTWARE environment variable (e.g. websocketd/1.2.3). // settings ReverseLookup bool // Perform reverse DNS lookups on hostnames (useful, but slower). Ssl bool // websocketd works with --ssl which means TLS is in use ScriptDir string // Base directory for websocket scripts. UsingScriptDir bool // Are we running with a script dir. StaticDir string // If set, static files will be served from this dir over HTTP. CgiDir string // If set, CGI scripts will be served from this dir over HTTP. DevConsole bool // Enable dev console. This disables StaticDir and CgiDir. AllowOrigins []string // List of allowed origin addresses for websocket upgrade. SameOrigin bool // If set, requires websocket upgrades to be performed from same origin only. Headers []string HeadersWs []string HeadersHTTP []string // created environment Env []string // Additional environment variables to pass to process ("key=value"). ParentEnv []string // Variables kept from os.Environ() before sanitizing it for subprocess. }
type LaunchedProcess ¶
type LaunchedProcess struct {
// contains filtered or unexported fields
}
type LogScope ¶
type LogScope struct { Parent *LogScope // Parent scope MinLevel LogLevel // Minimum log level to write out. Mutex *sync.Mutex // Should be shared across all LogScopes that write to the same destination. Associated []AssocPair // Additional data associated with scope LogFunc LogFunc }
func RootLogScope ¶
type ProcessEndpoint ¶
type ProcessEndpoint struct {
// contains filtered or unexported fields
}
func NewProcessEndpoint ¶
func NewProcessEndpoint(process *LaunchedProcess, log *LogScope) *ProcessEndpoint
func (*ProcessEndpoint) Output ¶
func (pe *ProcessEndpoint) Output() chan string
func (*ProcessEndpoint) Send ¶
func (pe *ProcessEndpoint) Send(msg string) bool
func (*ProcessEndpoint) StartReading ¶ added in v0.2.9
func (pe *ProcessEndpoint) StartReading()
func (*ProcessEndpoint) Terminate ¶
func (pe *ProcessEndpoint) Terminate()
type RemoteInfo ¶ added in v0.2.9
type RemoteInfo struct {
Addr, Host, Port string
}
RemoteInfo holds information about remote http client
func GetRemoteInfo ¶ added in v0.2.9
func GetRemoteInfo(remote string, doLookup bool) (*RemoteInfo, error)
GetRemoteInfo creates RemoteInfo structure and fills its fields appropriately
type URLInfo ¶
URLInfo - structure carrying information about current request and it's mapping to filesystem
type WebSocketEndpoint ¶
type WebSocketEndpoint struct {
// contains filtered or unexported fields
}
func NewWebSocketEndpoint ¶
func NewWebSocketEndpoint(ws *websocket.Conn, log *LogScope) *WebSocketEndpoint
func (*WebSocketEndpoint) Output ¶
func (we *WebSocketEndpoint) Output() chan string
func (*WebSocketEndpoint) Send ¶
func (we *WebSocketEndpoint) Send(msg string) bool
func (*WebSocketEndpoint) StartReading ¶ added in v0.2.9
func (we *WebSocketEndpoint) StartReading()
func (*WebSocketEndpoint) Terminate ¶
func (we *WebSocketEndpoint) Terminate()
type WebsocketdHandler ¶ added in v0.2.9
type WebsocketdHandler struct { Id string *RemoteInfo *URLInfo // TODO: I cannot find where it's used except in one single place as URLInfo.FilePath Env []string // contains filtered or unexported fields }
WebsocketdHandler is a single request information and processing structure, it handles WS requests out of all that daemon can handle (static, cgi, devconsole)
func NewWebsocketdHandler ¶ added in v0.2.9
func NewWebsocketdHandler(s *WebsocketdServer, req *http.Request, log *LogScope) (wsh *WebsocketdHandler, err error)
NewWebsocketdHandler constructs the struct and parses all required things in it...
type WebsocketdServer ¶ added in v0.2.9
type WebsocketdServer struct { Config *Config Log *LogScope // contains filtered or unexported fields }
WebsocketdServer presents http.Handler interface for requests libwebsocketd is handling.
func NewWebsocketdServer ¶ added in v0.2.9
func NewWebsocketdServer(config *Config, log *LogScope, maxforks int) *WebsocketdServer
NewWebsocketdServer creates WebsocketdServer struct with pre-determined config, logscope and maxforks limit
func (*WebsocketdServer) ServeHTTP ¶ added in v0.2.9
func (h *WebsocketdServer) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP muxes between WebSocket handler, CGI handler, DevConsole, Static HTML or 404.
func (*WebsocketdServer) TellURL ¶ added in v0.2.9
func (h *WebsocketdServer) TellURL(scheme, host, path string) string
TellURL is a helper function that changes http to https or ws to wss in case if SSL is used