server

package
v0.0.0-...-081c383 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: GPL-3.0 Imports: 40 Imported by: 0

Documentation

Overview

Package server ties together the pieces of the luce server process: HTTP routes over tools/server/core, users and sessions through util/lusers and lusess, an admin CLI, and the service-registration socket that external services connect to.

Index

Constants

This section is empty.

Variables

View Source
var DefaultExitDelay = 500 * time.Millisecond

DefaultExitDelay is the ExitDelay used when Config leaves it zero. It gives the services started by BashCommands time to clean up, removing their socket files, after their connections close and before the server exits.

View Source
var TimeoutDuration = time.Second * 5

TimeoutDuration bounds how long RunServiceSocket waits for a registered service to respond to a proxied request before replying 408 Request Timeout.

Functions

This section is empty.

Types

type AdminLockUserCreationReq

type AdminLockUserCreationReq struct {
	AdminLockUserCreation bool
}

AdminLockUserCreationReq sets whether new users may only be created by an admin.

type AdminLockUserCreationResp

type AdminLockUserCreationResp struct{}

AdminLockUserCreationResp confirms AdminLockUserCreationReq.

type BashCmd

type BashCmd struct {
	Format string
	Auto   bool
	Args   slice.Slice[any]
	// contains filtered or unexported fields
}

BashCmd is a configured shell command the admin CLI can run and inspect.

func (*BashCmd) Run

func (bc *BashCmd) Run(cmdr lexec.Commander)

Run starts the command with cmdr if it isn't already running.

func (*BashCmd) Running

func (bc *BashCmd) Running() bool

Running reports whether the command is currently running.

type BashCommandOuputReq

type BashCommandOuputReq struct {
	ID int
}

BashCommandOuputReq requests the buffered output of the bash command at index ID.

type BashCommandOuputResp

type BashCommandOuputResp struct {
	Msg string
}

BashCommandOuputResp is the output returned by BashCommandOuputReq.

type Config

type Config struct {
	SessionStore sessions.Store
	Templates    *template.Template
	UserStore    store.NestedFactory
	TemplateNames
	ServiceSocket string
	core.Config
	BashCommands []BashCmd
	Commander    lexec.Commander
	// ExitDelay is how long Run waits, after the server is shut down, before
	// it returns. Zero uses DefaultExitDelay.
	ExitDelay time.Duration
}

Config is used to create a Server. It holds all the configuration values. This follows the builder pattern instead of using a function that would take many arguments.

func (*Config) New

func (c *Config) New() (*Server, error)

New Server using the values from the Config.

type CreateUserReq

type CreateUserReq struct {
	Name, Password string
}

CreateUserReq requests a new user named Name with Password.

type CreateUserResp

type CreateUserResp struct {
	Error error
}

CreateUserResp reports whether CreateUserReq failed.

type GroupReq

type GroupReq struct {
	Name string
}

GroupReq requests a new group named Name.

type GroupResp

type GroupResp struct {
	Error error
}

GroupResp reports whether GroupReq failed.

type ListBashCommandsReq

type ListBashCommandsReq struct {
}

ListBashCommandsReq lists the server's configured bash commands.

type ListBashCommandsResp

type ListBashCommandsResp []BashCmd

ListBashCommandsResp is the bash commands returned by ListBashCommandsReq.

type ListGroupsReq

type ListGroupsReq struct{}

ListGroupsReq lists the server's group names.

type ListGroupsResp

type ListGroupsResp []string

ListGroupsResp is the group names returned by ListGroupsReq.

type ListServicesReq

type ListServicesReq struct {
}

ListServicesReq lists the services currently registered over the service socket.

type ListServicesResp

type ListServicesResp []string

ListServicesResp is the registered service names returned by ListServicesReq.

type ListUsersReq

type ListUsersReq struct{}

ListUsersReq lists the server's user names.

type ListUsersResp

type ListUsersResp []string

ListUsersResp is the user names returned by ListUsersReq.

type RoutesReq

type RoutesReq struct {
}

RoutesReq requests the server's currently active service routes.

type RoutesResp

type RoutesResp string

RoutesResp lists the active service routes, one per line, returned by RoutesReq.

type RunBashCommandReq

type RunBashCommandReq struct {
	ID int
}

RunBashCommandReq runs the configured bash command at index ID.

type RunBashCommandResp

type RunBashCommandResp struct {
	Msg string
}

RunBashCommandResp reports the result of RunBashCommandReq.

type Server

type Server struct {
	Users         *lusess.Store
	Settings      Settings
	Templates     *template.Template
	ServiceSocket string
	TemplateNames

	lerr.ErrHandler
	BashCommands slice.Slice[BashCmd]
	Commander    lexec.Commander
	WebSocket
	// contains filtered or unexported fields
}

Server runs a webserver.

func (*Server) Close

func (s *Server) Close() error

Close stops the underlying core.Server.

func (*Server) Run

func (s *Server) Run()

Run the server. If Socket or ServiceSocket is defined, they will be run as well. It blocks until the server stops. When it was stopped by a shutdown, such as the CLI's close command, it waits ExitDelay before it returns.

func (*Server) RunServiceSocket

func (s *Server) RunServiceSocket() error

RunServiceSocket listens on the configured service socket, blocking until it stops. External services connect here to register their routes and handle proxied requests.

func (*Server) RunStdIO

func (s *Server) RunStdIO()

RunStdIO drives the admin CLI over the process's stdin/stdout.

type SetPortReq

type SetPortReq struct {
	Port string
}

SetPortReq changes the HTTP server's listening port.

type SetPortResp

type SetPortResp struct{}

SetPortResp confirms SetPortReq; the server has already restarted.

type Settings

type Settings struct {
	AdminLockUserCreation bool
}

Settings holds the server's admin-configurable settings.

type SettingsReq

type SettingsReq struct{}

SettingsReq requests the server's current Settings.

type TemplateNames

type TemplateNames struct {
	SignIn       string
	Home         string
	HomeSignedIn string
	Services     string
}

TemplateNames names the templates Server renders for the built-in user pages.

type UserGroupReq

type UserGroupReq struct {
	User, Group string
}

UserGroupReq adds User to Group.

type UserGroupResp

type UserGroupResp struct {
	Error error
}

UserGroupResp reports whether UserGroupReq failed.

type WebSocket

type WebSocket struct {
	websocket.Upgrader
	// contains filtered or unexported fields
}

WebSocket upgrades HTTP connections for routes registered with service.Route.WithSocket and tracks each open socket by the ID a registered service uses to address it over the service socket.

Directories

Path Synopsis
Package core runs the HTTP and unix-socket plumbing for a luce server: starting and stopping the web server, and exposing the same process over an admin CLI socket.
Package core runs the HTTP and unix-socket plumbing for a luce server: starting and stopping the web server, and exposing the same process over an admin CLI socket.
Package service is the protocol a tools/server service registers and communicates with over the admin's service socket: requests, responses, routes, and the client that connects a service to the server.
Package service is the protocol a tools/server service registers and communicates with over the admin's service socket: requests, responses, routes, and the client that connects a service to the server.

Jump to

Keyboard shortcuts

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