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
- func Authorize(levels map[string]Access) grpc.UnaryServerInterceptor
- func AuthorizeStream(levels map[string]Access) grpc.StreamServerInterceptor
- func DialVoter(address string, sec Security) (*grpc.ClientConn, error)
- func Peer(ctx context.Context) (pki.Identity, bool)
- func ServerOptions(levels map[string]Access) []grpc.ServerOption
- type Access
- type Mux
- type Security
Constants ¶
const ( ALPNRaft = "uc-raft/1" ALPNGRPC = "h2" )
ALPN protocols of the cluster port.
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 ¶
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 Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux accepts TLS connections and hands them to Raft or gRPC.
func Listen ¶
Listen opens the cluster port. advertise is the address other nodes use for this node; Raft announces it.
func (*Mux) GRPCListener ¶
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.