ssbc / ssb-config

standard configuration for ssb
MIT License
23 stars 18 forks source link

detect which scopes a interface can be used for #64

Closed dominictarr closed 4 years ago

dominictarr commented 4 years ago

fixes https://github.com/ssbc/ssb-config/issues/63

binds each interface to just one scope. that means sbot.getAddress('local') will return a 192... (or whatever, possibly including ipv6, etc. and sbot.getAddress('device') will return 'localhost'.

basically this was the code inside of non-private-ip, which was just a wrapper for the ip module but assumed you wanted a single host which made sense before we had multiserver and scopes etc

dominictarr commented 4 years ago

also tried to make better documentation

dominictarr commented 4 years ago

@mixmix @christianbundy thoughts?

mixmix commented 4 years ago

here's the ouput I got running this locally. Seems good to me

"incoming": {
    "net": [
      {
        "host": "127.0.0.1",
        "port": 8008,
        "scope": [
          "device"
        ],
        "transform": "shs"
      },
      {
        "host": "::1",
        "port": 8008,
        "scope": [
          "device"
        ],
        "transform": "shs"
      },
      {
        "host": "192.168.1.162",
        "port": 8008,
        "scope": [
          "local"
        ],
        "transform": "shs"
      },
      {
        "host": "2407:7000:9c49:4e00:ecda:4ad0:b28a:25a2",
        "port": 8008,
        "scope": [
          "public"
        ],
        "transform": "shs"
      },
      {
        "host": "2407:7000:9c49:4e00:cb8a:5dd8:b866:f655",
        "port": 8008,
        "scope": [
          "public"
        ],
        "transform": "shs"
      }
    ],
    "ws": [
      {
        "host": "127.0.0.1",
        "port": 8989,
        "scope": [
          "device"
        ],
        "transform": "shs"
      },
      {
        "host": "::1",
        "port": 8989,
        "scope": [
          "device"
        ],
        "transform": "shs"
      },
      {
        "host": "192.168.1.162",
        "port": 8989,
        "scope": [
          "local"
        ],
        "transform": "shs"
      },
      {
        "host": "2407:7000:9c49:4e00:ecda:4ad0:b28a:25a2",
        "port": 8989,
        "scope": [
          "public"
        ],
        "transform": "shs"
      },
      {
        "host": "2407:7000:9c49:4e00:cb8a:5dd8:b866:f655",
        "port": 8989,
        "scope": [
          "public"
        ],
        "transform": "shs"
      }
    ]
  }
mixmix commented 4 years ago

hmmm .. . I tested this on windows + linux.

It looks to be generating sensible output, and it seems to be forming connections between windows + linux on the local wifi. The problem is that I think we need to test discovery + connection in both directions and not sure how best to do that.

ok turned off internet and saw a message replicated locally fine from Linux > windows. I'm merging this

mixmix commented 4 years ago

Dominic there are now 2 sections with Scope, I'm gonna merge those

mixmix commented 4 years ago

MISSING ip dependency!

mixmix commented 4 years ago

published as 3.4.3

thanks @dominictarr :heart:

dominictarr commented 4 years ago

thanks @mixmix note to other maintainers: mix's home wifi gives a public ipv6 address (actually, two!), which is fairly unusual.