firewalldb

package
v0.15.0-alpha.rc2 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2025 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DBFilename is the default filename of the rules' database.
	DBFilename = "rules.db"

	// DefaultRulesDBTimeout is the default maximum time we wait for the
	// db bbolt database to be opened. If the database is already
	// opened by another process, the unique lock cannot be obtained. With
	// the timeout we error out after the given time instead of just
	// blocking for forever.
	DefaultRulesDBTimeout = 5 * time.Second
)
View Source
const Subsystem = "FWDB"

Variables

View Source
var (
	// ErrDuplicateRealValue is returned when an attempt is made to insert
	// a new real-pseudo pair into the db, but the real value already exists
	// in the db.
	ErrDuplicateRealValue = errors.New("an entry with the given real " +
		"value already exists")

	// ErrDuplicatePseudoValue is returned when an attempt is made to
	// insert a new real-pseudo pair into the db, but the pseudo value
	// already exists in the db.
	ErrDuplicatePseudoValue = errors.New("an entry with the given pseudo " +
		"value already exists")
)
View Source
var (

	// ErrDBReversion is returned when detecting an attempt to revert to a
	// prior database version.
	ErrDBReversion = errors.New("cannot revert to prior version")
)
View Source
var (
	// ErrNoSuchKeyFound is returned when there is no key-value pair found
	// for the given key.
	ErrNoSuchKeyFound = fmt.Errorf("no such key found")
)

Functions

func DecodeChannelPoint

func DecodeChannelPoint(cp string) (string, uint32, error)

func HideBytes

func HideBytes(ctx context.Context, tx PrivacyMapTx, realBytes []byte) ([]byte,
	error)

func HideChanPoint

func HideChanPoint(ctx context.Context, tx PrivacyMapTx, txid string,
	index uint32) (string, uint32, error)

func HideChanPointStr

func HideChanPointStr(ctx context.Context, tx PrivacyMapTx, cp string) (string,
	error)

func HideString

func HideString(ctx context.Context, tx PrivacyMapTx, real string) (string,
	error)

func HideUint64

func HideUint64(ctx context.Context, tx PrivacyMapTx, real uint64) (uint64,
	error)

func NewMockSessionDB

func NewMockSessionDB() *mockSessionDB

NewMockSessionDB creates a new mock privacy map details instance.

func NewPseudoChanPoint

func NewPseudoChanPoint() (string, error)

func NewPseudoStr

func NewPseudoStr(n int) (string, error)

func NewPseudoUint32

func NewPseudoUint32() uint32

func NewPseudoUint64

func NewPseudoUint64() (uint64, string)

func RevealBytes

func RevealBytes(ctx context.Context, tx PrivacyMapTx,
	pseudoBytes []byte) ([]byte, error)

func RevealChanPoint

func RevealChanPoint(ctx context.Context, tx PrivacyMapTx, txid string,
	index uint32) (string, uint32, error)

func RevealString

func RevealString(ctx context.Context, tx PrivacyMapTx, pseudo string) (string,
	error)

func RevealUint64

func RevealUint64(ctx context.Context, tx PrivacyMapTx, pseudo uint64) (uint64,
	error)

func SerializeAction

func SerializeAction(w io.Writer, action *Action) error

SerializeAction binary serializes the given action to the writer using the tlv format.

func StrToUint64

func StrToUint64(s string) (uint64, error)

func Uint64ToStr

func Uint64ToStr(i uint64) string

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

Types

type AccountsDB

type AccountsDB interface {
	// Account fetches the Account with the given id from the accounts
	// database.
	Account(ctx context.Context,
		id accounts.AccountID) (*accounts.OffChainBalanceAccount, error)
}

AccountsDB is an interface that abstracts the database operations needed firewalldb to be able to query the accounts database.

type Action

type Action struct {
	AddActionReq

	// AttemptedAt is the time at which this action was created.
	AttemptedAt time.Time

	// State represents the state of the Action.
	State ActionState

	// ErrorReason is the human-readable reason for why the action failed.
	// It will only be set if State is ActionStateError.
	ErrorReason string
}

