tailcfg: add TailscaleSSHEnabled helper check (#4812)

This commit adds a helper to check if Tailscale SSH is enabled. We're
currently checking the SSH_HostKeys field in a few places, but later
plan to add an explicit bool. This helper makes the check and any future
changes easier.

Signed-off-by: Ross Zurowski <ross@rosszurowski.com>
This commit is contained in:
Ross Zurowski
2022-06-07 14:50:08 -04:00
committed by GitHub
parent 09363064b5
commit bb67999808
2 changed files with 35 additions and 0 deletions

View File

@@ -475,6 +475,14 @@ type Hostinfo struct {
// require changes to Hostinfo.Equal.
}
// TailscaleSSHEnabled reports whether or not this node is acting as a
// Tailscale SSH server.
func (hi *Hostinfo) TailscaleSSHEnabled() bool {
// Currently, we use `SSH_HostKeys` as a proxy for this. However, we may later
// include non-Tailscale host keys, and will add a separate flag to rely on.
return hi != nil && len(hi.SSH_HostKeys) > 0
}
// NetInfo contains information about the host's network state.
type NetInfo struct {
// MappingVariesByDestIP says whether the host's NAT mappings