summaryrefslogtreecommitdiffhomepage
path: root/tailcfg
diff options
context:
space:
mode:
authorKevinLiang10 <37811973+KevinLiang10@users.noreply.github.com>2026-02-04 10:30:07 -0500
committerHarry Harpham <harry@tailscale.com>2026-02-06 18:25:40 -0700
commit5eaaf9786b84931ac3cba16cc4bc737e4b60502a (patch)
tree9114dc14eb58a19c24997979e50fd9314bc5801c /tailcfg
parent9ba2a80ab64f5507ca6e6cbba4e91d082ec2d8df (diff)
downloadtailscale-5eaaf9786b84931ac3cba16cc4bc737e4b60502a.tar.xz
tailscale-5eaaf9786b84931ac3cba16cc4bc737e4b60502a.zip
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>
Diffstat (limited to 'tailcfg')
-rw-r--r--tailcfg/tailcfg.go1
-rw-r--r--tailcfg/tailcfg_clone.go1
-rw-r--r--tailcfg/tailcfg_test.go11
-rw-r--r--tailcfg/tailcfg_view.go4
4 files changed, 17 insertions, 0 deletions
diff --git a/tailcfg/tailcfg.go b/tailcfg/tailcfg.go
index f76eb8f55..171f88fd7 100644
--- a/tailcfg/tailcfg.go
+++ b/tailcfg/tailcfg.go
@@ -887,6 +887,7 @@ type Hostinfo struct {
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
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.
// Location represents geographical location data about a
diff --git a/tailcfg/tailcfg_clone.go b/tailcfg/tailcfg_clone.go
index 483746145..a60f301d7 100644
--- a/tailcfg/tailcfg_clone.go
+++ b/tailcfg/tailcfg_clone.go
@@ -186,6 +186,7 @@ var _HostinfoCloneNeedsRegeneration = Hostinfo(struct {
UserspaceRouter opt.Bool
AppConnector opt.Bool
ServicesHash string
+ PeerRelay bool
ExitNodeID StableNodeID
Location *Location
TPM *TPMInfo
diff --git a/tailcfg/tailcfg_test.go b/tailcfg/tailcfg_test.go
index 4e9909db0..f649e43ab 100644
--- a/tailcfg/tailcfg_test.go
+++ b/tailcfg/tailcfg_test.go
@@ -67,6 +67,7 @@ func TestHostinfoEqual(t *testing.T) {
"UserspaceRouter",
"AppConnector",
"ServicesHash",
+ "PeerRelay",
"ExitNodeID",
"Location",
"TPM",
@@ -245,6 +246,16 @@ func TestHostinfoEqual(t *testing.T) {
false,
},
{
+ &Hostinfo{PeerRelay: true},
+ &Hostinfo{PeerRelay: true},
+ true,
+ },
+ {
+ &Hostinfo{PeerRelay: true},
+ &Hostinfo{PeerRelay: false},
+ false,
+ },
+ {
&Hostinfo{ServicesHash: "73475cb40a568e8da8a045ced110137e159f890ac4da883b6b17dc651b3a8049"},
&Hostinfo{ServicesHash: "73475cb40a568e8da8a045ced110137e159f890ac4da883b6b17dc651b3a8049"},
true,
diff --git a/tailcfg/tailcfg_view.go b/tailcfg/tailcfg_view.go
index b2734d8af..7960000fd 100644
--- a/tailcfg/tailcfg_view.go
+++ b/tailcfg/tailcfg_view.go
@@ -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
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.
func (v HostinfoView) ExitNodeID() StableNodeID { return v.ж.ExitNodeID }
@@ -664,6 +667,7 @@ var _HostinfoViewNeedsRegeneration = Hostinfo(struct {
UserspaceRouter opt.Bool
AppConnector opt.Bool
ServicesHash string
+ PeerRelay bool
ExitNodeID StableNodeID
Location *Location
TPM *TPMInfo