multiaddr-0.1.0: A network address format

Copyright(c) 2016 Micxjo Funkcio
LicenseBSD3
Maintainermicxjo@fastmail.com
StabilityExperimental
Safe HaskellNone
LanguageHaskell2010

Network.Multiaddr

Contents

Description

Multiaddr is a self-describing network address format supporting a variety of protocols, with both string and binary representations.

Synopsis

Multiaddr type

Encoding / decoding

readMultiaddr :: Text -> Maybe Multiaddr Source

Try to read a multiaddr in the standard text format (e.g. "/ip4/8.8.8.8/tcp/80")

encode :: Multiaddr -> ByteString Source

Encode a multiaddr using the standard binary represenation.

decode :: ByteString -> Maybe Multiaddr Source

Try to decode a binary-encoded multiaddr.

class TextAddr a where Source

Render an address to its standard text representation.

Methods

toText :: a -> Text Source

Encapsulation

encapsulate :: Multiaddr -> Multiaddr -> Multiaddr Source

Append two multiaddrs (alias for (<>))

Query

parts :: Multiaddr -> [AddrPart] Source

Get the individual parts of the multiaddr, in order (e.g. ["/ip4/8.8.8.8", "/tcp/80"])

protocolNames :: Multiaddr -> [Text] Source

Get an ordered list of the protocols specified by the multiaddr. Protocols can appear more than once if they are repeated in the multiaddr.

hasIPv4 :: Multiaddr -> Bool Source

Does the multiaddr contain an IPv4 part?

hasIPv6 :: Multiaddr -> Bool Source

Does the multiaddr contain an IPv6 part?

hasUDP :: Multiaddr -> Bool Source

Does the multiaddr contain a UDP part?

hasTCP :: Multiaddr -> Bool Source

Does the multiaddr contain a TCP part?

hasIPFS :: Multiaddr -> Bool Source

Does the multiaddr contain an IPFS part?

AddrPart type

IPv4 type

readIPv4 :: Text -> Maybe IPv4 Source

Try to read an IPv4 address (e.g. "192.168.1.2")

IPv6 type

readIPv6 :: Text -> Maybe IPv6 Source

Try to read an IPv6 address (e.g. "2001:db8:85a3:8d3:1319:8a2e:370:7348")