summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Presence/PeerResolve.hs39
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 @@
1module PeerResolve
2 ( peerKeyToResolvedNames
3 , resolvePeer
4 , parseAddress
5 , strip_brackets
6 , withPort
7 ) where
8
9import Data.List ( nub )
10import Data.Text ( Text )
11import Network.Socket ( SockAddr(..) )
12import System.Endian ( fromBE32, toBE32 )
13import System.IO.Error ( isDoesNotExistError )
14import Control.Exception ( handle, ErrorCall(..) )
15import qualified Network.BSD as BSD
16import qualified Data.Text as Text
17import Control.Concurrent
18import Control.Concurrent.STM
19import Control.Monad
20import Data.Maybe
21import System.IO.Unsafe
22
23import GetHostByAddr
24import DNSCache
25import ConnectionKey
26import ControlMaybe
27
28{-# NOINLINE global_dns_cache #-}
29global_dns_cache = unsafePerformIO $ newDNSCache
30
31resolvePeer :: Text -> IO [SockAddr]
32resolvePeer addrtext = forwardResolve global_dns_cache addrtext
33
34peerKeyToResolvedNames :: ConnectionKey -> IO [Text]
35peerKeyToResolvedNames k@(ClientKey { localAddress=addr }) = return []
36peerKeyToResolvedNames k@(PeerKey { callBackAddress=addr }) = do
37 reverseResolve global_dns_cache addr
38
39