sqlite

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Level2SchemaVersion is the version of the SQLite schema understood by this backend.
	// Whenever changes to the schema are made, this version number should be increased
	// to prevent data corruption between incompatible database schemas.
	Level2SchemaVersion = 1
	// Level2Schema is the SQLite database layout.
	Level2Schema = `
	CREATE TABLE ASHost (
		Protocol	INTEGER NOT NULL,
		SrcIsdID	INTEGER NOT NULL,
		SrcAsID	INTEGER NOT NULL,
		DstIsdID	INTEGER NOT NULL,
		DstAsID	INTEGER NOT NULL,
		DstHostIP	TEXT,
		EpochBegin	INTEGER NOT NULL,
		EpochEnd	INTEGER NOT NULL,
		Key	BLOB NOT NULL,
		PRIMARY KEY (Protocol, SrcIsdID, SrcAsID,` +
		` DstIsdID, DstAsID, DstHostIP, EpochBegin)
	);

	CREATE TABLE HostAS (
		Protocol	INTEGER NOT NULL,
		SrcIsdID	INTEGER NOT NULL,
		SrcAsID	INTEGER NOT NULL,
		DstIsdID	INTEGER NOT NULL,
		DstAsID	INTEGER NOT NULL,
		SrcHostIP	TEXT,
		EpochBegin	INTEGER NOT NULL,
		EpochEnd	INTEGER NOT NULL,
		Key	BLOB NOT NULL,
		PRIMARY KEY (Protocol, SrcIsdID, SrcAsID,` +
		` DstIsdID, DstAsID, SrcHostIP, EpochBegin)
	);

	CREATE TABLE HostHost (
		Protocol	INTEGER NOT NULL,
		SrcIsdID	INTEGER NOT NULL,
		SrcAsID	INTEGER NOT NULL,
		DstIsdID	INTEGER NOT NULL,
		DstAsID	INTEGER NOT NULL,
		SrcHostIP	TEXT,
		DstHostIP	TEXT,
		EpochBegin	INTEGER NOT NULL,
		EpochEnd	INTEGER NOT NULL,
		Key	BLOB NOT NULL,
		PRIMARY KEY (Protocol, SrcIsdID, SrcAsID,` +
		` DstIsdID, DstAsID, SrcHostIP, DstHostIP, EpochBegin)
	);
	`
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

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

Backend implements a level 2 drkey DB with sqlite.

func NewBackend

func NewBackend(path string) (*Backend, error)

NewBackend creates a database and prepares all statements.

func (*Backend) Close

func (b *Backend) Close() error

Close closes the database connection.

func (Backend) DeleteExpiredASHostKeys

func (e Backend) DeleteExpiredASHostKeys(ctx context.Context, cutoff time.Time) (int, error)

DeleteExpiredASHostKeys removes all expired AS-Host keys, i.e. those keys which expiration time is strictly less than the cutoff

func (Backend) DeleteExpiredHostASKeys

func (e Backend) DeleteExpiredHostASKeys(ctx context.Context, cutoff time.Time) (int, error)

DeleteExpiredHostASKeys removes all expired Host-AS keys, i.e. those keys which expiration time is strictly less than the cutoff

func (Backend) DeleteExpiredHostHostKeys

func (e Backend) DeleteExpiredHostHostKeys(ctx context.Context, cutoff time.Time) (int, error)

DeleteExpiredHostHostKeys removes all expired Host-Host keys, i.e. those keys which expiration time is strictly less than the cutoff

func (Backend) GetASHostKey

func (e Backend) GetASHostKey(
	ctx context.Context,
	meta drkey.ASHostMeta) (drkey.ASHostKey, error)

GetASHostKey takes metadata information for the ASHost key and a timestamp at which it should be valid and returns the corresponding key.

func (Backend) GetHostASKey

func (e Backend) GetHostASKey(
	ctx context.Context,
	meta drkey.HostASMeta) (drkey.HostASKey, error)

GetHostASKey takes metadata information for the HostAS key and a timestamp at which it should be valid and returns the corresponding key.

func (Backend) GetHostHostKey

func (e Backend) GetHostHostKey(
	ctx context.Context,
	meta drkey.HostHostMeta) (drkey.HostHostKey, error)

GetHostHostKey takes metadata information for the HostHost key and a timestamp at which it should be valid and returns the corresponding key.

func (Backend) InsertASHostKey

func (e Backend) InsertASHostKey(ctx context.Context, key drkey.ASHostKey) error

InsertASHostKey inserts a ASHost key.

func (Backend) InsertHostASKey

func (e Backend) InsertHostASKey(ctx context.Context, key drkey.HostASKey) error

InsertHostASKey inserts a HostAS key.

func (Backend) InsertHostHostKey

func (e Backend) InsertHostHostKey(ctx context.Context, key drkey.HostHostKey) error

InsertHostHostKey inserts a HostHost key.

func (*Backend) SetMaxIdleConns

func (b *Backend) SetMaxIdleConns(maxIdleConns int)

SetMaxIdleConns sets the maximum number of idle connections.

func (*Backend) SetMaxOpenConns

func (b *Backend) SetMaxOpenConns(maxOpenConns int)

SetMaxOpenConns sets the maximum number of open connections.

Jump to

Keyboard shortcuts

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