hosts

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package hosts discovers the user's machines without connecting to any of them.

Candidates come from `tailscale status --json` (phones and expired nodes dropped, machines shared by other people marked) and from `~/.ssh/config` aliases (following Include; Match blocks are left to ssh). The two lists are merged by address and name. Consent and host-key trust are recorded elsewhere (config and package transport); a machine is contacted only after the user allows it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alias

type Alias struct {
	Names    []string // every name on the Host line
	HostName string
	User     string
	Port     string
}

Alias is one concrete Host entry from ssh config (wildcard patterns are skipped).

func SSHConfigAliases

func SSHConfigAliases(path string) []Alias

SSHConfigAliases lists concrete Host aliases from an ssh config file and the files it Includes. Real connection settings are always resolved later with `ssh -G`, which handles Match, ProxyJump and every other directive exactly like ssh.

type Candidate

type Candidate struct {
	Name        string   `json:"name"`        // short label
	Destination string   `json:"destination"` // what ssh is given
	Via         []string `json:"via"`         // tailscale, ssh-config
	OS          string   `json:"os,omitempty"`
	Online      *bool    `json:"online,omitempty"` // tailscale's view, if known
	DNSName     string   `json:"dnsName,omitempty"`
	IPs         []string `json:"ips,omitempty"`
	Owner       string   `json:"owner,omitempty"`
	OtherOwner  bool     `json:"otherOwner,omitempty"` // shared into the tailnet by someone else
	SSHHostKeys []string `json:"sshHostKeys,omitempty"`
	Self        bool     `json:"self,omitempty"`
	LastSeen    string   `json:"lastSeen,omitempty"`
}

Candidate is a machine found by discovery. Discovery never connects to anything.

func Discover

func Discover(ctx context.Context) ([]Candidate, error)

Discover merges Tailscale peers and ~/.ssh/config aliases.

func Merge

func Merge(ts []Candidate, aliases []Alias) []Candidate

Merge joins Tailscale peers with ssh aliases that point at the same machine (by Tailscale IP, MagicDNS name or normalised host name). The alias becomes the destination because it carries the right user, port and keys.

func Tailscale

func Tailscale(ctx context.Context) ([]Candidate, error)

Tailscale lists tailnet peers that could run Claude Code (no phones or tablets, no expired nodes), marking the local node and nodes owned by other users.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL