store

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: GPL-3.0 Imports: 12 Imported by: 0 modules, 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 是守卫侧的持久化层,以原子替换将扩展配对的长期共享密钥写入数据目录。

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNameTaken 表示名称已被另一个已配对的浏览器实例占用。
	ErrNameTaken = errors.New("browser instance name is already taken")
	// ErrInstanceNotFound 表示实例未登记,或已不再以调用方持有的密钥登记。
	ErrInstanceNotFound = errors.New("browser instance not found")
)

Functions

This section is empty.

Types

type BrowserInstance added in v0.2.0

type BrowserInstance struct {
	ID               string
	Name             string
	Key              []byte
	Product          string
	ProductVersion   string
	ExtensionVersion string
}

BrowserInstance 是一个已配对的浏览器实例:每实例一把长期密钥,名称在所有已配对实例中唯一。 产品与版本是最近一次连接时的自报信息,离线时仍可列出。

type BrowserRegistry added in v0.2.0

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

BrowserRegistry 以 0600 文件持久化已配对浏览器实例及其密钥。daemon 是该文件唯一的写者, 因此启动时加载一次、之后由内存副本应答读取;每次修改先原子落盘成功再更新内存。

func LoadBrowserRegistry added in v0.2.0

func LoadBrowserRegistry(path string) (*BrowserRegistry, error)

LoadBrowserRegistry 加载 path 处的登记表;文件不存在视为空表,内容损坏则报错。

func (*BrowserRegistry) Delete added in v0.2.0

func (r *BrowserRegistry) Delete(id string) error

Delete 删除实例及其密钥。

func (*BrowserRegistry) Get added in v0.2.0

Get 返回已登记实例的副本。

func (*BrowserRegistry) List added in v0.2.0

func (r *BrowserRegistry) List() []BrowserInstance

List 返回按名称排序的全部已登记实例副本。

func (*BrowserRegistry) Pair added in v0.2.0

func (r *BrowserRegistry) Pair(inst BrowserInstance) error

Pair 登记一次新配对:实例不存在则新增,已存在(同一实例重新配对)则替换其密钥与信息。

func (*BrowserRegistry) Update added in v0.2.0

func (r *BrowserRegistry) Update(inst BrowserInstance) error

Update 更新仍以同一密钥登记的实例的名称与信息。实例在握手之后被删除或重新配对时返回 ErrInstanceNotFound,使这条已过期的连接无法把登记写回。

type KeyStore

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

KeyStore 以 0600 权限持久化扩展配对的长期共享密钥 K。

func NewKeyStore

func NewKeyStore(path string) *KeyStore

NewKeyStore 返回落盘在 path 的密钥存储。

func (*KeyStore) Load

func (s *KeyStore) Load() (key []byte, ok bool, err error)

Load 读取长期密钥;文件不存在时返回 ok=false 而非错误。

func (*KeyStore) Save

func (s *KeyStore) Save(key []byte) error

Save 原子写入长期密钥,文件与目录权限分别为 0600 / 0700。重新配对时覆盖旧密钥。

Jump to

Keyboard shortcuts

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