mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
DNS (Windows): add support
Currently reports IPv4 addrs only
This commit is contained in:
+1
-1
@@ -689,7 +689,7 @@ elseif(WIN32)
|
||||
src/detection/physicaldisk/physicaldisk_windows.c
|
||||
src/detection/diskio/diskio_windows.c
|
||||
src/detection/displayserver/displayserver_windows.c
|
||||
src/detection/dns/dns_linux.c
|
||||
src/detection/dns/dns_windows.c
|
||||
src/detection/font/font_windows.c
|
||||
src/detection/gpu/gpu_windows.c
|
||||
src/detection/host/host_windows.c
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#include "detection/dns/dns.h"
|
||||
|
||||
const char* ffDetectDNS(FF_MAYBE_UNUSED FFlist* results)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "detection/dns/dns.h"
|
||||
#include "util/mallocHelper.h"
|
||||
|
||||
#include <iphlpapi.h>
|
||||
|
||||
const char* ffDetectDNS(FFlist* results)
|
||||
{
|
||||
FF_AUTO_FREE FIXED_INFO* fixedInfo = malloc(sizeof(FIXED_INFO));
|
||||
ULONG size = sizeof(fixedInfo);
|
||||
while (true)
|
||||
{
|
||||
DWORD res = GetNetworkParams(fixedInfo, &size);
|
||||
if (res == ERROR_BUFFER_OVERFLOW)
|
||||
{
|
||||
fixedInfo = realloc(fixedInfo, size);
|
||||
continue;
|
||||
}
|
||||
else if (res != ERROR_SUCCESS)
|
||||
return "GetNetworkParams() failed";
|
||||
break;
|
||||
}
|
||||
|
||||
for (IP_ADDR_STRING* dns = &fixedInfo->DnsServerList; dns; dns = dns->Next)
|
||||
{
|
||||
FFstrbuf* item = (FFstrbuf*) ffListAdd(results);
|
||||
ffStrbufInitS(item, dns->IpAddress.String);
|
||||
ffStrbufTrimRightSpace(item);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -20,7 +20,7 @@ void ffPrintDNS(FFDNSOptions* options)
|
||||
|
||||
if (result.length == 0)
|
||||
{
|
||||
ffPrintError(FF_DNS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "NO DNS detected");
|
||||
ffPrintError(FF_DNS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "NO DNS servers detected");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user