diff options
author | Joey Hess <joey@kitenet.net> | 2014-07-03 19:46:27 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-07-03 19:46:27 -0400 |
commit | a26aaf436d9af0154ceb990b4efe0de424e92ff2 (patch) | |
tree | b03dbe6232b442d3c43186c4a7356c9b3527b4da /standalone/android/haskell-patches/dns_use-android-net.dns1-command-instead-of-resolv.conf.patch | |
parent | 05bdec58c7943eabc8a6ecf70d4fae21420d0838 (diff) | |
parent | a8da82baa84171bb40b98c7cd9d3c33613410ce2 (diff) |
Merge orca:/tmp/build
Diffstat (limited to 'standalone/android/haskell-patches/dns_use-android-net.dns1-command-instead-of-resolv.conf.patch')
-rw-r--r-- | standalone/android/haskell-patches/dns_use-android-net.dns1-command-instead-of-resolv.conf.patch | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/standalone/android/haskell-patches/dns_use-android-net.dns1-command-instead-of-resolv.conf.patch b/standalone/android/haskell-patches/dns_use-android-net.dns1-command-instead-of-resolv.conf.patch index f510b0d8d..a00338fab 100644 --- a/standalone/android/haskell-patches/dns_use-android-net.dns1-command-instead-of-resolv.conf.patch +++ b/standalone/android/haskell-patches/dns_use-android-net.dns1-command-instead-of-resolv.conf.patch @@ -1,6 +1,6 @@ -From 3f72e299c50476c270c5187092d6e8b13ddfbf1e Mon Sep 17 00:00:00 2001 +From aaef1aadb21a198475a656132ef4488b85b8fd1b Mon Sep 17 00:00:00 2001 From: dummy <dummy@example.com> -Date: Mon, 26 May 2014 01:53:13 +0000 +Date: Thu, 3 Jul 2014 23:22:47 +0000 Subject: [PATCH] use android net.dns1 command instead of resolv.conf file Android has no /etc/resolv.conf. Some might have /system/etc/resolv.conf, @@ -9,12 +9,12 @@ but even that does not seem likely. This is likely a little slow, but is at least fine for git-annex's uses, since it only uses this library for occasional SRV lookups. --- - Network/DNS/Resolver.hs | 13 ++++++++----- + Network/DNS/Resolver.hs | 11 +++++++++-- dns.cabal | 1 + - 2 files changed, 9 insertions(+), 5 deletions(-) + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Network/DNS/Resolver.hs b/Network/DNS/Resolver.hs -index 5721e03..c4400d1 100644 +index e4124b8..7aca431 100644 --- a/Network/DNS/Resolver.hs +++ b/Network/DNS/Resolver.hs @@ -19,7 +19,7 @@ module Network.DNS.Resolver ( @@ -26,7 +26,7 @@ index 5721e03..c4400d1 100644 import qualified Data.ByteString.Char8 as BS import Data.Char (isSpace) import Data.List (isPrefixOf) -@@ -32,6 +32,7 @@ import Network.Socket (AddrInfoFlag(..), AddrInfo(..), defaultHints, getAddrInfo +@@ -32,6 +32,7 @@ import Network.Socket (AddrInfoFlag(..), AddrInfo(..), SockAddr(..), PortNumber( import Prelude hiding (lookup) import System.Random (getStdRandom, randomR) import System.Timeout (timeout) @@ -34,28 +34,26 @@ index 5721e03..c4400d1 100644 #if mingw32_HOST_OS == 1 import Network.Socket (send) -@@ -130,10 +131,12 @@ makeResolvSeed conf = ResolvSeed <$> addr - where +@@ -132,7 +133,13 @@ makeResolvSeed conf = ResolvSeed <$> addr addr = case resolvInfo conf of - 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 + RCHostName numhost -> makeAddrInfo numhost Nothing + RCHostPort numhost mport -> makeAddrInfo numhost $ Just mport +- RCFilePath file -> toAddr <$> readFile file >>= \i -> makeAddrInfo i Nothing + RCFilePath file -> do + -- Android has no /etc/resolv.conf; use getprop command. + ls <- catch (lines <$> readProcess "getprop" ["net.dns1"] []) (const (return []) :: IOException -> IO [String]) -+ makeAddrInfo $ case ls of ++ let addr = case ls of + [] -> "8.8.8.8" -- google public dns as a fallback only + (l:_) -> l - - makeAddrInfo :: HostName -> IO AddrInfo - makeAddrInfo addr = do ++ makeAddrInfo addr Nothing + toAddr cs = let l:_ = filter ("nameserver" `isPrefixOf`) $ lines cs + in extract l + extract = reverse . dropWhile isSpace . reverse . dropWhile isSpace . drop 11 diff --git a/dns.cabal b/dns.cabal -index ceaf5f4..cd15e61 100644 +index 0a08a9e..724a3e0 100644 --- a/dns.cabal +++ b/dns.cabal -@@ -37,6 +37,7 @@ Library +@@ -38,6 +38,7 @@ Library , network >= 2.3 , random , resourcet |