aliasstore

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package aliasstore persists user-defined device nicknames in a JSON file, keyed by MAC address so a label survives DHCP address changes.

ponytail: a flat JSON map is right for a handful of hand-set nicknames: zero dependencies, human-editable, loaded once. Ceilings, none of which bite at this scale: the whole file is rewritten on every Set/Delete, and there is no cross-process lock. Move to an embedded KV or SQLite only if this ever grows to thousands of entries or concurrent writers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() (string, error)

DefaultPath returns the per-user location of the alias file (<user-config-dir>/netwp/aliases.json), creating the netwp directory.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a MAC-to-nickname map backed by a JSON file. Safe for concurrent use within one process.

func Open

func Open(path string) (*Store, error)

Open loads the store at path. A missing file yields an empty store; the file is created on the first Set.

func (*Store) Alias

func (s *Store) Alias(mac net.HardwareAddr) string

Alias implements core.AliasLookup.

func (*Store) Delete

func (s *Store) Delete(mac net.HardwareAddr) error

Delete removes any nickname for mac and persists the change.

func (*Store) List

func (s *Store) List() []core.Alias

List returns all stored aliases sorted by MAC.

func (*Store) Set

func (s *Store) Set(mac net.HardwareAddr, name string) error

Set assigns name to mac and persists the change.

Jump to

Keyboard shortcuts

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