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 -> [MultiaddrPart]
- protocolNames :: Multiaddr -> [Text]
- hasIPv4 :: Multiaddr -> Bool
- hasIPv6 :: Multiaddr -> Bool
- hasUDP :: Multiaddr -> Bool
- hasTCP :: Multiaddr -> Bool
- hasUDT :: Multiaddr -> Bool
- hasUTP :: Multiaddr -> Bool
- hasDCCP :: Multiaddr -> Bool
- hasSCTP :: Multiaddr -> Bool
- hasIPFS :: Multiaddr -> Bool
- data MultiaddrPart
- data IPv4Addr = IPv4Addr !Word32
- readIPv4Addr :: Text -> Maybe IPv4Addr
- data IPv6Addr = IPv6Addr !Word32 !Word32 !Word32 !Word32
- readIPv6Addr :: Text -> Maybe IPv6Addr
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 -> [MultiaddrPart] 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.
MultiaddrPart type
data MultiaddrPart Source
An individual component of a multiaddr.
IPv4 type
An IPv4 address.
readIPv4Addr :: Text -> Maybe IPv4Addr Source
Try to read an IPv4 address (e.g. "192.168.1.2"
)
IPv6 type
An IPv6 address.
readIPv6Addr :: Text -> Maybe IPv6Addr Source
Try to read an IPv6 address
(e.g. "2001:db8:85a3:8d3:1319:8a2e:370:7348"
)