storage package

import "code.pfad.fr/gohmekit/storage"

Index

func NewMemDatabase

NewMemDatabase is an in-memory database for testing (not thread-safe!)

type JSONFile

JSONFile implements pairing.Database and pairing.AccessoryDevice, storing their settings in a JSON file.

func NewJSONFile

NewJSONFile will use (and create if missing) a JSON file to act as a storage. It will use the given options, only if the concerned parameters are not already set. It will generate random pin and private key if let unspecified.

func (*JSONFile) AddLongTermPublicKey

AddLongTermPublicKey is defined by the pairing.Database interface.

func (*JSONFile) DiscoveryService

DiscoveryService returns a discovery service, ready to be announced.

func (*JSONFile) GetLongTermPublicKey

GetLongTermPublicKey is defined by the pairing.Database interface.

func (*JSONFile) IsPaired

IsPaired is defined by the pairing.Database interface.

func (*JSONFile) IsPairedWatcher

IsPairedWatcher will trigger the callback on pairing change. It will overwrite any existing callback.

func (*JSONFile) ListLongTermPublicKey

ListLongTermPublicKey is defined by the pairing.Database interface.

func (*JSONFile) RemoveLongTermPublicKey

RemoveLongTermPublicKey is defined by the pairing.Database interface.

func (*JSONFile) VersionWatcher

VersionWatcher will never trigger the callback, since the version is changed on every restart.

type Option

Option is to set some default values on first run.

func WithEd25519PrivateKey

WithEd25519PrivateKey will set the private key if it wasn't previously set.

func WithPairingID

WithPairingID will set the pairing ID if it wasn't previously set.

func WithPin

WithPin will set the pin if it wasn't previously set.

Source Files

jsonfile.go memory.go