Merge pull request #92 from fraction/conn-buttons

Add buttons to 'meta' page to manage networking
This commit is contained in:
Jonathan Dahan 2020-01-28 14:03:30 -05:00 committed by GitHub
commit 37d01bf517
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 230 additions and 174 deletions

View File

@ -9,15 +9,15 @@ some extra tools for debugging, _not_ to support all known message types.
```console
$ oasis --help
Usage: oasis [options]
Options:
--version Show version number [boolean]
-h, --help Show help [boolean]
--open Automatically open app in web browser. Use --no-open to disable.
--open Automatically open app in web browser. Use --no-open to disable.
[boolean] [default: true]
--offline Don't try to connect to scuttlebutt peers or pubs
--offline Don't try to connect to scuttlebutt peers or pubs. This can be
changed on the 'meta' page while Oasis is running.
[boolean] [default: false]
--host Hostname for web app to listen on [string] [default: "localhost"]
--port Port for web app to listen on [number] [default: 3000]

256
package-lock.json generated
View File

@ -183,21 +183,21 @@
"integrity": "sha512-Lnle0J8t+Z+jFg78GFFnGo+Fphxaco9K9SppeBDsI27QBRBumxeGAMeOg5wt6XbAuj5pQWmAEWWEwPz4PYGMHw=="
},
"@fraction/flotilla": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@fraction/flotilla/-/flotilla-3.0.0.tgz",
"integrity": "sha512-FGEXJl1iYEaAKIWBRp0Fwy5IeaukTsCNKYHj6BtihHH0X8p9FCJTLriQQsdpIg3qAgrjOMbP2QZoywNVK5oltA==",
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/@fraction/flotilla/-/flotilla-3.0.2.tgz",
"integrity": "sha512-Saq4sZdp0ANkqACCF2tfheJbFm4tjKOJnkeM9iZiMzVDp9GQCmSSy3ZE+ffljcVFrWGMwZSc8kvEKa+UzIC4xQ==",
"requires": {
"lodash.shuffle": "^4.2.0",
"secret-stack": "^6.3.0",
"ssb-about": "^2.0.1",
"ssb-backlinks": "^0.7.3",
"ssb-blobs": "^1.2.2",
"ssb-conn": "^0.11.2",
"ssb-conn": "^0.15.2",
"ssb-db": "^19.3.0",
"ssb-ebt": "^5.6.7",
"ssb-friends": "^4.1.4",
"ssb-invite": "^2.1.3",
"ssb-lan": "^0.1.3",
"ssb-lan": "^0.2.0",
"ssb-links": "^3.0.8",
"ssb-logging": "^1.0.0",
"ssb-master": "^1.0.3",
@ -2122,9 +2122,9 @@
"integrity": "sha1-4rPZG1Su1nLzCdlQ0VSFD6EdTzc="
},
"es-abstract": {
"version": "1.17.0",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.0.tgz",
"integrity": "sha512-yYkE07YF+6SIBmg1MsJ9dlub5L48Ek7X0qz+c/CPCHS9EBXfESorzng4cJQjJW5/pB6vDF41u7F8vUhLVDqIug==",
"version": "1.17.4",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.4.tgz",
"integrity": "sha512-Ae3um/gb8F0mui/jPL+QiqmglkUsaQf7FwBEHYIFkztkneosu9imhqHpBzQ3h1vit8t5iQ74t6PEVvphBZiuiQ==",
"requires": {
"es-to-primitive": "^1.2.1",
"function-bind": "^1.1.1",
@ -2293,6 +2293,21 @@
"integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==",
"dev": true
},
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"dev": true
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"dev": true,
"requires": {
"minimist": "0.0.8"
}
},
"semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
@ -2738,13 +2753,6 @@
"pull-paramap": "^1.2.1",
"pull-stream": "^3.5.0",
"pull-write": "^1.1.1"
},
"dependencies": {
"looper": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/looper/-/looper-4.0.0.tgz",
"integrity": "sha1-dwat7VmpntygbmtUu4bI7BnJUVU="
}
}
},
"flumeview-query": {
@ -2759,13 +2767,6 @@
"pull-paramap": "^1.1.3",
"pull-sink-through": "0.0.0",
"pull-stream": "^3.4.0"
},
"dependencies": {
"looper": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/looper/-/looper-4.0.0.tgz",
"integrity": "sha1-dwat7VmpntygbmtUu4bI7BnJUVU="
}
}
},
"flumeview-reduce": {
@ -2791,13 +2792,6 @@
"pull-paramap": "^1.2.2",
"pull-pushable": "^2.2.0",
"pull-stream": "^3.0.1"
},
"dependencies": {
"looper": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/looper/-/looper-4.0.0.tgz",
"integrity": "sha1-dwat7VmpntygbmtUu4bI7BnJUVU="
}
}
},
"for-each": {
@ -4140,9 +4134,9 @@
},
"dependencies": {
"readable-stream": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz",
"integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==",
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.5.0.tgz",
"integrity": "sha512-gSz026xs2LfxBPudDuI41V1lka8cxg64E66SGe78zJlsUofOg/yqwezdIcdfwik6B4h8LFmWPA9ef9X3FiNFLA==",
"requires": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
@ -5666,6 +5660,25 @@
"tar-fs": "^2.0.0",
"tunnel-agent": "^0.6.0",
"which-pm-runs": "^1.0.0"
},
"dependencies": {
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"optional": true,
"requires": {
"minimist": "0.0.8"
},
"dependencies": {
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"optional": true
}
}
}
}
},
"prelude-ls": {
@ -5971,9 +5984,9 @@
"integrity": "sha1-GdRb6PqmFfpVbxSpb9czRiw3+6M="
},
"pull-ping": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/pull-ping/-/pull-ping-2.0.2.tgz",
"integrity": "sha1-e8SjQBZ9rYj2gqGWxjSFc1x6CJQ=",
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/pull-ping/-/pull-ping-2.0.3.tgz",
"integrity": "sha512-nbY4yHnMesJBrvkbhMim4VXUC9k1VCkgrkQu49pf8mxFbmb/U2KQrsuePvSmLjRL+VgkBVRSUXUoOY7DtSvhKw==",
"requires": {
"pull-pushable": "^2.0.0",
"pull-stream": "^3.4.5",
@ -6665,13 +6678,6 @@
"pull-stream": "^3.4.5",
"stream-to-pull-stream": "^1.6.1",
"to-camel-case": "^1.0.0"
},
"dependencies": {
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
}
}
},
"secret-stack-decorators": {
@ -7031,13 +7037,6 @@
"pull-notify": "^0.1.0",
"pull-stream": "^3.3.0",
"ssb-ref": "^2.3.0"
},
"dependencies": {
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
}
}
},
"ssb-caps": {
@ -7075,9 +7074,9 @@
}
},
"ssb-conn": {
"version": "0.11.3",
"resolved": "https://registry.npmjs.org/ssb-conn/-/ssb-conn-0.11.3.tgz",
"integrity": "sha512-Y8Ol60JWqf+oX+IG9+ThOI7VWDRUxzu3/xD7VE/dtNq74bdo+N1TN6zsxFp9cg1kmQfA36f1LT/QMw4iz6oi+w==",
"version": "0.15.2",
"resolved": "https://registry.npmjs.org/ssb-conn/-/ssb-conn-0.15.2.tgz",
"integrity": "sha512-QTdyOobC1ybnz0DHG1U0IrypRI9skd47HKXT6spQ2dnF8S4UQr29YOBWt4dWXfgnBP5a7WHMg07MY90XszwbGg==",
"requires": {
"debug": "~4.1.1",
"has-network2": "0.0.1",
@ -7086,30 +7085,23 @@
"on-wakeup": "^1.0.1",
"pull-notify": "^0.1.1",
"pull-pause": "~0.0.2",
"pull-ping": "^2.0.2",
"pull-stream": "^3.6.9",
"pull-ping": "^2.0.3",
"pull-stream": "^3.6.14",
"secret-stack-decorators": "1.0.0",
"ssb-conn-db": "~0.2.1",
"ssb-conn-db": "~0.3.0",
"ssb-conn-hub": "~0.2.7",
"ssb-conn-query": "~0.4.4",
"ssb-conn-query": "~0.4.5",
"ssb-conn-staging": "~0.1.0",
"ssb-ref": "^2.13.9",
"ssb-typescript": "^1.4.0",
"ssb-typescript": "^1.5.0",
"statistics": "^3.3.0",
"zii": "~1.1.0"
},
"dependencies": {
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
}
}
},
"ssb-conn-db": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/ssb-conn-db/-/ssb-conn-db-0.2.1.tgz",
"integrity": "sha512-ZcqB6pXyu20UmQ+3QPr8mY1+TAdQfQv20qjkf0wqm9LB1GRkYfKLm2O7Nc2DpLs1SOsWuFXfO8vgXjEAsDBOQQ==",
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/ssb-conn-db/-/ssb-conn-db-0.3.1.tgz",
"integrity": "sha512-1cCbfaVDow50FNx+0V1hGIJsSy1RIn10J16D/gBlWRxB1ddGr5v6TCtFyc6Y+J/6Gnx+BPTKwqd9vTJ1ow6RCA==",
"requires": {
"atomic-file": "^1.1.5",
"debug": "~4.1.1",
@ -7122,11 +7114,6 @@
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/atomic-file/-/atomic-file-1.1.5.tgz",
"integrity": "sha512-TG+5YFiaKQ6CZiSQsosGMJ/IJzwMZ4V/rSdEXlD6+DwKyv8OyeUcprq34kp4yuS6bfQYXhxBC2Vm8PWo+iKBGQ=="
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
}
}
},
@ -7144,21 +7131,14 @@
"pull-notify": "~0.1.1",
"pull-stream": "~3.6.9",
"ssb-ref": "~2.13.9"
},
"dependencies": {
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
}
}
},
"ssb-conn-query": {
"version": "0.4.4",
"resolved": "https://registry.npmjs.org/ssb-conn-query/-/ssb-conn-query-0.4.4.tgz",
"integrity": "sha512-FeHwQwec24RyEFImETEnP5Qdzg3IPOhEDNloJ9PqsZfd1c3fCoY0aunJz6Z3OgkrGIVSPzS4eze6iXx+ns+WIw==",
"version": "0.4.5",
"resolved": "https://registry.npmjs.org/ssb-conn-query/-/ssb-conn-query-0.4.5.tgz",
"integrity": "sha512-1ZMn3M6bs4nWyZRffVhKllMcqJRgvrlbZFXkQWUk1d3Yu5bSMnQWPVwn/1YKNqIRzu8RDrzcT/dlhS5VofHtIA==",
"requires": {
"ssb-conn-db": "~0.2.1",
"ssb-conn-db": "~0.3.0",
"ssb-conn-hub": "~0.2.7",
"ssb-conn-staging": "~0.1.0"
}
@ -7173,13 +7153,6 @@
"pull-cat": "~1.1.11",
"pull-notify": "~0.1.1",
"pull-stream": "^3.6.9"
},
"dependencies": {
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
}
}
},
"ssb-db": {
@ -7261,12 +7234,27 @@
"chloride": "^2.2.8",
"mkdirp": "~0.5.0",
"private-box": "^0.3.0"
},
"dependencies": {
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"requires": {
"minimist": "0.0.8"
}
}
}
},
"ssb-lan": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/ssb-lan/-/ssb-lan-0.1.4.tgz",
"integrity": "sha512-Ou+nZJp+p5e2ZbHAE2GO4956kiwj/HEasxXRsTvR60LwWIW+Ki1xOXoYF5K+qrbijL9lH1Udsb+vvBdcm9ijhA==",
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/ssb-lan/-/ssb-lan-0.2.0.tgz",
"integrity": "sha512-CG9vvjLIf4CEKmLBBeAXk6jtnIAoi1MpnRqBcCiqfw5WKe3bPBUCREIr45v5eQGhrkHAJgW10eMBef9jnEqeNQ==",
"requires": {
"broadcast-stream": "^0.2.2",
"debug": "^4.1.1",
@ -7274,13 +7262,6 @@
"secret-stack-decorators": "~1.0.0",
"ssb-keys": "^7.2.0",
"ssb-ref": "^2.13.9"
},
"dependencies": {
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
}
}
},
"ssb-links": {
@ -7315,9 +7296,9 @@
}
},
"ssb-markdown": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/ssb-markdown/-/ssb-markdown-6.0.2.tgz",
"integrity": "sha512-3+Wc6HjDdsqvLgw841uGv9UxW/bxQERsaL5/sIPEOAFBwPl8FnCv9LodU08kaNKN3lKbxJ2LfareCluODfSOag==",
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/ssb-markdown/-/ssb-markdown-6.0.3.tgz",
"integrity": "sha512-pVOStAcoBzQ/KvV1OyE7yREuhi/qUd10gLbKcnldELBwniSovuia867s2F67dPfRr3ASLXjfm+Zz5dnPXE/jVw==",
"requires": {
"emoji-regex": "^8.0.0",
"hashtag-regex": "^2.1.0",
@ -7444,11 +7425,6 @@
"pull-sink-through": "0.0.0",
"pull-stream": "^3.4.0"
}
},
"looper": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/looper/-/looper-4.0.0.tgz",
"integrity": "sha1-dwat7VmpntygbmtUu4bI7BnJUVU="
}
}
},
@ -7478,13 +7454,6 @@
"pull-pushable": "^2.2.0",
"pull-stream": "^3.6.9",
"ssb-ref": "^2.13.9"
},
"dependencies": {
"looper": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/looper/-/looper-4.0.0.tgz",
"integrity": "sha1-dwat7VmpntygbmtUu4bI7BnJUVU="
}
}
},
"ssb-room": {
@ -7621,9 +7590,9 @@
}
},
"ssb-typescript": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/ssb-typescript/-/ssb-typescript-1.4.0.tgz",
"integrity": "sha512-+qFUlFGTIR9f4ab45UfszGCBiClSPH1llM072zWiwlxMyKu70CQ4IUgsWGWyge2mN8z9CiNkPm+ElZ5Ok0Mxcg=="
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/ssb-typescript/-/ssb-typescript-1.5.0.tgz",
"integrity": "sha512-I4oe7BDYmk3kopVZC4BrXuKfugpJphLcZTmheofW2Dwanm6VutLfzLgz6juqt7aYKeIH5Ps3sJvZWQLw3MvUMQ=="
},
"ssb-unix-socket": {
"version": "1.0.0",
@ -8158,6 +8127,23 @@
"minizlib": "^2.1.0",
"mkdirp": "^0.5.0",
"yallist": "^4.0.0"
},
"dependencies": {
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"optional": true
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"optional": true,
"requires": {
"minimist": "0.0.8"
}
}
}
},
"tar-fs": {
@ -8170,6 +8156,23 @@
"mkdirp": "^0.5.1",
"pump": "^3.0.0",
"tar-stream": "^2.0.0"
},
"dependencies": {
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"optional": true
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"optional": true,
"requires": {
"minimist": "0.0.8"
}
}
}
},
"tar-stream": {
@ -8904,6 +8907,23 @@
"dev": true,
"requires": {
"mkdirp": "^0.5.1"
},
"dependencies": {
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"dev": true
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"dev": true,
"requires": {
"minimist": "0.0.8"
}
}
}
},
"write-file-atomic": {

View File

@ -22,7 +22,7 @@
},
"dependencies": {
"@fraction/base16-css": "^1.1.0",
"@fraction/flotilla": "3.0.0",
"@fraction/flotilla": "^3.0.2",
"debug": "^4.1.1",
"highlight.js": "^9.18.0",
"hyperaxe": "^1.3.0",
@ -41,7 +41,7 @@
"sharp": "^0.23.0",
"ssb-client": "^4.8.0",
"ssb-config": "^3.4.3",
"ssb-markdown": "^6.0.2",
"ssb-markdown": "^6.0.3",
"ssb-mentions": "^0.5.0",
"ssb-msgs": "^5.2.0",
"ssb-ref": "^2.13.9",

View File

@ -461,6 +461,12 @@ hr {
border: var(--pico) solid var(--fg-alt);
}
.form-button-group {
display: flex;
justify-content: space-between;
margin: var(--whole) 0;
}
/* sidebar only appears on big screens */
@media (min-width: calc(45rem)) {
body > nav > ul {

View File

@ -11,12 +11,13 @@ module.exports = () =>
.usage("Usage: $0 [options]")
.options("open", {
describe:
"Automatically open app in web browser. Use --no-open to disable.",
"Automatically open app in web browser. Use --no-open to disable.",
default: true,
type: "boolean"
})
.options("offline", {
describe: "Don't try to connect to scuttlebutt peers or pubs",
describe:
"Don't try to connect to scuttlebutt peers or pubs. This can be changed on the 'meta' page while Oasis is running.",
default: false,
type: "boolean"
})

View File

@ -510,6 +510,18 @@ router
ctx.cookies.set("theme", theme);
const referer = new URL(ctx.request.header.referer);
ctx.redirect(referer);
})
.post("/meta/conn/start", koaBody(), async ctx => {
await meta.connStart();
ctx.redirect("/meta");
})
.post("/meta/conn/stop", koaBody(), async ctx => {
await meta.connStop();
ctx.redirect("/meta");
})
.post("/meta/conn/restart", koaBody(), async ctx => {
await meta.connRestart();
ctx.redirect("/meta");
});
const { host } = config;

View File

@ -208,6 +208,33 @@ module.exports = cooler => {
})
);
});
},
connStop: async () => {
const ssb = await cooler.connect();
try {
const result = await cooler.get(ssb.conn.stop);
return result;
} catch (e) {
const expectedName = "TypeError";
const expectedMessage = "Cannot read property 'close' of null";
if (e.name === expectedName && e.message === expectedMessage) {
// https://github.com/staltz/ssb-lan/issues/5
debug("ssbConn is already stopped -- caught error");
} else {
throw new Error(e);
}
}
},
connStart: async () => {
const ssb = await cooler.connect();
const result = await cooler.get(ssb.conn.start);
return result;
},
connRestart: async () => {
await models.meta.connStop();
await models.meta.connStart();
}
};

View File

@ -2,8 +2,7 @@
// This module exports a function that connects to SSB and returns a "cooler"
// interface. This interface is poorly defined and should be replaced with
// native support for Promises in the MuxRPC module and auto-generated manifest
// files in the SSB-Client module.
// native support for Promises in the MuxRPC module.
const ssbClient = require("ssb-client");
const ssbConfig = require("ssb-config");
@ -22,56 +21,22 @@ const log = (...args) => {
const rawConnect = () =>
new Promise((resolve, reject) => {
ssbClient(
{
manifest: {
about: {
socialValue: "async",
read: "source"
},
backlinks: { read: "source" },
blobs: {
get: "source",
ls: "source",
want: "async"
},
conn: {
peers: "source"
},
createUserStream: "source",
createHistoryStream: "source",
get: "sync",
messagesByType: "source",
publish: "async",
status: "async",
tangle: { branch: "async" },
query: { read: "source" },
friends: {
isFollowing: "async",
isBlocking: "async"
},
search: {
query: "source"
}
ssbClient((err, api) => {
if (err) {
reject(err);
} else {
if (api.tangle === undefined) {
// HACK: SSB-Tangle isn't available in Patchwork, but we want that
// compatibility. This code automatically injects SSB-Tangle into our
// stack so that we don't get weird errors when using Patchwork.
//
// See: https://github.com/fraction/oasis/issues/21
api.tangle = ssbTangle.init(api);
}
},
(err, api) => {
if (err) {
reject(err);
} else {
if (api.tangle === undefined) {
// HACK: SSB-Tangle isn't available in Patchwork, but we want that
// compatibility. This code automatically injects SSB-Tangle into our
// stack so that we don't get weird errors when using Patchwork.
//
// See: https://github.com/fraction/oasis/issues/21
api.tangle = ssbTangle.init(api);
}
resolve(api);
}
resolve(api);
}
);
});
});
let handle;

View File

@ -174,6 +174,27 @@ exports.metaView = ({ status, peers, theme, themeNames }) => {
return div(label({ for: id }, key), progress({ id, value: val, max }, val));
});
const startButton = form(
{ action: "/meta/conn/start", method: "post" },
button({ type: "submit" }, "start networking")
);
const restartButton = form(
{ action: "/meta/conn/restart", method: "post" },
button({ type: "submit" }, "restart networking")
);
const stopButton = form(
{ action: "/meta/conn/stop", method: "post" },
button({ type: "submit" }, "stop networking")
);
const connButtons = div({ class: "form-button-group" }, [
startButton,
restartButton,
stopButton
]);
const peerList = (peers || []).map(([, data]) => {
return li(
a(
@ -248,6 +269,10 @@ exports.metaView = ({ status, peers, theme, themeNames }) => {
"Your computer is syncing data with these other computers. It will connect to any scuttlebutt pub and peer it can find, even if you have no relationship with them, as it looks for data from your friends."
),
peerList.length > 0 ? ul(peerList) : code("no peers connected"),
p(
"You can decide when you want your computer to network with peers. You can start, stop, or restart your networking whenever you'd like."
),
connButtons,
h3("Indexes"),
progressElements
)