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 ¶
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 ¶
Call is one request awaiting its answer.
func (*Call) Reply ¶
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 ¶
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.