haskell-tor-0.1.1: A Haskell Tor Node

Safe HaskellNone
LanguageHaskell2010

Tor.State.Routers

Description

A module for maintaining an up-to-date list of Tor nodes in the Tor network.

Synopsis

Documentation

data RouterDB Source

The current router database, refreshed at regular intervals.

data RouterRestriction Source

Restrictions to apply when searching for a router or set of routers.

Constructors

IsStable

Marked with the Stable flag

NotRouter RouterDesc

Is not the given router

NotTorAddr TorAddress

Is not the given address

ExitNode

Is an exit node of some kind

ExitNodeAllowing TorAddress Word16

Is an exit node that allows traffic to the given address and port.

newRouterDatabase :: TorNetworkStack ls s -> DirectoryDB -> (String -> IO ()) -> IO RouterDB Source

Build a new router database. This database will return before it is fully initialized, in order to make general start-up faster. This may mean that some queries of the database will take longer upon initial loading, or when the database is being refreshed periodicatly.

findRouter :: RouterDB -> [ExtendSpec] -> IO (Maybe RouterDesc) Source

Find a router given its fingerprint.

getRouter :: RouterDB -> [RouterRestriction] -> TorRNG -> IO (TorRNG, RouterDesc) Source

Fetch a router matching the given restrictions. The restrictions list should be thought of an AND with a default of True given the empty list. This routine may take awhile to find a suitable entry if the restrictions are cumbersome or if the database is being reloaded.

meetsRestrictions :: RouterDesc -> [RouterRestriction] -> Bool Source

Returns true iff the given router meets all the given restrictions. (If no restrictions are provided, then the router meets all of them.)

allowsExit :: [ExitRule] -> TorAddress -> Word16 -> Bool Source

Returns true iff the given exit rules allow traffic to the given address / port pair.