From b5cb2a609b2911ca725560f89f36f7109aa5c888 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Fri, 26 Aug 2016 17:20:32 -0400 Subject: [PATCH] libevent: Add patch for DNS resolution on Android --- packages/libevent/build.sh | 1 + packages/libevent/evdns.c.patch | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 packages/libevent/evdns.c.patch diff --git a/packages/libevent/build.sh b/packages/libevent/build.sh index 7108e06fc..13264f3ba 100755 --- a/packages/libevent/build.sh +++ b/packages/libevent/build.sh @@ -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_*" diff --git a/packages/libevent/evdns.c.patch b/packages/libevent/evdns.c.patch new file mode 100644 index 000000000..93f7bac2f --- /dev/null +++ b/packages/libevent/evdns.c.patch @@ -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 ++#ifdef __ANDROID__ ++# include ++#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