ipld-eth-server/vendor/github.com/multiformats/go-multiaddr-fmt
2019-12-02 13:24:54 -06:00
..
.travis.yml update to work with go-ipfs fork that doesn't use go modules and so can play nice with our forked dependencies; update documentation and dockerfile 2019-12-02 13:24:54 -06:00
go.mod update to work with go-ipfs fork that doesn't use go modules and so can play nice with our forked dependencies; update documentation and dockerfile 2019-12-02 13:24:54 -06:00
go.sum update to work with go-ipfs fork that doesn't use go modules and so can play nice with our forked dependencies; update documentation and dockerfile 2019-12-02 13:24:54 -06:00
LICENSE update to work with go-ipfs fork that doesn't use go modules and so can play nice with our forked dependencies; update documentation and dockerfile 2019-12-02 13:24:54 -06:00
package.json update to work with go-ipfs fork that doesn't use go modules and so can play nice with our forked dependencies; update documentation and dockerfile 2019-12-02 13:24:54 -06:00
patterns.go update to work with go-ipfs fork that doesn't use go modules and so can play nice with our forked dependencies; update documentation and dockerfile 2019-12-02 13:24:54 -06:00
README.md update to work with go-ipfs fork that doesn't use go modules and so can play nice with our forked dependencies; update documentation and dockerfile 2019-12-02 13:24:54 -06:00

multiaddr format

A validation checker for multiaddrs. Some basic validators for common address types are provided, but creating your own combinations is easy.

Usage:

a, _ := ma.NewMultiaddr("/ip4/5.2.67.3/tcp/1708")
TCP.Matches(a) // returns true

Making your own validators is easy, for example, the Reliable multiaddr is defined as follows:

// Define IP as either ipv4 or ipv6
var IP = Or(Base(ma.P_IP4), Base(ma.P_IP6))

// Define TCP as 'tcp' on top of either ipv4 or ipv6
var TCP = And(IP, Base(ma.P_TCP))

// Define UDP as 'udp' on top of either ipv4 or ipv6
var UDP = And(IP, Base(ma.P_UDP))

// Define UTP as 'utp' on top of udp (on top of ipv4 or ipv6)
var UTP = And(UDP, Base(ma.P_UTP))

// Now define a Reliable transport as either tcp or utp
var Reliable = Or(TCP, UTP)

// From here, we can easily define multiaddrs for protocols that can run on top
// of any 'reliable' transport (such as ipfs)

NOTE: the above patterns are already implemented in package