ssbc / ssb-server

The gossip and replication server for Secure Scuttlebutt - a distributed social network
1.69k stars 164 forks source link

--modern invites no longer work in scuttlebot@12.0.1 #542

Closed evbogue closed 6 years ago

evbogue commented 6 years ago

I'm trying to upgrade http://github.com/evbogue/mvd to the latest version of scuttlebot, and modern invites are failing.

% node bin invite.create --modern
/home/ev/scuttlebot/node_modules/muxrpcli/index.js:68
      throw err
      ^

Error: stream ended with:0 but wanted:34
    at drain (/home/ev/scuttlebot/node_modules/pull-reader/index.js:43:26)
    at /home/ev/scuttlebot/node_modules/pull-reader/index.js:63:18
    at /home/ev/scuttlebot/node_modules/pull-reader/index.js:114:13
    at drain (/home/ev/scuttlebot/node_modules/stream-to-pull-stream/index.js:141:18)
    at Socket.<anonymous> (/home/ev/scuttlebot/node_modules/stream-to-pull-stream/index.js:158:5)
    at Socket.emit (events.js:187:15)
    at endReadableNT (_stream_readable.js:1092:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

Results in scuttlebot crashing with

node bin server --allowPrivate
scuttlebot 12.0.1 /home/ev/.ssb logging.level:notice
my key ID: 8Qee0I/DwI5DHSCi3p5fsl6FyLGArrnDz3ox9qZr5Qc=.ed25519
(node:499) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
ssb-friends: stream legacy api used
/home/ev/scuttlebot/plugins/invite.js:112......... (indexes:66.7%)
            if(!/^ws/.test(ws_addr)) throw new Error('not a ws address:'+ws_addr)
                                     ^

Error: not a ws address:net:127.0.0.1:8008~shs:8Qee0I/DwI5DHSCi3p5fsl6FyLGArrnDz3ox9qZr5Qc=
    at /home/ev/scuttlebot/plugins/invite.js:112:44
    at /home/ev/scuttlebot/node_modules/secure-scuttlebutt/node_modules/level-sublevel/shell.js:53:51
    at /home/ev/scuttlebot/node_modules/secure-scuttlebutt/node_modules/level-sublevel/nut.js:109:13

In mvd we need --modern ws invites to serve a websocket address so the browser can find a server.

arj03 commented 6 years ago

Lets see. It dies because there is no addresses with ws configured. Basically before it just took stuff from server.ws, but now it uses the standard getadresses, so we don't have so many hacks around.

So you need to define an incoming ws connection as described here: https://github.com/ssbc/ssb-config#connections.

I tested this with:

  "ws": [{ "scope": "public", "transform": "shs" }],

getAddress now gives me a: ws://localhost:15967~shs:6CAxOI3f+LUOVrbAl0IemqiS7ATpQvr9Mdw9LC4+Uv0=

and invite.create --modern now works.

Also see the release notes here: https://github.com/ssbc/scuttlebot/releases/tag/12.0.0

evbogue commented 6 years ago

There are still some upgrade kinks to work out, but this solves the issue described above.

Thanks @arj03!