Documentation
¶
Index ¶
- type KeyStore
- type Keypair
- type ReplayStore
- type RequestHandler
- type RespondFn
- type Server
- func (s *Server) ClearClient(clientID string) error
- func (s *Server) Close() error
- func (s *Server) OffRequest(msgType string) error
- func (s *Server) OnRequest(msgType string, handler RequestHandler) error
- func (s *Server) Push(clientID, msgType string, payload any, write WriteFn) error
- func (s *Server) Receive(bytes []byte, write WriteFn) error
- type Session
- type WriteFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KeyStore ¶
type KeyStore struct {
GetPrivateKey func() ([]byte, error) // raw 32-byte scalar
GetClientPublicKey func(clientID string) ([]byte, bool) // raw uncompressed SEC1, (nil,false) if unknown
CommitClientPublicKey func(clientID string, newPublicKey []byte) error // persist after validated renewKeyAck
}
KeyStore is the server's callback seam into host-owned persistence The server holds one long-lived private key shared across all clients
type Keypair ¶
Keypair holds raw P-256 public and private key bytes Public key: 65-byte uncompressed SEC1 (0x04 || X || Y) Private key: 32-byte raw scalar
func GenerateKeypair ¶
GenerateKeypair creates a new P-256 keypair
type ReplayStore ¶
type ReplayStore struct {
Load func() ([]byte, error)
Append func(entry []byte) error
Save func(snapshot []byte) error
}
ReplayStore is the host's callback seam for persisting seen requestIDs Append is called after every accepted message; Save replaces the persisted state on client deletion; Load returns the concatenation of every record the host has persisted
type RequestHandler ¶
RequestHandler processes a client request Either return the response payload, or call respond() to send it immediately (return value will be ignored)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(selfID string, keyStore KeyStore, replayStore ReplayStore) (*Server, error)
NewServer constructs a server Close when the host shuts down to stop the background key-cleanup goroutine
func (*Server) ClearClient ¶ added in v0.1.2
ClearClient drops all per-client state (cached session and replay history)
func (*Server) OffRequest ¶
OffRequest unregisters the handler for a type
func (*Server) OnRequest ¶
func (s *Server) OnRequest(msgType string, handler RequestHandler) error
OnRequest registers the handler for a client-request type Only one handler per type; calling OnRequest twice for the same type replaces the prior handler
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session holds an AES-256-GCM cipher bound to a derived key
func DeriveSession ¶
DeriveSession performs P-256 ECDH between your private key and the other side's public key, runs HKDF-SHA256 over the result, and returns an AES-GCM session bound to the derived key
func SessionFromKey ¶
SessionFromKey builds an AES-GCM session from a 32-byte key
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
test_server
command
test_server is a Unix-domain-socket helper used by the JS cross-language e2e tests Framing: 4-byte big-endian length prefix + raw envelope bytes
|
test_server is a Unix-domain-socket helper used by the JS cross-language e2e tests Framing: 4-byte big-endian length prefix + raw envelope bytes |