Action represents an RPC call made through the firewall.

func DeserializeAction

func DeserializeAction(r io.Reader, sessionID session.ID) (*Action, error)

DeserializeAction deserializes an action from the given reader, expecting the data to be encoded in the tlv format.

type ActionDB

type ActionDB interface {
	// AddAction persists a new action to the database.
	AddAction(ctx context.Context, req *AddActionReq) (ActionLocator, error)

	// SetActionState finds the action specified by the ActionLocator and
	// sets its state to the given state.
	SetActionState(ctx context.Context, al ActionLocator,
		state ActionState, errReason string) error

	// ListActions returns a list of Actions that pass the filterFn
	// requirements. The query IndexOffset and MaxNum params can be used to
	// control the number of actions returned. The return values are the
	// list of actions, the last index and the total count (iff
	// query.CountTotal is set).
	ListActions(ctx context.Context, query *ListActionsQuery,
		options ...ListActionOption) ([]*Action, uint64, uint64, error)

	// GetActionsReadDB produces an ActionReadDB using the given group ID
	// and feature name.
	GetActionsReadDB(groupID session.ID, featureName string) ActionsReadDB
}

ActionDB is an interface that abstracts the database operations needed for the Action persistence and querying.

type ActionLocator

type ActionLocator interface {
	// contains filtered or unexported methods
}

ActionLocator helps us find an action in the database.

type ActionReadDBGetter

type ActionReadDBGetter interface {
	GetActionsReadDB(groupID session.ID, featureName string) ActionsReadDB
}

ActionReadDBGetter represents a function that can be used to construct an ActionsReadDB.

type ActionState

type ActionState uint8

ActionState represents the state of an action.

const (
	// ActionStateUnknown means that the action's state was never
	// initialised. This should never be the case.
	ActionStateUnknown ActionState = 0

	// ActionStateInit represents that an Action has been created but that
	// is still in the pending state.
	ActionStateInit ActionState = 1

	// ActionStateDone represents that an Action has been executed
	// successfully.
	ActionStateDone ActionState = 2

	// ActionStateError represents that an Action did not complete
	// successfully.
	ActionStateError ActionState = 3
)

type ActionsListDB

type ActionsListDB interface {
	// ListActions returns a  list of past Action items.
	ListActions(ctx context.Context) ([]*RuleAction, error)
}

ActionsListDB represents a DB backend that contains Action entries that can be queried. It allows us to abstract away the details of the data storage method.

type ActionsReadDB

type ActionsReadDB interface {
	GroupActionsDB() ActionsListDB
	GroupFeatureActionsDB() ActionsListDB
}

ActionsReadDB is an abstraction gives a caller access to either a group specific or group and feature specific rules.ActionDB.

type ActionsWriteDB

type ActionsWriteDB interface {
	AddAction(ctx context.Context, req *AddActionReq) (ActionLocator, error)
	SetActionState(ctx context.Context, al ActionLocator,
		state ActionState, errReason string) error
}

ActionsWriteDB is an abstraction over the Actions DB that will allow a caller to add new actions as well as change the values of an existing action.

type AddActionReq

