aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartijn Kaijser <machine.sanctum@gmail.com>2014-09-23 08:41:17 +0200
committerMartijn Kaijser <machine.sanctum@gmail.com>2014-09-23 08:41:17 +0200
commitc945c4a72f658a97176fe68d7531e9aeab948dde (patch)
tree74a63996ae1b3ef4922dfd5b391c7128707fe25b
parent6bac007a04b54c5e52532e3c68513505f5bdfdf7 (diff)
parent61cae440d51772896dd361279c2e746463562bf6 (diff)
Merge pull request #5373 from Memphiz/osx_dns2
[osx] - get secondary DNS
-rw-r--r--xbmc/network/linux/NetworkLinux.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/xbmc/network/linux/NetworkLinux.cpp b/xbmc/network/linux/NetworkLinux.cpp
index fb795d7da6..ddec359d06 100644
--- a/xbmc/network/linux/NetworkLinux.cpp
+++ b/xbmc/network/linux/NetworkLinux.cpp
@@ -472,17 +472,22 @@ std::vector<std::string> CNetworkLinux::GetNameServers(void)
std::vector<std::string> result;
#if defined(TARGET_DARWIN)
- //only finds the primary dns (0 :)
- FILE* pipe = popen("scutil --dns | grep \"nameserver\\[0\\]\" | tail -n1", "r");
+ FILE* pipe = popen("scutil --dns | grep \"nameserver\" | tail -n2", "r");
+ Sleep(100);
if (pipe)
{
- std::string tmpStr;
+ vector<std::string> tmpStr;
char buffer[256] = {'\0'};
if (fread(buffer, sizeof(char), sizeof(buffer), pipe) > 0 && !ferror(pipe))
{
- tmpStr = buffer;
- if (tmpStr.length() >= 17)
- result.push_back(tmpStr.substr(17));
+ tmpStr = StringUtils::Split(buffer, "\n");
+ for (unsigned int i = 0; i < tmpStr.size(); i ++)
+ {
+ // result looks like this - > ' nameserver[0] : 192.168.1.1'
+ // 2 blank spaces + 13 in 'nameserver[0]' + blank + ':' + blank == 18 :)
+ if (tmpStr[i].length() >= 18)
+ result.push_back(tmpStr[i].substr(18));
+ }
}
pclose(pipe);
}