server

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package server serves plymouthd's socket protocol: it accepts connections on the abstract socket, decodes their requests and hands each one to a Handler, which answers it at once or later.

Index

Constants

This section is empty.

Variables

View Source
var ErrRunning = errors.New("server: another daemon is already listening")

ErrRunning is what Listen fails with when another daemon already listens on the socket.

Functions

This section is empty.

Types

type Call

type Call struct {
	Request protocol.Request
	// contains filtered or unexported fields
}

Call is one request awaiting its answer.

func (*Call) Conn

func (c *Call) Conn() *Conn

Conn is the connection the request came in on.

func (*Call) Reply

func (c *Call) Reply(r protocol.Response) error

Reply answers the call without waiting for the client: the answer joins the connection's queue. A call is answered once; a second Reply fails. When the client has already hung up the answer is dropped without error. The encoded bytes are zeroed once written or dropped, since an answer may be a secret.

type Conn

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

Conn is one client connection. Replies go through a bounded queue to the connection's own writer, so a client that stops reading costs only itself: its connection is dropped once the queue overflows or a write times out.

func (*Conn) Peer

func (c *Conn) Peer() peercred.Credentials

Peer is the process that opened the connection, as SO_PEERCRED reports it when the connection is accepted.

type Handler

type Handler interface {
	// Request is a request from a permitted peer. The handler answers it
	// with Call.Reply, now or later; a request whose connection hangs up
	// first needs no answer.
	Request(c *Call)
	// HangUp reports that c is gone: its pending calls will never be
	// answered on the wire and can be dropped. No Request on c follows it.
	HangUp(c *Conn)
}

Handler receives a server's requests. Both methods are called from the connection's own goroutine, in the order the client sent its requests, and must not block.

type Server

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

Server accepts connections and dispatches their requests.

func Listen

func Listen(name string, owner uint32, log *slog.Logger) (*Server, error)

Listen listens on the Unix socket name, "@" leading an abstract one as in net.Listen. Only requests from processes running as uid owner reach the handler Serve is given; every other peer is answered NAK, as plymouthd answers non-root peers. A name another process listens on fails with ErrRunning.

func (*Server) Close

func (s *Server) Close() error

Close stops accepting, hangs up every connection and waits until each connection's HangUp has been delivered. Closing again does nothing.

func (*Server) Serve

func (s *Server) Serve(h Handler) error

Serve hands every request to h and accepts connections until Close, then returns nil.

Jump to

Keyboard shortcuts

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