Documentation
¶
Overview ¶
Package routing implements the beacon-registration and NAT punch-coordination handlers extracted from the registry server (R1.4 decomposition).
The package owns the beacon cluster state (registration, TTL-based listing) and the punch endpoint lookup. It exposes a Store that holds the beacon map and the PunchBackend interface that the *server.Server satisfies for the punch operation.
Index ¶
- Constants
- type BeaconEntry
- type PunchBackend
- type Store
- func (st *Store) HandleBeaconList() (map[string]interface{}, error)
- func (st *Store) HandleBeaconRegister(msg map[string]interface{}) (map[string]interface{}, error)
- func (st *Store) HandlePunch(msg map[string]interface{}) (map[string]interface{}, error)
- func (st *Store) ReapStale()
- func (st *Store) SetClock(fn func() time.Time)
Constants ¶
const BeaconTTL = 60 * time.Second
BeaconTTL is how long a beacon registration is valid without re-register.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PunchBackend ¶
type PunchBackend interface {
// NodePubKeyAndAdminToken returns false if the node does not exist.
NodePubKeyAndAdminToken(nodeID uint32) (pubKey []byte, adminToken string, ok bool)
// VerifyPunchSignature accepts either an Ed25519 signature or an admin-token fallback.
VerifyPunchSignature(pubKey []byte, adminToken string, msg map[string]interface{}, challenge string) error
// NodeAddrs returns false for addrA or addrB when the respective node is absent.
NodeAddrs(nodeA, nodeB uint32) (addrA string, okA bool, addrB string, okB bool)
}
PunchBackend is satisfied by *server.Server and provides the node address lookups that HandlePunch needs. The interface is intentionally narrow: only the three operations the punch handler requires are exposed.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store holds the beacon cluster state and implements the three beacon/punch routing handlers.
func NewStore ¶
func NewStore(backend PunchBackend) *Store
NewStore creates a Store with a real-time clock. backend may be nil if HandlePunch will never be called (e.g. in tests that only exercise beacon registration/listing).
func (*Store) HandleBeaconList ¶
HandleBeaconList returns all known (non-expired) beacon instances.
func (*Store) HandleBeaconRegister ¶
HandleBeaconRegister registers or refreshes a beacon instance for peer discovery.