Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prep work to pass config down to broadcast for ipv6 #525

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ var i = argv.indexOf('--')
var conf = argv.slice(i+1)
argv = ~i ? argv.slice(0, i) : argv

var config = require('ssb-config/inject')(process.env.ssb_appname, minimist(conf))
var config = require('ssb-config/inject')(
process.env.ssb_appname,
Object.assign(
minimist(conf),
{ host: process.env.ssb_host }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't put a hack like this here... this should already work in ssb-config. are you sure it's needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may no longer be needed, at the time I think this was a side-effect of how ssb_host was being read / overwritten.

))

var keys = ssbKeys.loadOrCreateSync(path.join(config.path, 'secret'))
if(keys.curve === 'k256')
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ function createSbot() {
//this is just the default app key.
//it can be overridden by passing a appKey as option
//when creating a Sbot instance.
host: process.env.ssb_host,
appKey: require('./lib/ssb-cap')
})
.use(SSB)
Expand Down
3 changes: 2 additions & 1 deletion plugins/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = {
}
}

var local = broadcast(config.port)
var local = broadcast(config.port, config.loopback, config.family)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this do?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh https://github.com/dominictarr/broadcast-stream/blob/master/index.js#L6 loopback makes the broadcast detectable on the same computer (needed for testing)

Was there a problem with this on ipv6? to OP mentions ipv6 but doesn't state it clearly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it will be a little bit of time before I can get a testing setup up and running again. The motivation for this PR was to allow for nodes who are on the same physical network, but only have link-local (self-assigned) IPV6 addresses, to discover each other using another plugin I had written, using ipv6 multicast (similar to ipv4 broadcast).

I need to look into it again, but I think I had to enable loopback to not filter messages from other hosts, not just self-broadcasts.

I opted to pass in the family so the code I was submitting didn't disrupt the normal code path, though it may be better for both to behave the same was, as seen below.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should have said something like this in the original post! I think the main reason this PR has languished is because it wasn't clear what you where trying to accomplish, so it wasn't clear how important this was, and so we soon got distracted by other things.

The biggest problem with this code is that it's really hard to test. To really cover all the sorts of network configurations we'd need a much more complicated testing set up than we have currently, like spinning up virtual networks running in VMs. This stuff is currently mainly QA'd by people with unusual network set ups complaining that it's not working.

can you give more context about how/why you are using ipv6? is ipv6 mission critical for you or nice to have?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is to be able to allow nodes to join a network without relying on a dhcp server. The 'easiest' way I've found for this is with self-assigned ipv6 addresses, since they won't really collide. I am open to figuring out other ways, but my knowledge is limited.

This is for mainly for two projects:

  1. https://baculus.co - an experiment in disaster response infrastructure
  2. An art project with a friend related to 'the distributed web of care' where we have participants connecting ad-hoc, though I think I can work around this by only having one node in the room act as a dhcp server.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, because dhcd is completely different on ipv6 because you can just choose your own ip address. I've also managed to figure out that the reason it takes so long to connect to a wifi is because DHCP spec mandates multisecond delays

I'm definitely keen to support ssb on adhoc networks! another idea we've kicked around it a public open wifi, that lets you download and install an ssb client on the captive portal page

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I wonder if I should setup a video demo of baculus, it totally can do this. Right now it just serves up mvd since that requires zero installation from an end-user, but I should also expose Manyverse if it detects and android phone.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is MVD? video demo is always good!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/evbogue/mvd - its a web client for scuttlebutt, that hosts identity keypairs in the browser. I'll make a video this week :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right now I remember

var addrs = {}
var lastSeen = {}

Expand All @@ -54,6 +54,7 @@ module.exports = {
var data = buf.toString()
var peer = ref.parseAddress(data)
if (peer && peer.key !== sbot.id) {
if (config.family === 'IPv6') peer.host = buf.address
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the crux of things - if a node is saying 'I am a node' it feels weird to me to use the contents of their message as the IP - why not use the address the packet came from? (From what I understand, its so my node can forward publicly routeable advertisements, which makes sense). With ipv6 link local, addresses are unique to the interface, so you cannot share another nodes address and it be able to connect.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also don’t get it..

#640 (comment)

addrs[peer.key] = peer
lastSeen[peer.key] = Date.now()
sbot.gossip.add(data, 'local')
Expand Down