diff options
Diffstat (limited to 'Presence')
-rw-r--r-- | Presence/PeerResolve.hs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Presence/PeerResolve.hs b/Presence/PeerResolve.hs new file mode 100644 index 00000000..39607ef4 --- /dev/null +++ b/Presence/PeerResolve.hs | |||
@@ -0,0 +1,39 @@ | |||
1 | module PeerResolve | ||
2 | ( peerKeyToResolvedNames | ||
3 | , resolvePeer | ||
4 | , parseAddress | ||
5 | , strip_brackets | ||
6 | , withPort | ||
7 | ) where | ||
8 | |||
9 | import Data.List ( nub ) | ||
10 | import Data.Text ( Text ) | ||
11 | import Network.Socket ( SockAddr(..) ) | ||
12 | import System.Endian ( fromBE32, toBE32 ) | ||
13 | import System.IO.Error ( isDoesNotExistError ) | ||
14 | import Control.Exception ( handle, ErrorCall(..) ) | ||
15 | import qualified Network.BSD as BSD | ||
16 | import qualified Data.Text as Text | ||
17 | import Control.Concurrent | ||
18 | import Control.Concurrent.STM | ||
19 | import Control.Monad | ||
20 | import Data.Maybe | ||
21 | import System.IO.Unsafe | ||
22 | |||
23 | import GetHostByAddr | ||
24 | import DNSCache | ||
25 | import ConnectionKey | ||
26 | import ControlMaybe | ||
27 | |||
28 | {-# NOINLINE global_dns_cache #-} | ||
29 | global_dns_cache = unsafePerformIO $ newDNSCache | ||
30 | |||
31 | resolvePeer :: Text -> IO [SockAddr] | ||
32 | resolvePeer addrtext = forwardResolve global_dns_cache addrtext | ||
33 | |||
34 | peerKeyToResolvedNames :: ConnectionKey -> IO [Text] | ||
35 | peerKeyToResolvedNames k@(ClientKey { localAddress=addr }) = return [] | ||
36 | peerKeyToResolvedNames k@(PeerKey { callBackAddress=addr }) = do | ||
37 | reverseResolve global_dns_cache addr | ||
38 | |||
39 | |||