diff options
author | Martijn Kaijser <machine.sanctum@gmail.com> | 2014-09-23 08:41:17 +0200 |
---|---|---|
committer | Martijn Kaijser <machine.sanctum@gmail.com> | 2014-09-23 08:41:17 +0200 |
commit | c945c4a72f658a97176fe68d7531e9aeab948dde (patch) | |
tree | 74a63996ae1b3ef4922dfd5b391c7128707fe25b | |
parent | 6bac007a04b54c5e52532e3c68513505f5bdfdf7 (diff) | |
parent | 61cae440d51772896dd361279c2e746463562bf6 (diff) |
Merge pull request #5373 from Memphiz/osx_dns2
[osx] - get secondary DNS
-rw-r--r-- | xbmc/network/linux/NetworkLinux.cpp | 17 |
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); } |