ssbc / ssb-ref

check if a string is a valid ssb-reference
MIT License
14 stars 10 forks source link

Should IPv6 addresses include brackets? #32

Open PragmaticCypher opened 5 years ago

PragmaticCypher commented 5 years ago

The IPv6 address format for a Scuttlebutt reference is:

net:fcbc:6c66:bcd4:d3b5:2a2a:60b3:9b86:498f:8008~shs:ppdSxn1pSozJIqtDE4pYgwaQGmswCT9y15VJJcXRntI=

A better way may be the Uniform Identifier Resource (URI) standard for IPv6 addresses (RFC 3986 section 3.2.2), which uses brackets to separate the address from the port:

net:[fcbc:6c66:bcd4:d3b5:2a2a:60b3:9b86:498f]:8008~shs:ppdSxn1pSozJIqtDE4pYgwaQGmswCT9y15VJJcXRntI=

This may have better parsing support across programming languages. For instance, Golang's 'net' package will only parse the URI formatted address.

christianbundy commented 5 years ago

I'd like to see this change. I'm not sure whether it's compatible with the multiserver-address syntax, but if so I think this would just be a change to multiserver.

arj03 commented 5 years ago

@christianbundy but it is already used. The ws plugin in multiserver uses URL so tests in ssb-invite are failing for me, because it generates an addr with [::] :)

christianbundy commented 5 years ago

Right, it's used in the websocket plugin but I don't think it works in the net plugin, does it?

arj03 commented 5 years ago

No, net plugin is not "affected". So I'm thinking something like fix multiserver-address and then use URL in net as well? Maybe together with your big PR :) What do you think?