peerverify

package
v0.0.0-...-a3a63d2 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetPeerVerifierSingleton

func SetPeerVerifierSingleton(pv *PeerVerifier)

SetPeerVerifierSingleton installs the singleton. Called at startup after NewPeerVerifier; cleared by the cancel returned from AttachToHost.

Types

type PeerIdentityConfig

type PeerIdentityConfig struct {
	Enabled     bool   // PEER_IDENTITY_ENABLED
	CAAddr      string // PEER_IDENTITY_CA_ADDR
	CAToken     string // PEER_IDENTITY_CA_TOKEN
	CAMountPath string // PEER_IDENTITY_CA_MOUNT (default "pki")
	CARole      string // PEER_IDENTITY_CA_ROLE (default "tx-rails-pod")
	StoreDir    string // PEER_IDENTITY_STORE_DIR (default "/var/lib/orgsnode/peeridentity")
	// TTL + RotateBefore tunables — rarely overridden but exposed for
	// per-deployment policy. Defaults match the peeridentity defaults.
	TTL          time.Duration
	RotateBefore time.Duration
}

PeerIdentityConfig is the env-var-derived config bundle.

func LoadPeerIdentityConfigFromEnv

func LoadPeerIdentityConfigFromEnv() PeerIdentityConfig

LoadPeerIdentityConfigFromEnv reads the PEER_IDENTITY_* env vars and returns a populated config. Unset vars take the package defaults.

type PeerVerifier

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

PeerVerifier owns the wp-06 primitives + verified-peer set for one libp2p host. Constructed by NewPeerVerifier; AttachToHost wires it into a host's lifecycle. Close (via the cancel returned by AttachToHost) releases all goroutines.

func NewPeerVerifier

func NewPeerVerifier(ctx context.Context, cfg PeerIdentityConfig, libp2pPeerID peer.ID) (*PeerVerifier, error)

NewPeerVerifier constructs the wp-06 chain when cfg.Enabled is true. Returns (nil, nil) when disabled (pre-wp-06 PoC path). On enabled + failure, returns a non-nil error — caller should treat as fatal (operator configuration mistake).

The libp2pPeerID is the local libp2p host's peer ID; Vault PKI is asked to mint a cert with CommonName=libp2pPeerID.String(). The Vault role must allow that CN (operator-side: configure allow_common_names to permit base58 peer IDs).

func PeerVerifierActive

func PeerVerifierActive() *PeerVerifier

PeerVerifierActive returns the singleton if wp-06 verification is currently enabled. Test seam — tests can set + reset.

func (*PeerVerifier) AttachToHost

func (pv *PeerVerifier) AttachToHost(ctx context.Context, h host.Host) func()

AttachToHost wires the verifier into a libp2p host:

  1. Registers peerhandshake.Server (incoming exchanges).
  2. Subscribes to event.EvtPeerConnectednessChanged.
  3. On Connected: spawns a goroutine that calls VerifyOutgoing; if it fails, closes the connection.
  4. On NotConnected: removes the peer from the verified set.

Returns a cancel function that closes the rotator + refresher + event subscription. Idempotent; safe to call once at shutdown.

func (*PeerVerifier) IsVerified

func (pv *PeerVerifier) IsVerified(p peer.ID) bool

IsVerified reports whether p is in the verified-peer set. Used by dht.go's applyEnforce (via the singleton) to reject peers that haven't completed the wp-06 handshake.

Jump to

Keyboard shortcuts

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