Documentation
¶
Index ¶
- type ActionLog
- type AgentKey
- type DB
- func (db *DB) Close() error
- func (db *DB) Conn() *sql.DB
- func (db *DB) DeleteAgentKey(id string) error
- func (db *DB) DeleteUpstream(name string) error
- func (db *DB) GetAgentKey(id string) (*AgentKey, error)
- func (db *DB) Insert(log ActionLog) error
- func (db *DB) InsertAgentKey(id, publicKey, label string) error
- func (db *DB) InsertUpstream(u UpstreamRow) error
- func (db *DB) ListAgentKeys(includeInactive bool) ([]AgentKey, error)
- func (db *DB) ListUpstreams() ([]UpstreamRow, error)
- func (db *DB) LoadConfig(key string) (string, error)
- func (db *DB) LoadConfigPrefix(prefix string) (map[string]string, error)
- func (db *DB) Purge(retentionDays int) (int64, error)
- func (db *DB) QueryLogs(opts QueryOptions) ([]ActionLog, error)
- func (db *DB) SaveConfig(key, value string) error
- func (db *DB) SchemaVersion() (int, error)
- func (db *DB) UpdateUpstream(name string, u UpstreamRow) error
- type QueryOptions
- type UpstreamRow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionLog ¶
type ActionLog struct {
Timestamp time.Time `json:"timestamp"`
AgentIDHash string `json:"agent_id_hash"`
Method string `json:"method"`
Direction string `json:"direction"`
Success bool `json:"success"`
LatencyMs float64 `json:"latency_ms"`
PayloadSize int `json:"payload_size"`
AuthStatus string `json:"auth"`
ErrorCode string `json:"error_code"`
IPAddress string `json:"ip"`
UpstreamName string `json:"upstream_name"`
}
ActionLog represents a single intercepted message log entry.
type AgentKey ¶ added in v1.0.0
type AgentKey struct {
ID string `json:"id"`
PublicKey string `json:"public_key"`
Label string `json:"label"`
CreatedAt string `json:"created_at"`
Active bool `json:"active"`
}
AgentKey represents a registered agent public key.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB wraps a SQLite connection.
func Open ¶
Open opens (or creates) a SQLite database at path, enables WAL mode, and runs migrations.
func (*DB) DeleteAgentKey ¶ added in v1.0.0
DeleteAgentKey soft-deletes an agent key by setting active=0.
func (*DB) DeleteUpstream ¶ added in v1.0.0
DeleteUpstream soft-deletes an upstream.
func (*DB) GetAgentKey ¶ added in v1.0.0
GetAgentKey retrieves a single active agent key by ID.
func (*DB) InsertAgentKey ¶ added in v1.0.0
InsertAgentKey stores a new agent public key.
func (*DB) InsertUpstream ¶ added in v1.0.0
func (db *DB) InsertUpstream(u UpstreamRow) error
InsertUpstream adds a new upstream.
func (*DB) ListAgentKeys ¶ added in v1.0.0
ListAgentKeys returns all agent keys, optionally including inactive ones.
func (*DB) ListUpstreams ¶ added in v1.0.0
func (db *DB) ListUpstreams() ([]UpstreamRow, error)
ListUpstreams returns all active upstreams.
func (*DB) LoadConfig ¶ added in v1.0.0
LoadConfig retrieves a single value from admin_config by key.
func (*DB) LoadConfigPrefix ¶ added in v1.0.0
LoadConfigPrefix returns all admin_config entries whose key starts with prefix.
func (*DB) Purge ¶
Purge deletes log entries older than retentionDays days. Returns the number of rows deleted.
func (*DB) QueryLogs ¶
func (db *DB) QueryLogs(opts QueryOptions) ([]ActionLog, error)
QueryLogs returns log entries matching opts, ordered newest-first.
func (*DB) SaveConfig ¶ added in v1.0.0
SaveConfig stores a key-value pair in the admin_config table.
func (*DB) SchemaVersion ¶
SchemaVersion returns the current schema version (for diagnostics).
func (*DB) UpdateUpstream ¶ added in v1.0.0
func (db *DB) UpdateUpstream(name string, u UpstreamRow) error
UpdateUpstream modifies an existing upstream.
type QueryOptions ¶
type QueryOptions struct {
Last int
AgentHash string
Since time.Duration
Method string
UpstreamName string
}
QueryOptions controls which log entries are returned by QueryLogs.
type UpstreamRow ¶ added in v1.0.0
type UpstreamRow struct {
Name string `json:"name"`
URL string `json:"url"`
MatchHost string `json:"match_host"`
MatchPrefix string `json:"match_prefix"`
StripPrefix bool `json:"strip_prefix"`
Transport string `json:"transport"`
TLSSkipVerify bool `json:"tls_skip_verify"`
Active bool `json:"active"`
CreatedAt string `json:"created_at"`
}
UpstreamRow represents a row in the upstreams table.