tailhelp

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2025 License: MIT Imports: 6 Imported by: 0

README

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 peers: %v", peers)
}

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

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
  1. Update your project to use the new version:
go get github.com/strombergdev/tailhelp@v0.0.1
go mod tidy

Documentation

Overview

Package tailhelp provides helper functions for working with Tailscale's API, making it easier to get information about the local node and its peers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MyIP

func MyIP() (netip.Addr, error)

MyIP returns the first IPv4 address of the local Tailscale node. Returns an error if no IPv4 address is found or if unable to get node status.

func PeersFromHostnamePrefix

func PeersFromHostnamePrefix(hostname string, onlyOnline bool) ([]string, error)

PeersFromHostnamePrefix returns a list of peer DNS names that match the given hostname prefix. If onlyOnline is true, only returns peers that are currently online. Returns an empty list if no matching peers are found.

Types

This section is empty.

Jump to

Keyboard shortcuts

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