type AddActionReq struct {
	// MacaroonIdentifier is a 4 byte identifier created from the last 4
	// bytes of the root key ID of the macaroon used to perform the action.
	// If no macaroon was used for the action, then this will not be set.
	MacaroonIdentifier fn.Option[[4]byte]

	// SessionID holds the optional session ID of the session that this
	// action was performed with.
	//
	// NOTE: for our BoltDB impl, this is not persisted in any way, and we
	// populate it by casting the macaroon ID to a session.ID and so is not
	// guaranteed to be linked to an existing session.
	SessionID fn.Option[session.ID]

	// AccountID holds the optional account ID of the account that this
	// action was performed on.
	//
	// NOTE: for our BoltDB impl, this is not persisted in any way, and we
	// do not populate it on reading from disk.
	AccountID fn.Option[accounts.AccountID]

	// ActorName is the name of the entity who performed the Action.
	ActorName string

	// FeatureName is the name of the feature that the Action is being
	// performed by.
	FeatureName string

	// Trigger is the meta info detailing what caused this action to be
	// executed.
	Trigger string

	// Intent is the meta info detailing what the intended outcome of this
	// action will be.
	Intent string

	// StructuredJsonData is extra, structured, info that the Autopilot can
	// send to Litd serialised as a json string.
	StructuredJsonData string

	// RPCMethod is the URI that was called.
	RPCMethod string

	// RPCParams is the method parameters of the request in JSON form.
	RPCParamsJson []byte
}

AddActionReq is the request that is used to add a new Action to the database. It contains all the information that is needed to create a new Action in the ActionStateInit State.

type BatchedSQLQueries

type BatchedSQLQueries interface {
	SQLQueries

	db.BatchedTx[SQLQueries]
}

BatchedSQLQueries is a version of the SQLQueries that's capable of batched database operations.

type BoltDB

type BoltDB struct {
	*bbolt.DB
	// contains filtered or unexported fields
}

BoltDB is a bolt-backed persistent store.

func NewBoltDB

func NewBoltDB(dir, fileName string, sessionIDIndex SessionDB,
	accountsDB AccountsDB, clock clock.Clock) (*BoltDB, error)

NewBoltDB creates a new bolt database that can be found at the given directory.

func NewTestDB

func NewTestDB(t *testing.T, clock clock.Clock) *BoltDB

NewTestDB is a helper function that creates an BBolt database for testing.

func NewTestDBFromPath

func NewTestDBFromPath(t *testing.T, dbPath string, clock clock.Clock) *BoltDB

NewTestDBFromPath is a helper function that creates a new BoltStore with a connection to an existing BBolt database for testing.

func NewTestDBWithSessions

func NewTestDBWithSessions(t *testing.T, sessStore SessionDB,
	clock clock.Clock) *BoltDB

NewTestDBWithSessions creates a new test BoltDB Store with access to an existing sessions DB.

func NewTestDBWithSessionsAndAccounts

func NewTestDBWithSessionsAndAccounts(t *testing.T, sessStore SessionDB,
	acctStore AccountsDB, clock clock.Clock) *BoltDB

NewTestDBWithSessionsAndAccounts creates a new test BoltDB Store with access to an existing sessions DB and accounts DB.

func (*BoltDB) AddAction

func (db *BoltDB) AddAction(ctx context.Context,
	req *AddActionReq) (ActionLocator, error)

AddAction serialises and adds an Action to the DB under the given sessionID.

func (*BoltDB) DeleteTempKVStores

func (db *BoltDB) DeleteTempKVStores(_ context.Context) error

DeleteTempKVStores deletes all kv-stores in the temporary namespace.

func (*BoltDB) GetActionsReadDB

func (db *BoltDB) GetActionsReadDB(groupID session.ID,
	featureName string) ActionsReadDB

GetActionsReadDB is a method on DB that constructs an ActionsReadDB.

func (*BoltDB) GetKVStores

func (db *BoltDB) GetKVStores(rule string, groupID session.ID,
	feature string) KVStores

GetKVStores constructs a new rules.KVStores backed by a bbolt db.

func (*BoltDB) ListActions

func (db *BoltDB) ListActions(ctx context.Context, query *ListActionsQuery,
	options ...ListActionOption) ([]*Action, uint64, uint64, error)

ListActions returns a list of Actions. The query IndexOffset and MaxNum params can be used to control the number of actions returned. ListActionOptions may be used to filter on specific Action values. The return values are the list of actions, the last index and the total count (iff query.CountTotal is set).

func (*BoltDB) PrivacyDB

func (db *BoltDB) PrivacyDB(groupID session.ID) PrivacyMapDB

