blobcached

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: GPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IdentitiesFilename = "IDENTITIES"
	ActionsFilename    = "ACTIONS"
	ObjectsFilename    = "OBJECTS"
	GrantsFilename     = "GRANTS"
)

Variables

View Source
var Everyone = inet256.Everyone()

Functions

func AwaitHealthy

func AwaitHealthy(ctx context.Context, svc blobcache.Service) error

func DefaultActionsFile

func DefaultActionsFile() (ret string)

func DefaultGrantsFile

func DefaultGrantsFile() (ret string)

func DefaultIdentitiesFile

func DefaultIdentitiesFile() (ret string)

func DefaultObjectsFile

func DefaultObjectsFile() (ret string)

func LoadPrivateKey

func LoadPrivateKey(p string) (inet256.PrivateKey, error)

func ParseActionsFile

func ParseActionsFile(data []byte) (ret []groupfile.Entry[GroupName, Action], _ error)

func ParseIdentitiesFile

func ParseIdentitiesFile(data []byte) (ret []groupfile.Entry[GroupName, Identity], _ error)

ParseIdentitiesFiles parses a Group file into a list of identity group memberships.

func ParseObjectsFile

func ParseObjectsFile(data []byte) (ret []groupfile.Entry[GroupName, ObjectSet], _ error)

func ParsePeerLocs added in v0.0.3

func ParsePeerLocs(data []byte) ([]groupfile.Entry[blobcache.PeerID, netip.AddrPort], error)

func SavePrivateKey

func SavePrivateKey(p string, privKey inet256.PrivateKey) error

func WriteActionsFile

func WriteActionsFile(w io.Writer, actions []groupfile.Entry[GroupName, Action]) error

func WriteGrantsFile

func WriteGrantsFile(w io.Writer, grants []Grant) error

func WriteIdentitiesFile

func WriteIdentitiesFile(w io.Writer, ents []groupfile.Entry[GroupName, Identity]) error

WriteIdentitiesFile writes the memberships to the writer, such that they can be parsed by ParseIdentitiesFile. It inserts an extra newline every time the group changes from the previous membership.

func WriteObjectsFile

func WriteObjectsFile(w io.Writer, ents []groupfile.Entry[GroupName, ObjectSet]) error

Types

type Action

type Action string
const (
	Action_LOAD        Action = "LOAD"
	Action_SAVE        Action = "SAVE"
	Action_POST        Action = "POST"
	Action_GET         Action = "GET"
	Action_EXISTS      Action = "EXISTS"
	Action_DELETE      Action = "DELETE"
	Action_COPY_FROM   Action = "COPY_FROM"
	Action_COPY_TO     Action = "COPY_TO"
	Action_LINK_FROM   Action = "LINK_FROM"
	Action_LINK_TO     Action = "LINK_TO"
	Action_UNLINK_FROM Action = "UNLINK_FROM"
	Action_CLONE       Action = "CLONE"
	Action_CREATE      Action = "CREATE"
)

func AllActions

func AllActions() []Action

func ParseAction

func ParseAction(x []byte) (Action, error)

func (Action) String

func (a Action) String() string

func (Action) ToSet

func (a Action) ToSet() blobcache.ActionSet

type Daemon

type Daemon struct {
	StateDir string
}

Daemon manages the state and configuration for running a Blobache node.

func BGTestDaemon added in v0.0.2

func BGTestDaemon(t testing.TB) (*Daemon, string)

BGTestDaemon launches a test daemon and returns it and the API address. This function will block until the daemon is healthy. The daemon will be stopped and cleaned up at the end of the test. The test will fail during cleanup if the daemon fails to stop, and The test will not complete until the daemon is successfully torn down.

func (*Daemon) EnsureLocator added in v0.0.3

func (d *Daemon) EnsureLocator() (*Locator, error)

func (*Daemon) EnsurePolicyFiles

func (d *Daemon) EnsurePolicyFiles() error

EnsurePolicyFiles ensures that the policy files exist. Creating default files if they don't exist.

func (*Daemon) EnsurePrivateKey

func (d *Daemon) EnsurePrivateKey() (inet256.PrivateKey, error)

EnsurePrivateKey generates a private key if it doesn't exist, and returns it.

func (*Daemon) GetPeerID

