diff options
author | Joey Hess <joey@kitenet.net> | 2013-12-03 13:14:49 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-12-03 13:14:49 -0400 |
commit | 46bafffb40f438d4aff6d26e0e5963a57692589f (patch) | |
tree | 16db3bc92ade89f413259d3d3500c25405dbb2a3 /standalone/android | |
parent | 88861987a9096453aa34469f2edf207bd5a5843d (diff) |
Android: Fix SRV record lookups for XMPP to use android getprop command to find DNS server, since there is no resolv.conf.
Diffstat (limited to 'standalone/android')
-rw-r--r-- | standalone/android/haskell-patches/dns_use-android-net.dns1-command-instead-of-resolv.conf.patch | 59 | ||||
-rwxr-xr-x | standalone/android/install-haskell-packages | 1 |
2 files changed, 60 insertions, 0 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 new file mode 100644 index 000000000..030f59ed1 --- /dev/null +++ b/standalone/android/haskell-patches/dns_use-android-net.dns1-command-instead-of-resolv.conf.patch @@ -0,0 +1,59 @@ +From bf2126a729e87c5eae7893a48f850993498a666a Mon Sep 17 00:00:00 2001 +From: Joey Hess <joey@kitenet.net> +Date: Tue, 3 Dec 2013 13:11:15 -0400 +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, +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 | 11 +++++++---- + dns.cabal | 1 + + 2 files changed, 8 insertions(+), 4 deletions(-) + +diff --git a/Network/DNS/Resolver.hs b/Network/DNS/Resolver.hs +index 9e6c951..c210763 100644 +--- a/Network/DNS/Resolver.hs ++++ b/Network/DNS/Resolver.hs +@@ -27,6 +27,7 @@ import Network.Socket.ByteString.Lazy + import Prelude hiding (lookup) + import System.Random + import System.Timeout ++import System.Process + + #if mingw32_HOST_OS == 1 + import Network.Socket (send) +@@ -111,10 +112,12 @@ makeResolvSeed conf = ResolvSeed <$> addr + where + 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 ++ 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 ++ [] -> "8.8.8.8" -- google public dns as a fallback only ++ (l:_) -> l + + makeAddrInfo :: HostName -> IO AddrInfo + makeAddrInfo addr = do +diff --git a/dns.cabal b/dns.cabal +index 0a7e6f8..06f5a90 100644 +--- a/dns.cabal ++++ b/dns.cabal +@@ -37,6 +37,7 @@ Library + , network >= 2.3 + , network-conduit + , random ++ , process + else + Build-Depends: base >= 4 && < 5 + , attoparsec +-- +1.8.4.4 + diff --git a/standalone/android/install-haskell-packages b/standalone/android/install-haskell-packages index f0a4b9113..a8d4a18f9 100755 --- a/standalone/android/install-haskell-packages +++ b/standalone/android/install-haskell-packages @@ -98,6 +98,7 @@ install_pkgs () { patched DAV patched language-javascript patched uuid + patched dns cd .. |