PrivacyDB constructs a PrivacyMapDB that will be indexed under the given group ID key.

NOTE: this is part of the PrivacyMapper interface.

func (*BoltDB) SetActionState

func (db *BoltDB) SetActionState(_ context.Context, al ActionLocator,
	state ActionState, errorReason string) error

SetActionState finds the action specified by the ActionLocator and sets its state to the given state.

type DB

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

DB manages the firewall rules database.

func NewDB

func NewDB(dbs firewallDBs) *DB

NewDB creates a new firewall database. For now, it only contains the underlying rules' and privacy mapper databases.

func (*DB) Start

func (db *DB) Start(ctx context.Context) error

Start starts the firewall database.

func (*DB) Stop

func (db *DB) Stop() error

Stop stops the firewall database operations.

type DBExecutor

type DBExecutor[T any] interface {
	// Update opens a database read/write transaction and executes the
	// function f with the transaction passed as a parameter. After f exits,
	// if f did not error, the transaction is committed. Otherwise, if f did
	// error, the transaction is rolled back. If the rollback fails, the
	// original error returned by f is still returned. If the commit fails,
	// the commit error is returned.
	Update(ctx context.Context, f func(ctx context.Context,
		tx T) error) error

	// View opens a database read transaction and executes the function f
	// with the transaction passed as a parameter. After f exits, the
	// transaction is rolled back. If f errors, its error is returned, not a
	// rollback error (if any occur).
	View(ctx context.Context, f func(ctx context.Context,
		tx T) error) error
}

DBExecutor provides an Update and View method that will allow the caller to perform atomic read and write transactions defined by PrivacyMapTx on the underlying BoltDB.

type KVStore

type KVStore interface {
	// Get fetches the value under the given key from the underlying kv
	// store. If no value is found, nil is returned.
	Get(ctx context.Context, key string) ([]byte, error)

	// Set sets the given key-value pair in the underlying kv store.
	Set(ctx context.Context, key string, value []byte) error

	// Del deletes the value under the given key in the underlying kv store.
	Del(ctx context.Context, key string) error
}

KVStore is in interface representing a key value store. It allows us to abstract away the details of the data storage method.

type KVStoreTx

type KVStoreTx interface {
	// Global returns a persisted global, rule-name indexed, kv store. A
	// rule with a given name will have access to this store independent of
	// group ID or feature.
	Global() KVStore

	// Local returns a persisted local kv store for the rule. Depending on
	// how the implementation is initialised, this will either be under the
	// group ID namespace or the group ID _and_ feature name namespace.
	Local() KVStore

	// GlobalTemp is similar to the Global store except that its contents
	// is cleared upon restart of the database. The reason persisting the
	// temporary store changes instead of just keeping an in-memory store is
	// that we can then guarantee atomicity if changes are made to both
	// the permanent and temporary stores.
	GlobalTemp() KVStore

	// LocalTemp is similar to the Local store except that its contents is
	// cleared upon restart of the database. The reason persisting the
	// temporary store changes instead of just keeping an in-memory store is
	// that we can then guarantee atomicity if changes are made to both
	// the permanent and temporary stores.
	LocalTemp() KVStore
}

KVStoreTx represents a database transaction that can be used for both read and writes of the various different key value stores offered for the rule.

type KVStores

type KVStores = DBExecutor[KVStoreTx]

KVStores provides an Update and View method that will allow the caller to perform atomic read and write transactions on and of the key value stores offered the KVStoreTx.

type ListActionOption

type ListActionOption func(*listActionOptions)

ListActionOption is a functional option that can be used to tweak the behaviour of the ListActions method.

func WithActionActorName

func WithActionActorName(actorName string) ListActionOption

WithActionActorName is a ListActionOption that can be used to select all Actions that were performed by the given actor.

func WithActionEndTime

func WithActionEndTime(endTime time.Time) ListActionOption

WithActionEndTime is a ListActionOption that can be used to select all Actions that were attempted before the given time.

