diff options
author | James Crayne <jim.crayne@gmail.com> | 2019-09-28 13:43:29 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2020-01-01 19:27:53 -0500 |
commit | 11987749fc6e6d3e53ea737d46d5ab13a16faeb8 (patch) | |
tree | 5716463275c2d3e902889db619908ded2a73971c /dht/Presence/PeerResolve.hs | |
parent | add2c76bced51fde5e9917e7449ef52be70faf87 (diff) |
Factor out some new libraries
word64-map:
Data.Word64Map
network-addr:
Network.Address
tox-crypto:
Crypto.Tox
lifted-concurrent:
Control.Concurrent.Lifted.Instrument
Control.Concurrent.Async.Lifted.Instrument
psq-wrap:
Data.Wrapper.PSQInt
Data.Wrapper.PSQ
minmax-psq:
Data.MinMaxPSQ
tasks:
Control.Concurrent.Tasks
kad:
Network.Kademlia
Network.Kademlia.Bootstrap
Network.Kademlia.Routing
Network.Kademlia.CommonAPI
Network.Kademlia.Persistence
Network.Kademlia.Search
Diffstat (limited to 'dht/Presence/PeerResolve.hs')
-rw-r--r-- | dht/Presence/PeerResolve.hs | 27 |
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 @@ | |||
1 | module PeerResolve | ||
2 | ( peerKeyToResolvedNames | ||
3 | , resolvePeer | ||
4 | , parseAddress | ||
5 | , unsafeParseAddress | ||
6 | , strip_brackets | ||
7 | , withPort | ||
8 | ) where | ||
9 | |||
10 | import Data.Text ( Text ) | ||
11 | import Network.Socket ( SockAddr(..) ) | ||
12 | import System.IO.Unsafe | ||
13 | |||
14 | import DNSCache | ||
15 | import ConnectionKey | ||
16 | |||
17 | {-# NOINLINE global_dns_cache #-} | ||
18 | global_dns_cache :: DNSCache | ||
19 | global_dns_cache = unsafePerformIO $ newDNSCache | ||
20 | |||
21 | resolvePeer :: Text -> IO [PeerAddress] | ||
22 | resolvePeer addrtext = map PeerAddress <$> forwardResolve global_dns_cache addrtext | ||
23 | |||
24 | peerKeyToResolvedNames :: PeerAddress -> IO [Text] | ||
25 | peerKeyToResolvedNames (PeerAddress addr) | ||
26 | = reverseResolve global_dns_cache addr | ||
27 | |||