haskell-tor-0.1.1: A Haskell Tor Node

Safe HaskellNone
LanguageHaskell2010

Tor.DataFormat.Helpers

Description

Miscellaneous very useful parsing routines.

Synopsis

Documentation

data PortSpec Source

A port specifier

Constructors

PortSpecAll

Accept any port

PortSpecRange Word16 Word16

Accept ports between the two values, inclusive.

PortSpecSingle Word16

Accept only the given port.

data AddrSpec Source

An address or subnet specifier.

Constructors

AddrSpecAll

Accept any address

AddrSpecIP4 String

Accept this specific address.

AddrSpecIP4Mask String String

Accept this IP address and subnet mask (255.255.255.0,etc.)

AddrSpecIP4Bits String Int

Accept this IP address and CIDR mask (/24,etc.)

AddrSpecIP6 String

Accept this specific IP6 address.

AddrSpecIP6Bits String Int

Accept this subnet and CIDR mask.

standardLine :: String -> Parser a -> Parser a Source

Parse a standard line of "name thingn".

nickname :: Parser String Source

Parse a Tor nickname.

hexDigest :: Parser ByteString Source

Parse a 20 byte hex digest.

port :: Bool -> Parser Word16 Source

Parse a port number.

addrSpec :: Parser AddrSpec Source

Parse an address specifier.

portSpec :: Parser PortSpec Source

Parse a port specifier

ip4 :: Parser String Source

Parse an IPv4 address.

ip6 :: Parser String Source

Parse an IPv6 address; assuming [0000:1111:....] format, with braces.

publicKey :: Parser PublicKey Source

Parse a public key.

publicKey' :: Parser (PublicKey, ByteString) Source

Parse a public key. Returns both the public key and the raw data behind it.

utcTime :: Parser DateTime Source

Parse a timestamp in UTC format.

bool :: Parser Bool Source

Parse a boolean. (0/1)

char8 :: Char -> Parser Word8 Source

Parse a character.

alphaNum :: Parser Word8 Source

Parse an alphanumeric character.

decDigit :: Parser Word8 Source

Parse a decimal digit.

hexDigit :: Parser Word8 Source

Parse a hex digit.

base64Char :: Parser Word8 Source

Parse a character in a Base64 stream.

decimalNum :: (Integral a, Read a) => (a -> Bool) -> Parser a Source

Parse a decimal number that matches the given predicate.

whitespace :: Parser () Source

Eat up some whitespace.

whitespace1 :: Parser () Source

Eat up at least one character of whitespace.

sp :: Parser Word8 Source

Read a space.

nl :: Parser Word8 Source

Read a newline.

newline :: Parser () Source

Eat some amount of whitespace and then a newline.

toString :: [Word8] -> String Source

Convert a series of bytes into a character string.

readHex :: String -> ByteString Source

Read a hex number into a bytestring in the obvious way.

decodeBase64 :: [Word8] -> Parser ByteString Source

Decode a series of characters as a Base64 stream.