libevent: Add patch for DNS resolution on Android

This commit is contained in:
Fredrik Fornwall 2016-08-26 17:20:32 -04:00
parent 85e28b3243
commit b5cb2a609b
2 changed files with 36 additions and 0 deletions

View File

@ -1,6 +1,7 @@
TERMUX_PKG_HOMEPAGE=http://libevent.org/
TERMUX_PKG_DESCRIPTION="Library that provides asynchronous event notification"
TERMUX_PKG_VERSION=2.0.22
TERMUX_PKG_BUILD_REVISION=1
TERMUX_PKG_SRCURL=https://github.com/libevent/libevent/releases/download/release-${TERMUX_PKG_VERSION}-stable/libevent-${TERMUX_PKG_VERSION}-stable.tar.gz
# Strip away libevent core, extra and openssl libraries until someone uses them
TERMUX_PKG_RM_AFTER_INSTALL="bin/event_rpcgen.py lib/libevent_*"

View File

@ -0,0 +1,35 @@
diff -u -r ../libevent-2.0.22-stable/evdns.c ./evdns.c
--- ../libevent-2.0.22-stable/evdns.c 2014-03-26 11:09:18.000000000 -0400
+++ ./evdns.c 2016-08-26 17:17:43.939853284 -0400
@@ -49,6 +49,9 @@
*/
#include <sys/types.h>
+#ifdef __ANDROID__
+# include <sys/system_properties.h>
+#endif
#include "event2/event-config.h"
#ifndef _FORTIFY_SOURCE
@@ -3892,6 +3895,21 @@
int r;
#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