git ssb

1+

mixmix / scuttle-shell



Tree: de92553986e36c8aa555fb0a529a98913b109777

Files: de92553986e36c8aa555fb0a529a98913b109777 / server.js

2463 bytesRaw
1#! /usr/bin/env node
2
3const http = require('http')
4const serve = require('ecstatic')
5const fs = require('fs')
6const path = require('path')
7const ssbKeys = require('ssb-keys')
8const minimist = require('minimist')
9const notifier = require('node-notifier')
10const SysTray = require('systray').default
11
12let argv = process.argv.slice(2)
13let i = argv.indexOf('--')
14let conf = argv.slice(i + 1)
15argv = ~i ? argv.slice(0, i) : argv
16
17const config = require('ssb-config/inject')(process.env.ssb_appname, minimist(conf))
18
19const keys = ssbKeys.loadOrCreateSync(path.join(config.path, 'secret'))
20if (keys.curve === 'k256') {
21 throw new Error('k256 curves are no longer supported,' +
22 'please delete' + path.join(config.path, 'secret'))
23}
24
25const manifestFile = path.join(config.path, 'manifest.json')
26
27const createSbot = require('scuttlebot')
28 // .use(require('scuttlebot/plugins/plugins'))
29 .use(require('scuttlebot/plugins/master'))
30 .use(require('scuttlebot/plugins/gossip'))
31 .use(require('scuttlebot/plugins/replicate'))
32 .use(require('ssb-friends'))
33 .use(require('ssb-blobs'))
34 .use(require('scuttlebot/plugins/invite'))
35 .use(require('scuttlebot/plugins/local'))
36 .use(require('ssb-query'))
37 .use(require('ssb-ooo'))
38 .use(require('ssb-ebt'))
39 .use(require('ssb-ws'))
40 .use(require('ssb-names'))
41 .use(require('ssb-backlinks'))
42 .use(require('ssb-about'))
43
44// start server
45
46config.keys = keys
47const server = createSbot(config)
48
49// write RPC manifest to ~/.ssb/manifest.json
50fs.writeFileSync(manifestFile, JSON.stringify(server.getManifest(), null, 2))
51
52const icon = fs.readFileSync(path.join(__dirname, `icon.${process.platform === 'win32' ? 'ico' : 'png'}`))
53const tray = new SysTray({
54 menu: {
55 icon: icon.toString('base64'),
56 title: 'Scuttle-Shell',
57 tooltip: 'Secure Scuttlebutt tray app',
58 items: [
59
60 {
61 title: 'Quit',
62 tooltip: 'Stop sbot and quit tray application',
63 checked: false,
64 enabled: true
65 }
66 ]
67 },
68 debug: false,
69 copyDir: true,
70})
71
72tray.onClick(action => {
73 switch (action.seq_id) {
74 case 0:
75 console.log("### EXITING IN TWO SECONDS ###")
76
77 notifier.notify({
78 title: 'Secure Scuttlebutt',
79 message: `Secure Scuttlebutt will exit in two seconds...`,
80 icon: path.join(__dirname, "icon.png"),
81 wait: true,
82 id: 0,
83 })
84
85 tray.kill()
86 }
87})
88
89tray.onExit((code, signal) => {
90 setTimeout(() =>
91 process.exit(0), 2000)
92})

Built with git-ssb-web