Skip to content

hibare/headscale-client-go

Repository files navigation

Headscale Client Go

Go Reference Go Report Card

A client implementation for the Headscale HTTP API.

Example (Using API Key)

package main

import (
	"context"
	"fmt"
	"log/slog"
	"os"

	hsClient "github.com/hibare/headscale-client-go"
)

func main() {
	slog.SetLogLoggerLevel(slog.LevelDebug) // Optional

	serverUrl := os.Getenv("HS_SERVER_URL")
	apiToken := os.Getenv("HS_API_TOKEN")

	client, err := hsClient.NewClient(serverUrl, apiToken, hsClient.HeadscaleClientOptions{})
	if err != nil {
		panic(err)
	}

	nodes, err := client.Nodes().List(context.Background())
	if err != nil {
		panic(err)
	}

	for _, node := range nodes.Nodes {
		fmt.Printf("Node: %s\n", node.Name)
	}

}

About

A client implementation for the Headscale HTTP API

Topics

Resources

License

Stars

Watchers

Forks

Languages