tailcfg: add peerRelay bool to hostinfo
This commit adds a bool named PeerRelay to Hostinfo, to identify the host's status of acting as a peer relay. Considering the RelayServerPort number can be 0, I just made this a bool in stead of a port number. If the port info is needed in future this would also help indicating if the port was set to 0 (meaning any port in peer relay context). Updates tailscale/corp#35862 Signed-off-by: KevinLiang10 <37811973+KevinLiang10@users.noreply.github.com>
This commit is contained in:
committed by
Harry Harpham
parent
9ba2a80ab6
commit
5eaaf9786b
@@ -5671,6 +5671,10 @@ func (b *LocalBackend) applyPrefsToHostinfoLocked(hi *tailcfg.Hostinfo, prefs ip
|
|||||||
}
|
}
|
||||||
hi.SSH_HostKeys = sshHostKeys
|
hi.SSH_HostKeys = sshHostKeys
|
||||||
|
|
||||||
|
if buildfeatures.HasRelayServer {
|
||||||
|
hi.PeerRelay = prefs.RelayServerPort().Valid()
|
||||||
|
}
|
||||||
|
|
||||||
for _, f := range hookMaybeMutateHostinfoLocked {
|
for _, f := range hookMaybeMutateHostinfoLocked {
|
||||||
f(b, hi, prefs)
|
f(b, hi, prefs)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -887,6 +887,7 @@ type Hostinfo struct {
|
|||||||
UserspaceRouter opt.Bool `json:",omitzero"` // if the client's subnet router is running in userspace (netstack) mode
|
UserspaceRouter opt.Bool `json:",omitzero"` // if the client's subnet router is running in userspace (netstack) mode
|
||||||
AppConnector opt.Bool `json:",omitzero"` // if the client is running the app-connector service
|
AppConnector opt.Bool `json:",omitzero"` // if the client is running the app-connector service
|
||||||
ServicesHash string `json:",omitzero"` // opaque hash of the most recent list of tailnet services, change in hash indicates config should be fetched via c2n
|
ServicesHash string `json:",omitzero"` // opaque hash of the most recent list of tailnet services, change in hash indicates config should be fetched via c2n
|
||||||
|
PeerRelay bool `json:",omitzero"` // if the client is willing to relay traffic for other peers
|
||||||
ExitNodeID StableNodeID `json:",omitzero"` // the client’s selected exit node, empty when unselected.
|
ExitNodeID StableNodeID `json:",omitzero"` // the client’s selected exit node, empty when unselected.
|
||||||
|
|
||||||
// Location represents geographical location data about a
|
// Location represents geographical location data about a
|
||||||
|
|||||||
@@ -186,6 +186,7 @@ var _HostinfoCloneNeedsRegeneration = Hostinfo(struct {
|
|||||||
UserspaceRouter opt.Bool
|
UserspaceRouter opt.Bool
|
||||||
AppConnector opt.Bool
|
AppConnector opt.Bool
|
||||||
ServicesHash string
|
ServicesHash string
|
||||||
|
PeerRelay bool
|
||||||
ExitNodeID StableNodeID
|
ExitNodeID StableNodeID
|
||||||
Location *Location
|
Location *Location
|
||||||
TPM *TPMInfo
|
TPM *TPMInfo
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ func TestHostinfoEqual(t *testing.T) {
|
|||||||
"UserspaceRouter",
|
"UserspaceRouter",
|
||||||
"AppConnector",
|
"AppConnector",
|
||||||
"ServicesHash",
|
"ServicesHash",
|
||||||
|
"PeerRelay",
|
||||||
"ExitNodeID",
|
"ExitNodeID",
|
||||||
"Location",
|
"Location",
|
||||||
"TPM",
|
"TPM",
|
||||||
@@ -244,6 +245,16 @@ func TestHostinfoEqual(t *testing.T) {
|
|||||||
&Hostinfo{AppConnector: opt.Bool("false")},
|
&Hostinfo{AppConnector: opt.Bool("false")},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
&Hostinfo{PeerRelay: true},
|
||||||
|
&Hostinfo{PeerRelay: true},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
&Hostinfo{PeerRelay: true},
|
||||||
|
&Hostinfo{PeerRelay: false},
|
||||||
|
false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
&Hostinfo{ServicesHash: "73475cb40a568e8da8a045ced110137e159f890ac4da883b6b17dc651b3a8049"},
|
&Hostinfo{ServicesHash: "73475cb40a568e8da8a045ced110137e159f890ac4da883b6b17dc651b3a8049"},
|
||||||
&Hostinfo{ServicesHash: "73475cb40a568e8da8a045ced110137e159f890ac4da883b6b17dc651b3a8049"},
|
&Hostinfo{ServicesHash: "73475cb40a568e8da8a045ced110137e159f890ac4da883b6b17dc651b3a8049"},
|
||||||
|
|||||||
@@ -606,6 +606,9 @@ func (v HostinfoView) AppConnector() opt.Bool { return v.ж.AppConnector }
|
|||||||
// opaque hash of the most recent list of tailnet services, change in hash indicates config should be fetched via c2n
|
// opaque hash of the most recent list of tailnet services, change in hash indicates config should be fetched via c2n
|
||||||
func (v HostinfoView) ServicesHash() string { return v.ж.ServicesHash }
|
func (v HostinfoView) ServicesHash() string { return v.ж.ServicesHash }
|
||||||
|
|
||||||
|
// if the client is willing to relay traffic for other peers
|
||||||
|
func (v HostinfoView) PeerRelay() bool { return v.ж.PeerRelay }
|
||||||
|
|
||||||
// the client’s selected exit node, empty when unselected.
|
// the client’s selected exit node, empty when unselected.
|
||||||
func (v HostinfoView) ExitNodeID() StableNodeID { return v.ж.ExitNodeID }
|
func (v HostinfoView) ExitNodeID() StableNodeID { return v.ж.ExitNodeID }
|
||||||
|
|
||||||
@@ -664,6 +667,7 @@ var _HostinfoViewNeedsRegeneration = Hostinfo(struct {
|
|||||||
UserspaceRouter opt.Bool
|
UserspaceRouter opt.Bool
|
||||||
AppConnector opt.Bool
|
AppConnector opt.Bool
|
||||||
ServicesHash string
|
ServicesHash string
|
||||||
|
PeerRelay bool
|
||||||
ExitNodeID StableNodeID
|
ExitNodeID StableNodeID
|
||||||
Location *Location
|
Location *Location
|
||||||
TPM *TPMInfo
|
TPM *TPMInfo
|
||||||
|
|||||||
Reference in New Issue
Block a user