func WithActionFeatureName

func WithActionFeatureName(featureName string) ListActionOption

WithActionFeatureName is a ListActionOption that can be used to select all Actions that were performed by the given feature.

func WithActionGroupID

func WithActionGroupID(groupID session.ID) ListActionOption

WithActionGroupID is a ListActionOption that can be used to select all Actions performed under the give group ID.

func WithActionMethodName

func WithActionMethodName(methodName string) ListActionOption

WithActionMethodName is a ListActionOption that can be used to select all Actions that called the given RPC method.

func WithActionSessionID

func WithActionSessionID(sessionID session.ID) ListActionOption

WithActionSessionID is a ListActionOption that can be used to select all Actions performed under the given session ID.

func WithActionStartTime

func WithActionStartTime(startTime time.Time) ListActionOption

WithActionStartTime is a ListActionOption that can be used to select all Actions that were attempted after the given time.

func WithActionState

func WithActionState(state ActionState) ListActionOption

WithActionState is a ListActionOption that can be used to select all Actions that are in the given state.

type ListActionsQuery

type ListActionsQuery struct {
	// IndexOffset is index of the action to inspect.
	IndexOffset uint64

	// MaxNum is the maximum number of actions to return. If it is set to 0,
	// then no maximum is enforced.
	MaxNum uint64

	// Reversed indicates whether the actions should be returned in reverse
	// order.
	Reversed bool

	// CountAll should be set to true if the total number of actions that
	// satisfy the query should be counted and returned. Note that this will
	// make the query slower.
	CountAll bool
}

ListActionsQuery can be used to tweak the query to ListActions and listSessionActions.

type PrivacyMapDB

type PrivacyMapDB = DBExecutor[PrivacyMapTx]

PrivacyMapDB provides an Update and View method that will allow the caller to perform atomic read and write transactions defined by PrivacyMapTx on the underlying DB.

type PrivacyMapPairs

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

PrivacyMapPairs is an in memory implementation of the PrivacyMapReader.

func NewPrivacyMapPairs

func NewPrivacyMapPairs(m map[string]string) *PrivacyMapPairs

NewPrivacyMapPairs constructs a new PrivacyMapPairs struct. It may be initialised with either a nil map or a pre-defined real-to-pseudo strings map.

func (*PrivacyMapPairs) Add

func (p *PrivacyMapPairs) Add(pairs map[string]string) error

Add adds the passed set of real-to-pseudo pairs to the PrivacyMapPairs structure. It will throw an error if the new pairs conflict with any of the existing pairs.

func (*PrivacyMapPairs) GetPseudo

func (p *PrivacyMapPairs) GetPseudo(real string) (string, bool)

GetPseudo returns the associated pseudo value for a given real value. If no such real value exists in the DB, then false is returned.

NOTE: this is part of the PrivacyMapReader interface.

type PrivacyMapReader

type PrivacyMapReader interface {
	// GetPseudo returns the associated pseudo value for a given real value.
	// If no such real value exists in the DB, then false is returned.
	GetPseudo(real string) (string, bool)
}

PrivacyMapReader is an interface that gives read access to a privacy map DB.

type PrivacyMapTx

type PrivacyMapTx interface {
	// NewPair persists a new real-pseudo pair.
	NewPair(ctx context.Context, real, pseudo string) error

	// PseudoToReal returns the real value associated with the given pseudo
	// value. If no such pair is found, then ErrNoSuchKeyFound is returned.
	PseudoToReal(ctx context.Context, pseudo string) (string, error)

	// RealToPseudo returns the pseudo value associated with the given real
	// value. If no such pair is found, then ErrNoSuchKeyFound is returned.
	RealToPseudo(ctx context.Context, real string) (string, error)

	// FetchAllPairs loads and returns the real-to-pseudo pairs in the form
	// of a PrivacyMapPairs struct.
	FetchAllPairs(ctx context.Context) (*PrivacyMapPairs, error)
}

