/tmp/sv-test/splicevpn/proto/proto.go
// Package proto defines the wire types exchanged between the SpliceVPN
// coordinator and agents. Everything here is plain JSON over HTTP.
package proto
// RegisterRequest is sent by an agent when it joins (or refreshes) the mesh.
type RegisterRequest struct {
JoinKey string `json: [REDACTED]
Name string `json:"name"` // human label, e.g. "office-gw"
// PublicKey is the agent's WireGuard public key (base64, as `wg` prints it).
PublicKey string `json:"public_key"`
// Endpoints are candidate ip:port pairs the agent believes it is reachable on
// (LAN addresses, UPnP-mapped ports, etc). The coordinator also records the
// observed public source ip:port (STUN-lite) and merges it in.
Endpoints []string `json:"endpoints"`
// Routes are subnets this endpoint exposes to the mesh. Empty => host-only
// (just its own overlay IP). A site gateway advertises e.g. "192.168.10.0/24".
Routes []string `json:"routes"`
// ListenPort is the UDP port the agent's WireGuard is listening on.
ListenPort int `json:"listen_port"`
// Profile is the zero-config preference: "speed" | "resilience" | "both".
// It tunes keepalives and relay willingness; it does not change the topology.
Profile string `json:"profile"`
}
// Peer is one node as seen by another node, ready to drop into a WireGuard config.
type Peer struct {
Name string `json:"name"`
PublicKey string `json:"public_key"`
OverlayIP string `json:"overlay_ip"` // /32 inside the overlay range
Endpoints []string `json:"endpoints"` // best-known reachable ip:port list
AllowedIPs []string `json:"allowed_ips"` // overlay /32 + advertised routes
}
// RegisterResponse tells the agent who it is on the overlay and how to reach the relay.
type RegisterResponse struct {
OverlayIP string `json:"overlay_ip"` // this agent's assigned /32
OverlayCIDR string `json:"overlay_cidr"` // full overlay range, e.g. 100.96.0.0/16
HubPublicKey string `json:"hub_public_key"` // relay/hub WireGuard key
HubEndpoint string `json:"hub_endpoint"` // relay/hub ip:port (always-on fallback)
Token string `json: [REDACTED]
}
// MeshSnapshot is the full peer list returned on each poll. Every other registered
// node appears here, which is what makes the topology a full mesh.
type MeshSnapshot struct {
Self Peer `json:"self"`
Peers []Peer `json:"peers"`
// HubAllowedIPs is what to route via the relay as the catch-all fallback path.
HubAllowedIPs []string `json:"hub_allowed_ips"`
Epoch int64 `json:"epoch"` // bumps when membership changes
}