Composable and future-proof network addresses https://github.com/multiformats/multiaddr
Go to file
Steven Allen 71c1bfde36 Fix protocol multicodecs numbers
1. Swap udt/utp.
2. Fix udp (17 is SHA1)
3. Change them to hex so it's easier to compare them with the official
   multicodec table.
4. Remove the local protocols.csv table.

Fixes #49
Fixes multiformats/multicodec#51
2017-07-20 14:39:12 -07:00
.gx gx publish 1.2.2 2017-03-23 18:43:16 -07:00
.travis.yml fix ci scripts 2016-10-04 17:01:32 -07:00
LICENSE MIT license 2014-09-28 15:21:18 -07:00
Makefile fix ci scripts 2016-10-04 17:01:32 -07:00
README.md Edit Badges 2016-12-26 15:18:42 -05:00
codec.go add Transocoder functionality 2016-10-14 11:48:19 -04:00
doc.go Changed jbenet to multiformats 2016-10-20 20:48:40 -04:00
interface.go Changed jbenet to multiformats 2016-10-20 20:48:40 -04:00
multiaddr.go added unix path protocol 2016-09-19 11:06:27 +08:00
multiaddr_test.go add QUIC 2017-03-17 13:26:26 +07:00
package.json gx publish 1.2.2 2017-03-23 18:43:16 -07:00
protocols.go Fix protocol multicodecs numbers 2017-07-20 14:39:12 -07:00
transcoders.go Create NewTranscoderFromFunctions function and use it 2016-11-02 17:49:29 +01:00
util.go faster encapsulation + join 2014-11-05 02:30:53 -08:00

README.md

go-multiaddr

Travis CI codecov.io

multiaddr implementation in go

Multiaddr is a standard way to represent addresses that:

  • Support any standard network protocols.
  • Self-describe (include protocols).
  • Have a binary packed format.
  • Have a nice string representation.
  • Encapsulate well.

Table of Contents

Install

go get github.com/multiformats/go-multiaddr

Usage

Example

Simple

import ma "github.com/multiformats/go-multiaddr"

// construct from a string (err signals parse failure)
m1, err := ma.NewMultiaddr("/ip4/127.0.0.1/udp/1234")

// construct from bytes (err signals parse failure)
m2, err := ma.NewMultiaddrBytes(m1.Bytes())

// true
strings.Equal(m1.String(), "/ip4/127.0.0.1/udp/1234")
strings.Equal(m1.String(), m2.String())
bytes.Equal(m1.Bytes(), m2.Bytes())
m1.Equal(m2)
m2.Equal(m1)

Protocols

// get the multiaddr protocol description objects
m1.Protocols()
// []Protocol{
//   Protocol{ Code: 4, Name: 'ip4', Size: 32},
//   Protocol{ Code: 17, Name: 'udp', Size: 16},
// }

En/decapsulate

m.Encapsulate(ma.NewMultiaddr("/sctp/5678"))
// <Multiaddr /ip4/127.0.0.1/udp/1234/sctp/5678>
m.Decapsulate(ma.NewMultiaddr("/udp")) // up to + inc last occurrence of subaddr
// <Multiaddr /ip4/127.0.0.1>

Tunneling

Multiaddr allows expressing tunnels very nicely.

printer, _ := ma.NewMultiaddr("/ip4/192.168.0.13/tcp/80")
proxy, _ := ma.NewMultiaddr("/ip4/10.20.30.40/tcp/443")
printerOverProxy := proxy.Encapsulate(printer)
// /ip4/10.20.30.40/tcp/443/ip4/192.168.0.13/tcp/80

proxyAgain := printerOverProxy.Decapsulate(printer)
// /ip4/10.20.30.40/tcp/443

Maintainers

Captain: @whyrusleeping.

Contribute

Contributions welcome. Please check out the issues.

Check out our contributing document for more information on how we work, and about contributing in general. Please be aware that all interactions related to multiformats are subject to the IPFS Code of Conduct.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © 2014 Juan Batiz-Benet