PrivacyMapTx represents a db that can be used to create, store and fetch real-pseudo pairs.

type PrivacyMapper

type PrivacyMapper interface {
	// PrivacyDB constructs a PrivacyMapDB that will be indexed under the
	// given group ID key.
	PrivacyDB(groupID session.ID) PrivacyMapDB
}

PrivacyMapper is an interface that abstracts access to the privacy mapper database.

type RuleAction

type RuleAction struct {
	// Method is the URI of the rpc method that was called.
	Method string

	// PerformedAt is the time at which the action was attempted.
	PerformedAt time.Time
}

RuleAction represents a method call that was performed at a certain time at a certain time.

type RulesDB

type RulesDB interface {
	// GetKVStores constructs a new rules.KVStores in a namespace defined
	// by the rule name, group ID and feature name.
	GetKVStores(rule string, groupID session.ID, feature string) KVStores

	// DeleteTempKVStores deletes all temporary kv stores.
	DeleteTempKVStores(ctx context.Context) error
}

RulesDB can be used to initialise a new rules.KVStores.

type SQLAccountQueries

type SQLAccountQueries interface {
	GetAccount(ctx context.Context, id int64) (sqlc.Account, error)
	GetAccountIDByAlias(ctx context.Context, alias int64) (int64, error)
}

SQLAccountQueries is a subset of the sqlc.Queries interface that can be used to interact with the accounts table.

type SQLActionQueries

type SQLActionQueries interface {
	SQLSessionQueries
	SQLAccountQueries

	InsertAction(ctx context.Context, arg sqlc.InsertActionParams) (int64, error)
	SetActionState(ctx context.Context, arg sqlc.SetActionStateParams) error
	ListActions(ctx context.Context, arg sqlc.ListActionsParams) ([]sqlc.Action, error)
	CountActions(ctx context.Context, arg sqlc.ActionQueryParams) (int64, error)
}

SQLActionQueries is a subset of the sqlc.Queries interface that can be used to interact with action related tables.

type SQLDB

type SQLDB struct {

	// BaseDB represents the underlying database connection.
	*db.BaseDB
	// contains filtered or unexported fields
}

SQLDB represents a storage backend.

func NewSQLDB

func NewSQLDB(sqlDB *db.BaseDB, clock clock.Clock) *SQLDB

NewSQLDB creates a new SQLStore instance given an open SQLQueries storage backend.

func (*SQLDB) AddAction

func (s *SQLDB) AddAction(ctx context.Context,
	req *AddActionReq) (ActionLocator, error)

AddAction persists the given action to the database.

NOTE: This is a part of the ActionDB interface.

func (*SQLDB) DeleteTempKVStores

func (s *SQLDB) DeleteTempKVStores(ctx context.Context) error

DeleteTempKVStores deletes all temporary kv stores.

NOTE: part of the RulesDB interface.

func (*SQLDB) GetActionsReadDB

func (s *SQLDB) GetActionsReadDB(groupID session.ID,
	featureName string) ActionsReadDB

GetActionsReadDB is a method on DB that constructs an ActionsReadDB.

NOTE: This is part of the ActionDB interface.

func (*SQLDB) GetKVStores

func (s *SQLDB) GetKVStores(rule string, groupAlias session.ID,
	feature string) KVStores

GetKVStores constructs a new rules.KVStores in a namespace defined by the rule name, group ID and feature name.

NOTE: part of the RulesDB interface.

func (*SQLDB) ListActions

func (s *SQLDB) ListActions(ctx context.Context,
	query *ListActionsQuery, options ...ListActionOption) ([]*Action,
	uint64, uint64, error)

ListActions returns a list of Actions. The query IndexOffset and MaxNum params can be used to control the number of actions returned. ListActionOptions may be used to filter on specific Action values. The return values are the list of actions, the last index and the total count (iff query.CountTotal is set).

NOTE: This is part of the ActionDB interface.

