store

package
v0.0.0-...-b256af6 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package store keeps SSH hosts and the panel key in SQLite.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound reports a host that does not exist.
	ErrNotFound = errors.New("host not found")
	// ErrConflict reports a duplicate host name.
	ErrConflict = errors.New("a host with this name exists")
)

Functions

This section is empty.

Types

type SQLite

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

SQLite stores hosts. Its tables are prefixed "ssh_", so the database can be shared with other modules. Passwords and private keys are stored as given: protect the database file.

func New

func New(ctx context.Context, db *sql.DB) (*SQLite, error)

New migrates the ssh_ tables in db, which the caller owns and may share with other modules.

func Open

func Open(ctx context.Context, path string) (*SQLite, error)

Open opens (creating if needed) a database file of its own at path.

func (*SQLite) Close

func (s *SQLite) Close() error

Close closes the database if Open opened it.

func (*SQLite) Connected

func (s *SQLite) Connected(ctx context.Context, id int64, hostKey string) error

Connected records a successful connection and pins hostKey if the host had none.

func (*SQLite) Create

func (s *SQLite) Create(ctx context.Context, h *hosts.Host) error

Create inserts h and sets its ID and timestamps.

func (*SQLite) Delete

func (s *SQLite) Delete(ctx context.Context, id int64) error

Delete removes a host; removing a missing host succeeds.

func (*SQLite) ForgetHostKey

func (s *SQLite) ForgetHostKey(ctx context.Context, id int64) error

ForgetHostKey clears a host's pinned key, so the next connection pins whatever the server offers.

func (*SQLite) Get

func (s *SQLite) Get(ctx context.Context, id int64) (hosts.Host, error)

Get returns one host.

func (*SQLite) List

func (s *SQLite) List(ctx context.Context) ([]hosts.Host, error)

List returns every host by name.

func (*SQLite) SetSetting

func (s *SQLite) SetSetting(ctx context.Context, key, value string) error

SetSetting stores a setting.

func (*SQLite) Setting

func (s *SQLite) Setting(ctx context.Context, key string) (string, error)

Setting returns a stored setting, or "" when unset.

func (*SQLite) Update

func (s *SQLite) Update(ctx context.Context, h *hosts.Host) error

Update replaces h's fields, including its pinned host key.

Jump to

Keyboard shortcuts

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