A simple Go package that provides helper functions for working with Tailscale's API.
go get github.com/strombergdev/tailhelp
package main
import (
"log"
"github.com/strombergdev/tailhelp"
)
func main() {
// Get your Tailscale IPv4 address
ip, err := tailhelp.MyIP()
if err != nil {
log.Fatal(err)
}
log.Printf("My Tailscale IP: %v", ip)
// Find online peers with a specific hostname prefix
peers, err := tailhelp.PeersFromHostnamePrefix("myprefix", true)
if err != nil {
log.Fatal(err)
}
log.Printf("Found peer DNS names: %v", peers)
// Find IPv4 addresses of online peers with a specific hostname prefix
ips, err := tailhelp.PeerIPv4sFromHostnamePrefix("myprefix", true)
if err != nil {
log.Fatal(err)
}
log.Printf("Found peer IPs: %v", ips)
}
MyIP() (netip.Addr, error)
: Returns the first IPv4 address of your Tailscale nodePeersFromHostnamePrefix(hostname string, onlyOnline bool) ([]string, error)
: Returns a list of peer DNS names that match the given hostname prefixPeerIPv4sFromHostnamePrefix(hostname string, onlyOnline bool) ([]netip.Addr, error)
: Returns a list of IPv4 addresses for peers that match the given hostname prefix
- Go 1.19 or later
- Tailscale daemon running on the system
To create and publish a new release:
- Create and push a new tag:
git tag v0.0.1
git push origin v0.0.1 --tags
- Update your project to use the new version:
go get github.com/strombergdev/[email protected]
go mod tidy