Copyright | (c) 2016 Micxjo Funkcio |
---|---|
License | BSD3 |
Maintainer | micxjo@fastmail.com |
Stability | Experimental |
Safe Haskell | None |
Language | Haskell2010 |
Multiaddr is a self-describing network address format supporting a variety of protocols, with both string and binary representations.
- data Multiaddr
- readMultiaddr :: Text -> Maybe Multiaddr
- encode :: Multiaddr -> ByteString
- decode :: ByteString -> Maybe Multiaddr
- class TextAddr a where
- encapsulate :: Multiaddr -> Multiaddr -> Multiaddr
- parts :: Multiaddr -> [AddrPart]
- protocolNames :: Multiaddr -> [Text]
- hasIPv4 :: Multiaddr -> Bool
- hasIPv6 :: Multiaddr -> Bool
- hasUDP :: Multiaddr -> Bool
- hasTCP :: Multiaddr -> Bool
- hasIPFS :: Multiaddr -> Bool
- data AddrPart
- data IPv4 = IPv4 !Word32
- readIPv4 :: Text -> Maybe IPv4
- data IPv6 = IPv6 !Word32 !Word32 !Word32 !Word32
- readIPv6 :: Text -> Maybe IPv6
Multiaddr type
A network address.
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.
Render an address to its standard text representation.
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.
AddrPart type
An individual component of a multiaddr.
IPv4 type
An IPv4 address.
IPv6 type
An IPv6 address.