termux-packages/packages/libevent/evdns.c.patch

36 lines
1.0 KiB
Diff
Raw Normal View History

2017-01-28 10:42:52 +01:00
diff -u -r ../libevent-release-2.1.8-stable/evdns.c ./evdns.c
--- ../libevent-release-2.1.8-stable/evdns.c 2017-01-26 00:37:15.000000000 +0100
+++ ./evdns.c 2017-01-28 00:02:43.332229763 +0100
@@ -52,6 +52,9 @@
#include "evconfig-private.h"
#include <sys/types.h>
+#ifdef __ANDROID__
+# include <sys/system_properties.h>
+#endif
#ifndef _FORTIFY_SOURCE
2017-01-28 10:42:52 +01:00
#define _FORTIFY_SOURCE 3
@@ -3959,6 +3962,21 @@
int r;
2017-01-28 10:42:52 +01:00
#ifdef _WIN32
r = evdns_base_config_windows_nameservers(base);
+#elif defined(__ANDROID__)
+ /** From: http://www.programering.com/a/MjMwcjMwATA.html */
+ int add_servers = 0;
+ char buf[PROP_VALUE_MAX];
+ r = __system_property_get("net.dns1", buf);
+ if (r >= 7) {
+ add_servers++;
+ evdns_base_nameserver_ip_add(base, buf);
+ }
+ r = __system_property_get("net.dns2", buf);
+ if (r >= 7) {
+ add_servers++;
+ evdns_base_nameserver_ip_add(base, buf);
+ }
+ if (add_servers == 0) evdns_base_nameserver_ip_add(base, "8.8.8.8");
#else
r = evdns_base_resolv_conf_parse(base, DNS_OPTIONS_ALL, "/etc/resolv.conf");
#endif