clusternet

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: AGPL-3.0 Imports: 16 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 clusternet serves the cluster port (ADR 0006): one TLS 1.3 listener with mutual authentication against the cluster CA, multiplexed by ALPN into Raft ("uc-raft/1", voters only) and gRPC ("h2", authorized per RPC).

Index

Constants

View Source
const (
	ALPNRaft = "uc-raft/1"
	ALPNGRPC = "h2"
)

ALPN protocols of the cluster port.

View Source
const (

	// MaxConnectionAge closes Raft connections after this time, so renewed
	// and revoked certificates take effect on long-lived peers (FA-PKI-03).
	MaxConnectionAge = time.Hour
)

Variables

This section is empty.

Functions

func Authorize

func Authorize(levels map[string]Access) grpc.UnaryServerInterceptor

Authorize returns a unary interceptor that enforces the access level of each method; unknown methods are denied.

func AuthorizeStream

func AuthorizeStream(levels map[string]Access) grpc.StreamServerInterceptor

AuthorizeStream is Authorize for streaming methods: the caller is checked once when the stream opens, before the handler runs.

func DialVoter

func DialVoter(address string, sec Security) (*grpc.ClientConn, error)

DialVoter opens a gRPC connection to another voter with this node's certificate; the server must be a voter of this cluster.

func Peer

func Peer(ctx context.Context) (pki.Identity, bool)

Peer returns the verified identity of the caller, or ok=false if it presented no certificate. Certificates were verified during the handshake (chain, expiry, revocation, cluster).

func ServerOptions

func ServerOptions(levels map[string]Access) []grpc.ServerOption

ServerOptions returns the gRPC server options of the cluster port (ADR 0006: keepalive, maximum connection age). levels says who may call each method, unary and streaming alike; unknown methods are denied.

Types

type Access

type Access int

Access says who may call an RPC.

const (
	// Anonymous allows callers without certificate (Join only).
	Anonymous Access = iota
	// AnyNode requires a valid certificate of any role (RenewCertificate).
	AnyNode
	// VoterOnly requires a voter certificate (Apply, GetStatus, replication).
	VoterOnly
)

Access levels of cluster RPCs.

type Mux

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

Mux accepts TLS connections and hands them to Raft or gRPC.

func Listen

func Listen(addr, advertise string, sec Security, log *slog.Logger) (*Mux, error)

Listen opens the cluster port. advertise is the address other nodes use for this node; Raft announces it.

func (*Mux) Addr

func (m *Mux) Addr() net.Addr

Addr is the bound address (useful with port 0 in tests).

func (*Mux) Close

func (m *Mux) Close() error

Close stops accepting and closes the listener.

func (*Mux) GRPCListener

func (m *Mux) GRPCListener() net.Listener

GRPCListener returns the connections negotiated for gRPC, unwrapped *tls.Conn as gRPC needs them (spike finding, ADR 0006).

func (*Mux) RaftLayer

func (m *Mux) RaftLayer() raft.StreamLayer

RaftLayer returns the raft.StreamLayer of this port.

func (*Mux) Serve

func (m *Mux) Serve() error

Serve accepts connections until Close.

type Security

type Security struct {
	Holder   *pki.Holder
	Verifier *pki.Verifier
}

Security is the node's TLS material for the cluster port.

Jump to

Keyboard shortcuts

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