Documentation
¶
Overview ¶
Package store keeps the server's files: config.toml (edited by people), state.json (paired devices, written by the server) and the secret store.
Index ¶
- func ClientDialAddr(dir string) (addr string, ok bool)
- func DefaultDir() string
- func SecretBackend() string
- func SystemLang() string
- type Config
- type DeviceRecord
- type Store
- func (s *Store) AddClientToken(id, token, label string) error
- func (s *Store) CheckClientToken(token string) bool
- func (s *Store) ClientTokens() []TokenRecord
- func (s *Store) Device(id string) (DeviceRecord, bool)
- func (s *Store) Devices() []DeviceRecord
- func (s *Store) PutDevice(d DeviceRecord) error
- func (s *Store) RemoveClientToken(id string) (bool, error)
- func (s *Store) RemoveDevice(id string) error
- func (s *Store) Secret(key string) string
- func (s *Store) SecretKeys(prefix string) []string
- func (s *Store) ServerID(newID func() string) (string, error)
- func (s *Store) SetRelayURL(url string) error
- func (s *Store) SetSecret(key, value string) error
- func (s *Store) TouchDevice(id string, now time.Time)
- type TokenRecord
- type Webhook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClientDialAddr ¶ added in v0.1.9
ClientDialAddr returns where a CLI on this PC should reach the server, from [client] listen in dir/config.toml. It only reads the file, so a missing or unreadable config gives ok false and the caller keeps its default. A listen address without a host, or on all interfaces, is dialled on 127.0.0.1.
func DefaultDir ¶
func DefaultDir() string
DefaultDir is %APPDATA%\Droidline on Windows, ~/Library/Application Support/Droidline on macOS and ~/.config/droidline elsewhere. DROIDLINE_HOME overrides it.
func SecretBackend ¶
func SecretBackend() string
func SystemLang ¶
func SystemLang() string
Types ¶
type Config ¶
type Config struct {
Name string `toml:"name"`
Lang string `toml:"lang"`
OfflineWait float64 `toml:"offline_wait"`
Agent struct {
Listen string `toml:"listen"`
} `toml:"agent"`
Client struct {
Listen string `toml:"listen"`
RequireToken bool `toml:"require_token"`
AllowedOrigins []string `toml:"allowed_origins"`
} `toml:"client"`
Discovery struct {
Listen string `toml:"listen"`
} `toml:"discovery"`
Pairing struct {
Code bool `toml:"code"`
} `toml:"pairing"`
Remote struct {
Addresses []string `toml:"addresses"`
} `toml:"remote"`
Relay struct {
URL string `toml:"url"`
} `toml:"relay"`
OCR struct {
Tesseract string `toml:"tesseract"`
} `toml:"ocr"`
Webhooks []Webhook `toml:"webhooks"`
}
type DeviceRecord ¶
type DeviceRecord struct {
ID string `json:"id"`
Name string `json:"name"`
Pub string `json:"pub"`
Model string `json:"model,omitempty"`
Manufacturer string `json:"manufacturer,omitempty"`
SDK int `json:"sdk,omitempty"`
Release string `json:"release,omitempty"`
Agent string `json:"agent,omitempty"`
PairedAt int64 `json:"paired_at"`
LastSeen int64 `json:"last_seen,omitempty"`
}
type Store ¶
func (*Store) AddClientToken ¶
func (*Store) CheckClientToken ¶
CheckClientToken compares hashes, so the token itself is never stored.
func (*Store) ClientTokens ¶
func (s *Store) ClientTokens() []TokenRecord
func (*Store) Devices ¶
func (s *Store) Devices() []DeviceRecord
func (*Store) PutDevice ¶
func (s *Store) PutDevice(d DeviceRecord) error
PutDevice inserts or replaces a device record by ID.
func (*Store) RemoveDevice ¶
func (*Store) SecretKeys ¶
SecretKeys lists secret names with the given prefix, sorted.
func (*Store) SetRelayURL ¶
SetRelayURL rewrites relay.url in config.toml in place so comments survive.