Skip to content

strombergdev/tailhelp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tailhelp

A simple Go package that provides helper functions for working with Tailscale's API.

Installation

go get github.com/strombergdev/tailhelp

Usage

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)
}

Functions

  • MyIP() (netip.Addr, error): Returns the first IPv4 address of your Tailscale node
  • PeersFromHostnamePrefix(hostname string, onlyOnline bool) ([]string, error): Returns a list of peer DNS names that match the given hostname prefix
  • PeerIPv4sFromHostnamePrefix(hostname string, onlyOnline bool) ([]netip.Addr, error): Returns a list of IPv4 addresses for peers that match the given hostname prefix

Requirements

  • Go 1.19 or later
  • Tailscale daemon running on the system

Release Process

To create and publish a new release:

  1. Create and push a new tag:
git tag v0.0.1
git push origin v0.0.1 --tags
  1. Update your project to use the new version:
go get github.com/strombergdev/[email protected]
go mod tidy

About

Helper functions to get your Tailscale IP and your peers

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages