Documentation
¶
Overview ¶
Package natsense implements observed address consensus (spec Phase 2a: ≥3 distinct reporters). For tests or small networks, set MinAgreeingPeers to 1.
Index ¶
Constants ¶
const ( NATUnknown uint8 = 0 NATFullCone uint8 = 1 NATRestricted uint8 = 2 NATPortRestrict uint8 = 3 NATSymmetric uint8 = 4 )
NAT type constants (mirror protocol.NAT* for convenience).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Sense ¶
type Sense struct {
// contains filtered or unexported fields
}
Sense tracks distinct peers that reported the same reflected UDP endpoint (wire bytes) and infers a basic NAT type from observed port consistency.
func (*Sense) InferNATType ¶
InferNATType returns a basic NAT type inference based on observed port consistency across reporters (spec Phase 2a):
- All reporters saw the same port → endpoint-independent mapping (FullCone/Restricted)
- Different ports → NATSymmetric
- Insufficient data → NATUnknown
Distinguishing FullCone from Restricted requires active probing (Phase 2b).
func (*Sense) MinAgreeing ¶
MinAgreeing returns the configured threshold.
func (*Sense) SetMinAgreeing ¶
SetMinAgreeing updates the threshold (e.g. 1 for integration tests).
func (*Sense) TrustedUDP ¶
TrustedUDP returns host and port if some observed key has >= min distinct reporters.
func (*Sense) TrustedWire ¶
TrustedWire returns the first trusted observed_addr wire form (6 or 18 bytes).