Compare commits

...

1 Commits

Author SHA1 Message Date
Maisem Ali 1178d4ae1f tailcfg: add Node.SelfNodeV4MasqAddrForThisPeer
This only adds the field, to be used in a future commit.

Updates tailscale/corp#8020

Co-authored-by: Melanie Warrick <warrick@tailscale.com>
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-03-16 11:35:10 -07:00
3 changed files with 81 additions and 61 deletions

View File

@ -273,6 +273,21 @@ type Node struct {
// the client, this is calculated client-side based on a timestamp sent // the client, this is calculated client-side based on a timestamp sent
// from control, to avoid clock skew issues. // from control, to avoid clock skew issues.
Expired bool `json:",omitempty"` Expired bool `json:",omitempty"`
// SelfNodeV4MasqAddrForThisPeer is the IPv4 that this peer knows the current node as.
// It may be empty if the peer knows the current node by its native
// IPv4 address.
// This field is only populated in a MapResponse for peers and not
// for the current node.
//
// If set, it should be used to masquerade traffic originating from the
// current node to this peer. The masquerade address is only relevant
// for this peer and not for other peers.
//
// This only applies to traffic originating from the current node to the
// peer or any of its subnets. Traffic originating from subnet routes will
// not be masqueraded (e.g. in case of --snat-subnet-routes).
SelfNodeV4MasqAddrForThisPeer netip.Addr `json:",omitempty"`
} }
// DisplayName returns the user-facing name for a node which should // DisplayName returns the user-facing name for a node which should

View File

@ -68,36 +68,37 @@ func (src *Node) Clone() *Node {
// A compilation failure here means this code must be regenerated, with the command at the top of this file. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _NodeCloneNeedsRegeneration = Node(struct { var _NodeCloneNeedsRegeneration = Node(struct {
ID NodeID ID NodeID
StableID StableNodeID StableID StableNodeID
Name string Name string
User UserID User UserID
Sharer UserID Sharer UserID
Key key.NodePublic Key key.NodePublic
KeyExpiry time.Time KeyExpiry time.Time
KeySignature tkatype.MarshaledSignature KeySignature tkatype.MarshaledSignature
Machine key.MachinePublic Machine key.MachinePublic
DiscoKey key.DiscoPublic DiscoKey key.DiscoPublic
Addresses []netip.Prefix Addresses []netip.Prefix
AllowedIPs []netip.Prefix AllowedIPs []netip.Prefix
Endpoints []string Endpoints []string
DERP string DERP string
Hostinfo HostinfoView Hostinfo HostinfoView
Created time.Time Created time.Time
Cap CapabilityVersion Cap CapabilityVersion
Tags []string Tags []string
PrimaryRoutes []netip.Prefix PrimaryRoutes []netip.Prefix
LastSeen *time.Time LastSeen *time.Time
Online *bool Online *bool
KeepAlive bool KeepAlive bool
MachineAuthorized bool MachineAuthorized bool
Capabilities []string Capabilities []string
UnsignedPeerAPIOnly bool UnsignedPeerAPIOnly bool
ComputedName string ComputedName string
computedHostIfDifferent string computedHostIfDifferent string
ComputedNameWithHost string ComputedNameWithHost string
DataPlaneAuditLogID string DataPlaneAuditLogID string
Expired bool Expired bool
SelfNodeV4MasqAddrForThisPeer netip.Addr
}{}) }{})
// Clone makes a deep copy of Hostinfo. // Clone makes a deep copy of Hostinfo.

View File

@ -176,40 +176,44 @@ func (v NodeView) ComputedName() string { return v.ж.ComputedName
func (v NodeView) ComputedNameWithHost() string { return v.ж.ComputedNameWithHost } func (v NodeView) ComputedNameWithHost() string { return v.ж.ComputedNameWithHost }
func (v NodeView) DataPlaneAuditLogID() string { return v.ж.DataPlaneAuditLogID } func (v NodeView) DataPlaneAuditLogID() string { return v.ж.DataPlaneAuditLogID }
func (v NodeView) Expired() bool { return v.ж.Expired } func (v NodeView) Expired() bool { return v.ж.Expired }
func (v NodeView) Equal(v2 NodeView) bool { return v.ж.Equal(v2.ж) } func (v NodeView) SelfNodeV4MasqAddrForThisPeer() netip.Addr {
return v.ж.SelfNodeV4MasqAddrForThisPeer
}
func (v NodeView) Equal(v2 NodeView) bool { return v.ж.Equal(v2.ж) }
// A compilation failure here means this code must be regenerated, with the command at the top of this file. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _NodeViewNeedsRegeneration = Node(struct { var _NodeViewNeedsRegeneration = Node(struct {
ID NodeID ID NodeID
StableID StableNodeID StableID StableNodeID
Name string Name string
User UserID User UserID
Sharer UserID Sharer UserID
Key key.NodePublic Key key.NodePublic
KeyExpiry time.Time KeyExpiry time.Time
KeySignature tkatype.MarshaledSignature KeySignature tkatype.MarshaledSignature
Machine key.MachinePublic Machine key.MachinePublic
DiscoKey key.DiscoPublic DiscoKey key.DiscoPublic
Addresses []netip.Prefix Addresses []netip.Prefix
AllowedIPs []netip.Prefix AllowedIPs []netip.Prefix
Endpoints []string Endpoints []string
DERP string DERP string
Hostinfo HostinfoView Hostinfo HostinfoView
Created time.Time Created time.Time
Cap CapabilityVersion Cap CapabilityVersion
Tags []string Tags []string
PrimaryRoutes []netip.Prefix PrimaryRoutes []netip.Prefix
LastSeen *time.Time LastSeen *time.Time
Online *bool Online *bool
KeepAlive bool KeepAlive bool
MachineAuthorized bool MachineAuthorized bool
Capabilities []string Capabilities []string
UnsignedPeerAPIOnly bool UnsignedPeerAPIOnly bool
ComputedName string ComputedName string
computedHostIfDifferent string computedHostIfDifferent string
ComputedNameWithHost string ComputedNameWithHost string
DataPlaneAuditLogID string DataPlaneAuditLogID string
Expired bool Expired bool
SelfNodeV4MasqAddrForThisPeer netip.Addr
}{}) }{})
// View returns a readonly view of Hostinfo. // View returns a readonly view of Hostinfo.