func (d *Daemon) GetPeerID() (blobcache.PeerID, error)

func (*Daemon) GetPolicy

func (d *Daemon) GetPolicy() (*Policy, error)

func (*Daemon) Run

func (d *Daemon) Run(ctx context.Context, pc net.PacketConn, serveAPI net.Listener) error

Run runs the blobcache daemon, until the context is cancelled. If the context is cancelled, Run returns nil. Run returns an error if it returns for any other reason.

type Entry added in v0.0.3

type Entry[T any] = groupfile.Entry[GroupName, T]

func LoadActionsFile

func LoadActionsFile(p string) ([]Entry[Action], error)

LoadActionsFile loads the actions file from the filesystem. p should be the path to the actions file.

func LoadIdentitiesFile

func LoadIdentitiesFile(p string) ([]Entry[Identity], error)

LoadIdentitiesFile loads the identities file from the filesystem. p should be the path to the identities file.

func LoadObjectsFile

func LoadObjectsFile(p string) ([]Entry[ObjectSet], error)

LoadObjectsFile loads the objects file from the filesystem. p should be the path to the objects file.

type Grant

func LoadGrantsFile

func LoadGrantsFile(p string) ([]Grant, error)

LoadGrantsFile loads the grants file from the filesystem. p should be the path to the grants file.

func ParseGrantsFile

func ParseGrantsFile(r io.Reader) (ret []Grant, _ error)

func (*Grant) Equals

func (g *Grant) Equals(other Grant) bool

type GroupName

type GroupName string

func ParseGroupName

func ParseGroupName(x []byte) (GroupName, error)

func (GroupName) String added in v0.0.3

func (gn GroupName) String() string

type Identity

type Identity = blobcache.PeerID

func ParseIdentity

func ParseIdentity(x []byte) (Identity, error)

type Locator added in v0.0.3

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

func LoadLocator added in v0.0.3

func LoadLocator(p string) (*Locator, error)

LoadLocator creates a new locator using the PEER_LOC file at p

func (*Locator) WhereIs added in v0.0.3

func (loc *Locator) WhereIs(peer blobcache.PeerID) []netip.AddrPort

type Member

type Member[T any] = groupfile.Member[GroupName, T]

type Membership

type Membership[T any] = groupfile.Membership[GroupName, T]

type ObjectSet

type ObjectSet struct {
	// ByOID is a specific OID
	ByOID *blobcache.OID
	// All refers to all possible objects
	All *struct{}
}

ObjectSet is something that Actions are performed on. It can be a specific OID, or a set of names defined by a regular expression.

func ParseObject

func ParseObject(x []byte) (ObjectSet, error)

func (ObjectSet) Equals

func (o ObjectSet) Equals(other ObjectSet) bool

func (ObjectSet) String

func (o ObjectSet) String() string

type Policy

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

func LoadPolicy

func LoadPolicy(stateDir string) (*Policy, error)

LoadPolicy loads the 4 policy files from the filesystem. stateDir should be the path to the state directory.

func NewPolicy

func NewPolicy(idens []Membership[Identity], actions []Membership[Action], objects []Membership[ObjectSet], grants []Grant) (*Policy, error)

func (*Policy) AllActionGroups

func (p *Policy) AllActionGroups() iter.Seq[string]

func (*Policy) AllGrants

func (p *Policy) AllGrants() iter.Seq[Grant]

func (*Policy) AllIdentityGroups

func (p *Policy) AllIdentityGroups() iter.Seq[string]

func (*Policy) AllObjectGroups

func (p *Policy) AllObjectGroups() iter.Seq[string]

func (*Policy) CanConnect

func (p *Policy) CanConnect(peer blobcache.PeerID) bool

func (*Policy) CanCreate

func (p *Policy) CanCreate(peer blobcache.PeerID) bool

func (*Policy) IdentityMembersOf

func (p *Policy) IdentityMembersOf(group string) iter.Seq[Identity]

func (*Policy) IsIdentityDefined

func (p *Policy) IsIdentityDefined(iden Identity) bool

IsDefined returns true if the identity is a defined group, or a peer.

func (*Policy) OpenFiat

func (p *Policy) OpenFiat(peer blobcache.PeerID, target blobcache.OID) blobcache.ActionSet

Jump to

Keyboard shortcuts

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