Android: Fix SRV record lookups for XMPP to use android getprop command to find DNS server, since there is no resolv.conf.
This commit is contained in:
parent
33f89c9d03
commit
b2e9339b57
3 changed files with 62 additions and 0 deletions
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -12,6 +12,8 @@ git-annex (5.20131131) UNRELEASED; urgency=low
|
||||||
* copy --from, get --from: When --force is used, ignore the
|
* copy --from, get --from: When --force is used, ignore the
|
||||||
location log and always try to get the file from the remote.
|
location log and always try to get the file from the remote.
|
||||||
* Deal with box.com changing the url of their webdav endpoint.
|
* Deal with box.com changing the url of their webdav endpoint.
|
||||||
|
* Android: Fix SRV record lookups for XMPP to use android getprop
|
||||||
|
command to find DNS server, since there is no resolv.conf.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Sun, 01 Dec 2013 13:57:58 -0400
|
-- Joey Hess <joeyh@debian.org> Sun, 01 Dec 2013 13:57:58 -0400
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -98,6 +98,7 @@ install_pkgs () {
|
||||||
patched DAV
|
patched DAV
|
||||||
patched language-javascript
|
patched language-javascript
|
||||||
patched uuid
|
patched uuid
|
||||||
|
patched dns
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue