ssb-server

The gossip and replication server for Secure Scuttlebutt - a distributed social network

Github星跟踪图

ssb-server

ssb-server is an open source peer-to-peer log store used as a database, identity provider, and messaging system.
It has:

  • Global replication
  • File-synchronization
  • End-to-end encryption

ssb-server behaves just like a Kappa Architecture DB.
In the background, it syncs with known peers.
Peers do not have to be trusted, and can share logs and files on behalf of other peers, as each log is an unforgeable append-only message feed.
This means ssb-servers comprise a global gossip-protocol mesh without any host dependencies.

If you are looking to use ssb-server to run a pub, consider using ssb-minimal-pub-server instead.

Join us in #scuttlebutt on freenode.

build status

Install

To add ssb-server to your available CLI commands, install it using the -g global flag:

npm install -g ssb-server

Applications

There are already several applications built on ssb-server,
one of the best ways to learn about secure-scuttlebutt is to poke around in these applications.

  • patchwork is a discussion platform that we use to anything and everything concerning ssb and decentralization.
  • patchbay is another take on patchwork - it's compatible, less polished, but more modular. The main goal of patchbay is to be very easy to add features to.
  • git-ssb is git (& github!) on top of secure-scuttlebutt. Although we still keep our repos on github, primary development is via git-ssb.

It is recommended to get started with patchwork, and then look into git-ssb and patchbay.

Starting an ssb-server

Command Line Usage Example

Start the server with extra log detail
Leave this running in its own terminal/window

ssb-server start --logging.level=info

Javascript Usage Example

var Server = require('ssb-server')
var config = require('ssb-config')
var fs = require('fs')
var path = require('path')

// add plugins
Server
  .use(require('ssb-master'))
  .use(require('ssb-gossip'))
  .use(require('ssb-replicate'))
  .use(require('ssb-backlinks'))

var server = Server(config)

// save an updated list of methods this server has made public
// in a location that ssb-client will know to check
var manifest = server.getManifest()
fs.writeFileSync(
  path.join(config.path, 'manifest.json'), // ~/.ssb/manifest.json
  JSON.stringify(manifest)
)

see: github.com/ssbc/ssb-config for custom configuration.

Calling ssb-server Functions

There are a variety of ways to call ssb-server methods, from a command line as well as in a javascript program.

Command Line Usage Example

The command ssb-server can also used to call the running ssb-server.

Now, in a separate terminal from the one where you ran ssb-server start, you can run commands such as the following:

# publish a message
ssb-server publish --type post --text "My First Post!"

# stream all messages in all feeds, ordered by publish time
ssb-server feed

# stream all messages in all feeds, ordered by receive time
ssb-server log

# stream all messages by one feed, ordered by sequence number
ssb-server hist --id $FEED_ID

Javascript Usage Example

Note that the following involves using a separate JS package, called ssb-client. It is most suitable for connecting to a running ssb-server and calling its methods. To see further distinctions between ssb-server and ssb-client, check out this handbook article.

var pull = require('pull-stream')
var Client = require('ssb-client')

// create a ssb-server client using default settings
// (server at localhost:8080, using key found at ~/.ssb/secret, and manifest we wrote to `~/.ssb/manifest.json` above)
Client(function (err, server) {
  if (err) throw err

  // publish a message
  server.publish({ type: 'post', text: 'My First Post!' }, function (err, msg) {
    // msg.key           == hash(msg.value)
    // msg.value.author  == your id
    // msg.value.content == { type: 'post', text: 'My First Post!' }
    // ...
  })

  // stream all messages in all feeds, ordered by publish time
  pull(
    server.createFeedStream(),
    pull.collect(function (err, msgs) {
      // msgs[0].key == hash(msgs[0].value)
      // msgs[0].value...
    })
  )

  // stream all messages in all feeds, ordered by receive time
  pull(
    server.createLogStream(),
    pull.collect(function (err, msgs) {
      // msgs[0].key == hash(msgs[0].value)
      // msgs[0].value...
    })
  )

  // stream all messages by one feed, ordered by sequence number
  pull(
    server.createHistoryStream({ id: < feedId > }),
    pull.collect(function (err, msgs) {
      // msgs[0].key == hash(msgs[0].value)
      // msgs[0].value...
    })
  )
})

Use Cases

ssb-server's message-based data structure makes it ideal for mail and forum applications (see Patchwork).
However, it is sufficiently general to be used to build:

  • Office tools (calendars, document-sharing, tasklists)
  • Wikis
  • Package managers

Because ssb-server doesn't depend on hosts, its users can synchronize over WiFi or any other connective medium, making it great for Sneakernets.

ssb-server is eventually-consistent with peers, and requires exterior coordination to create strictly-ordered transactions.
Therefore, by itself, it would probably make a poor choice for implementing a crypto-currency.
(We get asked that a lot.)


Getting Started

Key Concepts

Further Reading

License

MIT

主要指标

概览
名称与所有者ssbc/ssb-server
主编程语言JavaScript
编程语言JavaScript (语言数: 1)
平台
许可证
所有者活动
创建于2014-10-28 23:23:16
推送于2022-06-17 15:11:15
最后一次提交2020-10-16 10:28:55
发布数65
最新版本名称v15.3.0 (发布于 2020-11-10 14:21:08)
第一版名称v10.4.5 (发布于 2017-09-18 11:18:15)
用户参与
星数1.7k
关注者数73
派生数167
提交数1.9k
已启用问题?
问题数423
打开的问题数35
拉请求数263
打开的拉请求数8
关闭的拉请求数71
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?