2014-10-16 04:31:59 +00:00
|
|
|
From 087f1ae5e17f0e6d7c9f6b4092a5bb5bb6f5bf60 Mon Sep 17 00:00:00 2001
|
2014-05-26 02:47:15 +00:00
|
|
|
From: dummy <dummy@example.com>
|
2014-10-16 04:31:59 +00:00
|
|
|
Date: Thu, 16 Oct 2014 02:59:11 +0000
|
|
|
|
Subject: [PATCH] port
|
2013-12-03 17:14:49 +00:00
|
|
|
|
|
|
|
---
|
2014-10-16 04:31:59 +00:00
|
|
|
Network/DNS/Resolver.hs | 13 ++++++++-----
|
|
|
|
dns.cabal | 1 +
|
|
|
|
2 files changed, 9 insertions(+), 5 deletions(-)
|
2013-12-03 17:14:49 +00:00
|
|
|
|
|
|
|
diff --git a/Network/DNS/Resolver.hs b/Network/DNS/Resolver.hs
|
2014-10-16 04:31:59 +00:00
|
|
|
index 5721e03..c4400d1 100644
|
2013-12-03 17:14:49 +00:00
|
|
|
--- a/Network/DNS/Resolver.hs
|
|
|
|
+++ b/Network/DNS/Resolver.hs
|
2014-05-26 02:47:15 +00:00
|
|
|
@@ -19,7 +19,7 @@ module Network.DNS.Resolver (
|
|
|
|
) where
|
|
|
|
|
|
|
|
import Control.Applicative ((<$>), (<*>), pure)
|
|
|
|
-import Control.Exception (bracket)
|
|
|
|
+import Control.Exception (bracket, catch, IOException)
|
2014-10-16 04:31:59 +00:00
|
|
|
import qualified Data.ByteString.Char8 as BS
|
2014-05-26 02:47:15 +00:00
|
|
|
import Data.Char (isSpace)
|
|
|
|
import Data.List (isPrefixOf)
|
2014-10-16 04:31:59 +00:00
|
|
|
@@ -32,6 +32,7 @@ import Network.Socket (AddrInfoFlag(..), AddrInfo(..), defaultHints, getAddrInfo
|
2013-12-03 17:14:49 +00:00
|
|
|
import Prelude hiding (lookup)
|
2014-05-26 02:47:15 +00:00
|
|
|
import System.Random (getStdRandom, randomR)
|
|
|
|
import System.Timeout (timeout)
|
2013-12-03 17:14:49 +00:00
|
|
|
+import System.Process
|
|
|
|
|
|
|
|
#if mingw32_HOST_OS == 1
|
|
|
|
import Network.Socket (send)
|
2014-10-16 04:31:59 +00:00
|
|
|
@@ -130,10 +131,12 @@ makeResolvSeed conf = ResolvSeed <$> addr
|
|
|
|
where
|
2013-12-03 17:14:49 +00:00
|
|
|
addr = case resolvInfo conf of
|
2014-10-16 04:31:59 +00:00
|
|
|
RCHostName numhost -> makeAddrInfo numhost
|
|
|
|
- RCFilePath file -> toAddr <$> readFile file >>= makeAddrInfo
|
|
|
|
- toAddr cs = let l:_ = filter ("nameserver" `isPrefixOf`) $ lines cs
|
|
|
|
- in extract l
|
|
|
|
- extract = reverse . dropWhile isSpace . reverse . dropWhile isSpace . drop 11
|
2013-12-03 17:14:49 +00:00
|
|
|
+ RCFilePath file -> do
|
|
|
|
+ -- Android has no /etc/resolv.conf; use getprop command.
|
|
|
|
+ ls <- catch (lines <$> readProcess "getprop" ["net.dns1"] []) (const (return []) :: IOException -> IO [String])
|
2014-10-16 04:31:59 +00:00
|
|
|
+ makeAddrInfo $ case ls of
|
2013-12-03 17:14:49 +00:00
|
|
|
+ [] -> "8.8.8.8" -- google public dns as a fallback only
|
|
|
|
+ (l:_) -> l
|
2014-10-16 04:31:59 +00:00
|
|
|
|
|
|
|
makeAddrInfo :: HostName -> IO AddrInfo
|
|
|
|
makeAddrInfo addr = do
|
2013-12-03 17:14:49 +00:00
|
|
|
diff --git a/dns.cabal b/dns.cabal
|
2014-10-16 04:31:59 +00:00
|
|
|
index ceaf5f4..cd15e61 100644
|
2013-12-03 17:14:49 +00:00
|
|
|
--- a/dns.cabal
|
|
|
|
+++ b/dns.cabal
|
2014-10-16 04:31:59 +00:00
|
|
|
@@ -37,6 +37,7 @@ Library
|
2013-12-03 17:14:49 +00:00
|
|
|
, network >= 2.3
|
|
|
|
, random
|
2014-05-26 02:47:15 +00:00
|
|
|
, resourcet
|
2013-12-03 17:14:49 +00:00
|
|
|
+ , process
|
|
|
|
else
|
|
|
|
Build-Depends: base >= 4 && < 5
|
|
|
|
, attoparsec
|
|
|
|
--
|
2014-10-16 04:31:59 +00:00
|
|
|
2.1.1
|
2013-12-03 17:14:49 +00:00
|
|
|
|