summaryrefslogtreecommitdiff
path: root/dht/Presence/PeerResolve.hs
diff options
context:
space:
mode:
Diffstat (limited to 'dht/Presence/PeerResolve.hs')
-rw-r--r--dht/Presence/PeerResolve.hs27
1 files changed, 27 insertions, 0 deletions
diff --git a/dht/Presence/PeerResolve.hs b/dht/Presence/PeerResolve.hs
new file mode 100644
index 00000000..62becfe1
--- /dev/null
+++ b/dht/Presence/PeerResolve.hs
@@ -0,0 +1,27 @@
1module PeerResolve
2 ( peerKeyToResolvedNames
3 , resolvePeer
4 , parseAddress
5 , unsafeParseAddress
6 , strip_brackets
7 , withPort
8 ) where
9
10import Data.Text ( Text )
11import Network.Socket ( SockAddr(..) )
12import System.IO.Unsafe
13
14import DNSCache
15import ConnectionKey
16
17{-# NOINLINE global_dns_cache #-}
18global_dns_cache :: DNSCache
19global_dns_cache = unsafePerformIO $ newDNSCache
20
21resolvePeer :: Text -> IO [PeerAddress]
22resolvePeer addrtext = map PeerAddress <$> forwardResolve global_dns_cache addrtext
23
24peerKeyToResolvedNames :: PeerAddress -> IO [Text]
25peerKeyToResolvedNames (PeerAddress addr)
26 = reverseResolve global_dns_cache addr
27