storage

package
v0.0.0-...-5012d17 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

storage provides an embeddable database that bitmask uses to persist a series of values. For now, we store the following items in the database: - Introducer metadata. - Private bridges.

Index

Constants

This section is empty.

Variables

View Source
var AppName = "bitmask"

Functions

func MaybeGetBridgeByName

func MaybeGetBridgeByName(name string) (models.Bridge, error)

func MaybeGetIntroducerURLByName

func MaybeGetIntroducerURLByName(introducerName string) string

func MaybeUpdateLastUsedForIntroducer

func MaybeUpdateLastUsedForIntroducer(url string) error

MaybeUpdateLastUsedForIntroducer will attempt to update the LastUsed timestamp for the introducer that matches the passed URL.

Types

type Storage

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

func NewStorage

func NewStorage(path string) (*Storage, error)

NewStorage initializes a new storage with a given path. `NewStorageWithDefaultDir` should be preferred to initialize a storage, since it will try to pick a default path.

func NewStorageWithDefaultDir

func NewStorageWithDefaultDir() (*Storage, error)

func (*Storage) Close

func (s *Storage) Close()

Close closes the db connection

func (*Storage) DeleteBridge

func (s *Storage) DeleteBridge(id int, name string) error

DeleteBridge accepts a name and an ID. If you want to delete by name, pass 0 as the ID; if you want to delete by ID, pass the empty string as name.

func (*Storage) DeleteIntroducer

func (s *Storage) DeleteIntroducer(id int, name string) error

DeleteIntroducer accepts a name and an ID. If you want to delete by name, pass 0 as the ID; if you want to delete by ID, pass the empty string as name.

func (*Storage) GetBridgeByID

func (s *Storage) GetBridgeByID(id int) (models.Bridge, error)

GetBridgeByID will return the Bridge with the given ID, if found, and an error.

func (*Storage) GetBridgeByName

func (s *Storage) GetBridgeByName(name string) (models.Bridge, error)

GetBridgeByName will return the Bridge with the given Name, if found, and an error.

func (*Storage) GetBridgesByLocation

func (s *Storage) GetBridgesByLocation(location string) ([]models.Bridge, error)

GetBridgesByLocation will return all Bridges with the given Location, if found, and an error.

func (*Storage) GetBridgesByType

func (s *Storage) GetBridgesByType(bridgeType string) ([]models.Bridge, error)

GetBridgesByType will return all Bridges with the given Type, if found, and an error.

func (*Storage) GetIntroducerByID

func (s *Storage) GetIntroducerByID(id int) (models.Introducer, error)

GetIntroducerByID will return the Introducer with the given ID, if found, and an error.

func (*Storage) GetIntroducerByName

func (s *Storage) GetIntroducerByName(name string) (models.Introducer, error)

GetIntroducerByName will return the Introducer with the given Name, if found, and an error.

func (*Storage) ListBridges

func (s *Storage) ListBridges() ([]models.Bridge, error)

ListBridges returns an array of all the bridges.

func (*Storage) ListIntroducers

func (s *Storage) ListIntroducers() ([]models.Introducer, error)

ListIntroducers returns an array of all the introducers

func (*Storage) NewBridge

func (s *Storage) NewBridge(name, bridgeType, location, raw string) error

NewBridge creates a new Bridge from the passed parameters.

func (*Storage) NewIntroducer

func (s *Storage) NewIntroducer(name, url string) error

NewIntroducer creates a new Introducer from the name and URL.

Jump to

Keyboard shortcuts

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