Documentation
¶
Overview ¶
This file serves the app's lodge socket, on which lodge forwards a user's calls after it has checked that user's grant for this app (docs/specs/lodge-app.md, and lodge's docs/specs/app-contract.md).
The socket admits lodge's user alone, and the Lodge-Principal and Lodge-Grant headers are read only through hearth's adapter (lodge.Handler), after that check. The app's own /health answer stands outside the adapter: lodge polls it for the rail, and it carries no grant.
Package rpc serves frostmarks' API over Connect on the app's private and lodge Unix sockets, and it gives the app's CLI and its MCP server a private client.
Hearth's connectserver provides the handlers, the error mapping, the servers and the Unix client. The private socket acts as the local user and ignores forged Lodge-* headers. The lodge socket admits calls forwarded by lodge with the principal and grant of the caller. This package owns the socket files and the app's health route.
Index ¶
- func Handler(api marksv1.MarksAPI) http.Handler
- func Listen(path string) (net.Listener, error)
- func ListenActivated(name string, getenv func(string) string) (listener net.Listener, ok bool, err error)
- func ListenLodge(path string, lodgeUID int) (net.Listener, error)
- func LodgeHandler(api marksv1.MarksAPI, health func(context.Context) Health) http.Handler
- func NewClient(socket string) marksv1connect.MarksClient
- func Serve(ctx context.Context, listener net.Listener, h http.Handler) error
- func ServeLodge(ctx context.Context, listener net.Listener, h http.Handler) error
- type Health
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Listen ¶
Listen listens on the private socket at path, and it serves only the processes of the local user: another user's connection is closed before the server reads a byte of it.
It makes the socket's directory (0700) when it is missing. A path that holds a socket that accepts a connection is another frostmarksd: the call fails. A path that holds a socket that the kernel refuses is stale: it is removed. A path that holds something else, or a socket that fails for another reason, fails the call and stays. The socket's own permission is 0600.
func ListenActivated ¶
func ListenActivated(name string, getenv func(string) string) (listener net.Listener, ok bool, err error)
ListenActivated returns the socket that systemd passed to this process under name, such as the socket unit's FileDescriptorName.
ok is false when systemd passed no socket: the variables are absent, they name another process, or no descriptor carries the name. The daemon then creates the socket itself. A variable that is there and malformed is an error.
func ListenLodge ¶
ListenLodge listens on the lodge socket at path, and it serves lodge's user alone: another peer's connection is closed before the server reads a byte of it.
It makes the socket's directory (0755) when it is missing, it clears a stale socket as the private socket does, and it sets the socket's mode to 0660. The socket unit owns these when systemd passes the socket instead.
func LodgeHandler ¶
LodgeHandler returns the HTTP handler of the app's lodge socket: GET and HEAD /health for lodge's polls, and the Connect API at /connect/ for a caller whose kind is principal. Every other path, and a kind that the path does not admit, is 403 with 1 line of text.
health is a function, so that each poll answers with the current version of the app and pings the store of the moment.
func NewClient ¶
func NewClient(socket string) marksv1connect.MarksClient
NewClient returns the API's client on the private socket.
func Serve ¶
Serve serves h on the listener until ctx ends, and it returns nil after a clean stop. A call in flight has the time that hearth's connectserver.Serve gives it to finish; a server error closes its connections and returns the error.
func ServeLodge ¶
ServeLodge serves h on the lodge socket's listener until ctx ends, and it returns nil after a clean stop. A call in flight has the time that hearth's connectserver.Serve gives it to finish.
The server marks every connection that hearth's lodge listener accepted in the connection's context, which the adapter requires: without the mark it refuses every request.
Types ¶
type Health ¶
type Health struct {
// Version is the app's version.
Version string
// Protocol is the major of the app's own API.
Protocol int
// Ping checks the app's store. A store that does not answer gives
// {"ok": false, "reason": ...}.
Ping func(context.Context) error
}
Health is the app's state, as GET /health answers it (lodge's docs/specs/app-contract.md, What an app serves on its socket).