Documentation
¶
Overview ¶
Package sbot ties together network, repo and plugins like graph and blobs into a large server that offers data-access APIs and background replication. It's name dates back to a time where ssb-server was still called scuttlebot, in short: sbot.
Index ¶
- Constants
- func DropIndicies(r repo.Interface) error
- func RebuildIndicies(path string) error
- func ShutdownContext(ctx context.Context) (context.Context, context.CancelFunc)
- type ErrConsistencyProblems
- type FSCKMode
- type FSCKOption
- type FSCKUpdateFunc
- type MetaFeeds
- type MuxrpcEndpointWrapper
- type Option
- func DisableEBT(yes bool) Option
- func DisableLegacyLiveReplication(yes bool) Option
- func DisableLiveIndexMode() Option
- func DisableNetworkNode() Option
- func EnableAdvertismentBroadcasts(do bool) Option
- func EnableAdvertismentDialing(do bool) Option
- func LateOption(o Option) Option
- func MountMultiLog(name string, fn repo.MakeMultiLog) Option
- func MountPlugin(plug ssb.Plugin, mode plugins2.AuthMode) Option
- func MountSimpleIndex(name string, fn repo.MakeSimpleIndex) Option
- func WithAppKey(k []byte) Option
- func WithBlobStore(bs ssb.BlobStore) Option
- func WithContext(ctx context.Context) Option
- func WithDialer(dial netwrap.Dialer) Option
- func WithEndpointWrapper(mw MuxrpcEndpointWrapper) Option
- func WithEventMetrics(ctr metrics.Counter, lvls metrics.Gauge, lat metrics.Histogram) Option
- func WithHMACSigning(key []byte) Option
- func WithHops(h uint) Option
- func WithInfo(log kitlog.Logger) Option
- func WithJSONKeyPair(blob string) Option
- func WithKeyPair(kp ssb.KeyPair) Option
- func WithListenAddr(addr string) Option
- func WithMetaFeedMode(enable bool) Option
- func WithNamedKeyPair(name string) Option
- func WithNetworkConnTracker(ct ssb.ConnTracker) Option
- func WithPostSecureConnWrapper(cw netwrap.ConnWrapper) Option
- func WithPreSecureConnWrapper(cw netwrap.ConnWrapper) Option
- func WithPromisc(yes bool) Option
- func WithPublicAuthorizer(auth ssb.Authorizer) Option
- func WithReplicator(r ssb.Replicator) Option
- func WithRepoPath(path string) Option
- func WithUNIXSocket() Option
- func WithWebsocketAddress(addr string) Option
- type Sbot
- func (s *Sbot) Close() error
- func (s *Sbot) CurrentSequence(feed refs.FeedRef) (ssb.Note, error)
- func (sbot *Sbot) DontReplicate(r refs.FeedRef)
- func (s *Sbot) FSCK(opts ...FSCKOption) error
- func (s Sbot) Get(ref refs.MessageRef) (refs.Message, error)
- func (s *Sbot) GetIndexNamesMultiLog() []string
- func (s *Sbot) GetIndexNamesSimple() []string
- func (s *Sbot) GetMultiLog(name string) (multilog.MultiLog, bool)
- func (s *Sbot) GetSimpleIndex(name string) (librarian.Index, bool)
- func (s *Sbot) HealRepo(report ErrConsistencyProblems) error
- func (s *Sbot) NullContent(fr refs.FeedRef, seq uint) error
- func (s *Sbot) NullFeed(ref refs.FeedRef) error
- func (sbot *Sbot) PublishAs(nick string, val interface{}) (refs.MessageRef, error)
- func (sbot *Sbot) Replicate(r refs.FeedRef)
- func (sbot *Sbot) Status() (ssb.Status, error)
- func (s *Sbot) WaitUntilIndexesAreSynced()
- type SubfeedListEntry
Constants ¶
const FolderNameDelete = "drop-content-requests"
Variables ¶
This section is empty.
Functions ¶
func DropIndicies ¶
Drop indicies deletes the following folders of the indexes. TODO: check that sbot isn't running?
func RebuildIndicies ¶
func ShutdownContext ¶
ShutdownContext returns a context that returns ssb.ErrShuttingDown when canceld. The server internals use this error to cleanly shut down index processing.
Types ¶
type ErrConsistencyProblems ¶
type ErrConsistencyProblems struct { Errors []ssb.ErrWrongSequence Sequences *roaring.Bitmap }
func (ErrConsistencyProblems) Error ¶
func (e ErrConsistencyProblems) Error() string
type FSCKMode ¶
type FSCKMode uint
FSCKMode is an enum for the sbot.FSCK function
const ( // FSCKModeLength just checks the feed lengths FSCKModeLength FSCKMode // FSCKModeSequences makes sure the sequence field of each message on a feed are increasing correctly FSCKModeSequences )
type FSCKOption ¶
type FSCKOption func(*fsckOpt) error
func FSCKWithFeedIndex ¶
func FSCKWithFeedIndex(idx multilog.MultiLog) FSCKOption
func FSCKWithMode ¶
func FSCKWithMode(m FSCKMode) FSCKOption
func FSCKWithProgress ¶
func FSCKWithProgress(fn FSCKUpdateFunc) FSCKOption
type FSCKUpdateFunc ¶
FSCKUpdateFunc is called with the a percentage float between 0 and 100 and a durration who much time it should take, rounded to seconds.
type MetaFeeds ¶ added in v0.2.1
type MetaFeeds interface { // CreateSubFeed derives a new keypair, stores it in the keystore and publishes a `metafeed/add` message on the housing metafeed. // It takes purpose whic will be published and added to the keystore, too. // The subfeed will use the format CreateSubFeed(purpose string, format refs.RefAlgo) (refs.FeedRef, error) // TombstoneSubFeed removes the keypair from the store and publishes a `metafeed/tombstone` message to the feed. // Afterwards the referenced feed is unusable. TombstoneSubFeed(refs.FeedRef) error // ListSubFeeds returns a list of all _active_ subfeeds of the housing metafeed ListSubFeeds() ([]SubfeedListEntry, error) // Publish works like normal `Sbot.Publish()` but takes an additional feed reference, // which specifies the subfeed on which the content should be published. Publish(as refs.FeedRef, content interface{}) (refs.MessageRef, error) }
MetaFeeds allows managing and publishing to subfeeds of a metafeed.
type MuxrpcEndpointWrapper ¶
type MuxrpcEndpointWrapper func(muxrpc.Endpoint) muxrpc.Endpoint
MuxrpcEndpointWrapper can be used to wrap ever call a endpoint makes
type Option ¶
Option is a functional option type definition to change sbot behaviour
func DisableEBT ¶
DisableEBT disables epidemic broadcast trees. It's a new implementation and might have some bugs.
func DisableLegacyLiveReplication ¶
DisableLegacyLiveReplication controls wether createHistoryStreams are created with live:true flag. This code is functional but might not scale to a lot of feeds. Therefore this flag can be used to force the old non-live polling mode.
func DisableLiveIndexMode ¶
func DisableLiveIndexMode() Option
DisableLiveIndexMode makes the update processing halt once it reaches the end of the rootLog makes it easier to rebuild indicies.
func DisableNetworkNode ¶
func DisableNetworkNode() Option
DisableNetworkNode disables all networking, in turn it only serves the database.
func EnableAdvertismentBroadcasts ¶
EnableAdvertismentBroadcasts controls local peer discovery through sending UDP broadcasts
func EnableAdvertismentDialing ¶
EnableAdvertismentDialing controls local peer discovery through listening for and connecting to UDP broadcasts
func LateOption ¶
LateOption is a bit of a hack, it loads options after the _basic_ inititialisation is done (like repo location and keypair) this is mainly usefull for plugins that want to use a configured bot.
func MountMultiLog ¶
func MountMultiLog(name string, fn repo.MakeMultiLog) Option
func MountSimpleIndex ¶
func MountSimpleIndex(name string, fn repo.MakeSimpleIndex) Option
func WithAppKey ¶
WithAppKey changes the appkey (aka secret-handshake network cap). See https://ssbc.github.io/scuttlebutt-protocol-guide/#handshake for more.
func WithBlobStore ¶
WithBlobStore can be used to use a different storage backend for blobs.
func WithContext ¶
WithContext changes the context that is context.Background() by default. Handy to setup cancelation against a interup signal like ctrl+c. Canceling the context also shuts down indexing. If no context is passed sbot.Shutdown() can be used.
func WithDialer ¶
WithDialer changes the function that is used to dial remote peers. This could be a sock5 connection builder to support tor proxying to hidden services.
func WithEndpointWrapper ¶
func WithEndpointWrapper(mw MuxrpcEndpointWrapper) Option
WithEndpointWrapper sets a MuxrpcEndpointWrapper for new connections.
func WithEventMetrics ¶
WithEventMetrics sets up latency and counter metrics
func WithHMACSigning ¶
WithHMACSigning sets an HMAC signing key for messages. Useful for testing, see https://github.com/ssb-js/ssb-validate#state--validateappendstate-hmac_key-msg for more.
func WithHops ¶
WithHops sets the number of friends (or bi-directionla follows) to walk between two peers controls fetch depth (whos feeds to fetch. 0: only my own follows 1: my friends follows 2: also their friends follows and how many hops a peer can be from self to for a connection to be accepted
func WithJSONKeyPair ¶
WithJSONKeyPair expectes a JSON-string as blob and calls ssb.ParseKeyPair on it. This is useful if you dont't want to place the keypair on the filesystem.
func WithKeyPair ¶
WithKeyPair exepect a initialized ssb.KeyPair. Useful for testing.
func WithListenAddr ¶
WithListenAddr changes the muxrpc listener address. By default it listens to ':8008'.
func WithMetaFeedMode ¶ added in v0.2.1
WithMetaFeedMode enables metafeed support. It switches the default keypair to bendybutt and initializes the MetaFeed API of the Sbot.
func WithNamedKeyPair ¶
WithNamedKeyPair changes from the default `secret` file, useful for testing.
func WithNetworkConnTracker ¶
func WithNetworkConnTracker(ct ssb.ConnTracker) Option
WithNetworkConnTracker changes the connection tracker. See network.NewLastWinsTracker and network.NewAcceptAllTracker.
func WithPostSecureConnWrapper ¶
func WithPostSecureConnWrapper(cw netwrap.ConnWrapper) Option
WithPostSecureConnWrapper wrapps the connection before it is encrypted. Usefull to insepct the muxrpc frames before they go into boxstream.
func WithPreSecureConnWrapper ¶
func WithPreSecureConnWrapper(cw netwrap.ConnWrapper) Option
WithPreSecureConnWrapper wrapps the connection after it is encrypted. Usefull for debugging and measuring traffic.
func WithPromisc ¶
WithPromisc when enabled bypasses graph-distance lookups on connections and makes the gossip handler fetch the remotes feed
func WithPublicAuthorizer ¶
func WithPublicAuthorizer(auth ssb.Authorizer) Option
WithPublicAuthorizer configures who is considered "public" when accepting connections. By default, this is covered by the list of followed and blocked peers using the graph implementation.
func WithReplicator ¶
func WithReplicator(r ssb.Replicator) Option
WithReplicator overwrites the default graph based decision maker, of which feeds to copy or block
func WithRepoPath ¶
WithRepoPath changes where the replication database and blobs are stored.
func WithUNIXSocket ¶
func WithUNIXSocket() Option
WithUNIXSocket enables listening for muxrpc connections on a unix socket files ($repo/socket). This socket is not encrypted or authenticated since access to it is mediated by filesystem ownership.
func WithWebsocketAddress ¶
WithWebsocketAddress changes the HTTP listener address, by default it's :8989.
type Sbot ¶
type Sbot struct { // Shutdown needs to be called to shutdown indexing Shutdown context.CancelFunc Network *network.Node KeyPair ssb.KeyPair Groups *private.Manager ReceiveLog multimsg.AlterableLog // the stream of messages as they arrived SeqResolver *repo.SequenceResolver PublishLog ssb.Publisher // hardcoded default indexes Users *roaring.MultiLog // one sublog per feed Private *roaring.MultiLog // one sublog per keypair ByType *roaring.MultiLog // one sublog per type: ... (special cases for private messages by suffix) Tangles *roaring.MultiLog // one sublog per root:%ref (actual root is in the get index) GraphBuilder graph.Builder BlobStore ssb.BlobStore WantManager ssb.WantManager MetaFeeds MetaFeeds ssb.Replicator // contains filtered or unexported fields }
Sbot is the database and replication server
func (*Sbot) Close ¶
Close closes the bot by stopping network connections and closing the internal databases
func (*Sbot) DontReplicate ¶
func (*Sbot) FSCK ¶
func (s *Sbot) FSCK(opts ...FSCKOption) error
FSCK checks the consistency of the received messages and the indexes. progressFn offers a way to track the progress. It's okay to pass nil, the set sbot.info logger is used in that case.
func (*Sbot) GetIndexNamesMultiLog ¶
func (*Sbot) GetIndexNamesSimple ¶
func (*Sbot) HealRepo ¶
func (s *Sbot) HealRepo(report ErrConsistencyProblems) error
HealRepo just nulls the messages and is a very naive repair but the only one that is feasably implemented right now
func (*Sbot) NullContent ¶
NullContent drops the content portion of a gabbygrove transfer. seq is in the same base ase the feed (starting with 1).
func (*Sbot) PublishAs ¶
func (sbot *Sbot) PublishAs(nick string, val interface{}) (refs.MessageRef, error)
func (*Sbot) WaitUntilIndexesAreSynced ¶
func (s *Sbot) WaitUntilIndexesAreSynced()
WaitUntilIndexesAreSynced blocks until all the index processing is in sync with the rootlog