This is a huge performance hit. Really, we just need to tell users not to modify
the result.
Also, get rid of an unnecessary pointer indirection (no api change).
See [rfc4007].
Can be prefixed to "ip6" like so:
/zone/eth0/ip6/fe80::1
This corresponds to the rfc4007 address `fe80::1%eth0`
[rfc4007] https://tools.ietf.org/html/rfc4007
This commit changes the struct to a new Multiaddr interface:
```Go
type Multiaddr interface {
Equal(Multiaddr) bool
Bytes() []byte
String() string
Protocols() []*Protocol
Encapsulate(Multiaddr) Multiaddr
Decapsulate(Multiaddr) Multiaddr
}
```
This means a few things have changed:
- use Multiaddr interface, struct not exported
- Bytes returns a copy of the internal bytes
- Some methods no longer return errors (catch errors in NewMultiaddr)
- String (panics if malformed)
- Protocols (panics if malformed)
- Decapsulate (no-op if not prefix)
- Moved net-specific functions to package
- Multiaddr.DialArgs() -> DialArgs(Multiaddr)
- Multiaddr.IsThinWaist() -> IsThinWaist(Multiaddr)
cc @whyrusleeping @perfmode
The error in String should not actually ocurr, as the multiaddr
should have been valid to be constructed successfully, and thus
should be encoded back to its string rep correctly.
This will be bolstered by creating an interface (to prevent messing
with the internal bytes)