func (*SQLDB) PrivacyDB

func (s *SQLDB) PrivacyDB(groupID session.ID) PrivacyMapDB

PrivacyDB constructs a PrivacyMapDB that will be indexed under the given group ID key.

NOTE: this is part of the PrivacyMapper interface.

func (*SQLDB) SetActionState

func (s *SQLDB) SetActionState(ctx context.Context, al ActionLocator,
	state ActionState, errReason string) error

SetActionState finds the action specified by the ActionLocator and sets its state to the given state.

NOTE: This is a part of the ActionDB interface.

type SQLKVStoreQueries

type SQLKVStoreQueries interface {
	SQLSessionQueries

	DeleteFeatureKVStoreRecord(ctx context.Context, arg sqlc.DeleteFeatureKVStoreRecordParams) error
	DeleteGlobalKVStoreRecord(ctx context.Context, arg sqlc.DeleteGlobalKVStoreRecordParams) error
	DeleteSessionKVStoreRecord(ctx context.Context, arg sqlc.DeleteSessionKVStoreRecordParams) error
	GetFeatureKVStoreRecord(ctx context.Context, arg sqlc.GetFeatureKVStoreRecordParams) ([]byte, error)
	GetGlobalKVStoreRecord(ctx context.Context, arg sqlc.GetGlobalKVStoreRecordParams) ([]byte, error)
	GetSessionKVStoreRecord(ctx context.Context, arg sqlc.GetSessionKVStoreRecordParams) ([]byte, error)
	UpdateFeatureKVStoreRecord(ctx context.Context, arg sqlc.UpdateFeatureKVStoreRecordParams) error
	UpdateGlobalKVStoreRecord(ctx context.Context, arg sqlc.UpdateGlobalKVStoreRecordParams) error
	UpdateSessionKVStoreRecord(ctx context.Context, arg sqlc.UpdateSessionKVStoreRecordParams) error
	InsertKVStoreRecord(ctx context.Context, arg sqlc.InsertKVStoreRecordParams) error
	DeleteAllTempKVStores(ctx context.Context) error
	GetOrInsertFeatureID(ctx context.Context, name string) (int64, error)
	GetOrInsertRuleID(ctx context.Context, name string) (int64, error)
	GetFeatureID(ctx context.Context, name string) (int64, error)
	GetRuleID(ctx context.Context, name string) (int64, error)
}

SQLKVStoreQueries is a subset of the sqlc.Queries interface that can be used to interact with the kvstore tables.

type SQLPrivacyPairQueries

type SQLPrivacyPairQueries interface {
	SQLSessionQueries

	InsertPrivacyPair(ctx context.Context, arg sqlc.InsertPrivacyPairParams) error
	GetAllPrivacyPairs(ctx context.Context, groupID int64) ([]sqlc.GetAllPrivacyPairsRow, error)
	GetPseudoForReal(ctx context.Context, arg sqlc.GetPseudoForRealParams) (string, error)
	GetRealForPseudo(ctx context.Context, arg sqlc.GetRealForPseudoParams) (string, error)
}

SQLPrivacyPairQueries is a subset of the sqlc.Queries interface that can be used to interact with the privacy map table.

type SQLQueries

SQLQueries is a subset of the sqlc.Queries interface that can be used to interact with various firewalldb tables.

type SQLSessionQueries

type SQLSessionQueries interface {
	GetSessionIDByAlias(ctx context.Context, legacyID []byte) (int64, error)
	GetAliasBySessionID(ctx context.Context, id int64) ([]byte, error)
}

SQLSessionQueries is a subset of the sqlc.Queries interface that can be used to interact with the session table.

type SessionDB

type SessionDB interface {
	session.IDToGroupIndex

	// GetSession returns the session for a specific id.
	GetSession(context.Context, session.ID) (*session.Session, error)
}

SessionDB is an interface that abstracts the database operations needed for the privacy mapper to function.

Jump to

Keyboard shortcuts

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