diff --git a/src/main/jni/Android.mk b/src/main/jni/Android.mk index 796ca06ff7..ab34275cad 100755 --- a/src/main/jni/Android.mk +++ b/src/main/jni/Android.mk @@ -304,13 +304,13 @@ openssl_subdirs := $(addprefix $(LOCAL_PATH)/openssl/,$(addsuffix /Android.mk, \ include $(openssl_subdirs) # Iptables -LOCAL_PATH := $(ROOT_PATH) -iptables_subdirs := $(addprefix $(LOCAL_PATH)/iptables/,$(addsuffix /Android.mk, \ - iptables \ - extensions \ - libiptc \ - )) -include $(iptables_subdirs) +# LOCAL_PATH := $(ROOT_PATH) +# iptables_subdirs := $(addprefix $(LOCAL_PATH)/iptables/,$(addsuffix /Android.mk, \ +# iptables \ +# extensions \ +# libiptc \ +# )) +# include $(iptables_subdirs) # Import cpufeatures $(call import-module,android/cpufeatures) diff --git a/src/main/jni/Application.mk b/src/main/jni/Application.mk index d8820faad0..d3fa0156b1 100644 --- a/src/main/jni/Application.mk +++ b/src/main/jni/Application.mk @@ -1,4 +1,4 @@ -APP_ABI := armeabi-v7a x86 +APP_ABI := armeabi-v7a arm64-v8a x86 x86_64 APP_PLATFORM := android-16 APP_STL := stlport_static NDK_TOOLCHAIN_VERSION := 4.9 diff --git a/src/main/jni/libevent/arc4random.c b/src/main/jni/libevent/arc4random.c index cabc46f4b8..15fee1cceb 100644 --- a/src/main/jni/libevent/arc4random.c +++ b/src/main/jni/libevent/arc4random.c @@ -477,6 +477,7 @@ arc4random(void) } #endif +#ifndef _EVENT_HAVE_ARC4RANDOM_BUF ARC4RANDOM_EXPORT void arc4random_buf(void *_buf, size_t n) { @@ -490,6 +491,7 @@ arc4random_buf(void *_buf, size_t n) } _ARC4_UNLOCK(); } +#endif #ifndef ARC4RANDOM_NOUNIFORM /* diff --git a/src/main/jni/libevent/epoll_sub.c b/src/main/jni/libevent/epoll_sub.c index 3738b26bf1..3feda901b4 100644 --- a/src/main/jni/libevent/epoll_sub.c +++ b/src/main/jni/libevent/epoll_sub.c @@ -31,11 +31,20 @@ #include #include #include +#include int epoll_create(int size) { - return (syscall(__NR_epoll_create, size)); +#if !defined(__NR_epoll_create) && defined(__NR_epoll_create1) + if (size <= 0) { + errno = EINVAL; + return -1; + } + return (syscall(__NR_epoll_create1, 0)); +#else + return (syscall(__NR_epoll_create, size)); +#endif } int @@ -48,5 +57,9 @@ epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout) { - return (syscall(__NR_epoll_wait, epfd, events, maxevents, timeout)); +#if !defined(__NR_epoll_wait) && defined(__NR_epoll_pwait) + return (syscall(__NR_epoll_pwait, epfd, events, maxevents, timeout, NULL, 0)); +#else + return (syscall(__NR_epoll_wait, epfd, events, maxevents, timeout)); +#endif } diff --git a/src/main/jni/libevent/include/event2/event-config.h b/src/main/jni/libevent/include/event2/event-config.h index 85518dedbf..3d363bef03 100644 --- a/src/main/jni/libevent/include/event2/event-config.h +++ b/src/main/jni/libevent/include/event2/event-config.h @@ -24,10 +24,12 @@ /* #undef _EVENT_DISABLE_THREAD_SUPPORT */ /* Define to 1 if you have the `arc4random' function. */ +#if !defined(__aarch64__) && !defined(__x86_64__) #define _EVENT_HAVE_ARC4RANDOM 1 +#endif /* Define to 1 if you have the `arc4random_buf' function. */ -/* #undef _EVENT_HAVE_ARC4RANDOM_BUF */ +#define _EVENT_HAVE_ARC4RANDOM_BUF /* Define to 1 if you have the header file. */ #define _EVENT_HAVE_ARPA_INET_H 1 @@ -262,7 +264,7 @@ /* #undef _EVENT_HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY */ /* Define to 1 if you have the `sysctl' function. */ -#define _EVENT_HAVE_SYSCTL 1 +// #define _EVENT_HAVE_SYSCTL 1 /* Define to 1 if you have the header file. */ /* #undef _EVENT_HAVE_SYS_DEVPOLL_H */ @@ -301,7 +303,7 @@ #define _EVENT_HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ -#define _EVENT_HAVE_SYS_SYSCTL_H 1 +//#define _EVENT_HAVE_SYS_SYSCTL_H 1 /* Define to 1 if you have the header file. */ #define _EVENT_HAVE_SYS_TIME_H 1 diff --git a/src/main/jni/openssl/android-config.mk b/src/main/jni/openssl/android-config.mk index 4a4f21514b..1fa94a3712 100644 --- a/src/main/jni/openssl/android-config.mk +++ b/src/main/jni/openssl/android-config.mk @@ -15,7 +15,7 @@ LOCAL_CFLAGS += -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_SCTP \ # LOCAL_CFLAGS += -DOPENSSL_NO_DEPRECATED # Extra -LOCAL_CFLAGS += -DOPENSSL_NO_HW -DOPENSSL_NO_ENGINE -DZLIB +LOCAL_CFLAGS += -DOPENSSL_NO_HW -DOPENSSL_NO_ASM -DOPENSSL_NO_ENGINE -DZLIB # Debug # LOCAL_CFLAGS += -DCIPHER_DEBUG diff --git a/src/main/jni/pdnsd/config.h b/src/main/jni/pdnsd/config.h index 3c136abfe3..3740beae73 100644 --- a/src/main/jni/pdnsd/config.h +++ b/src/main/jni/pdnsd/config.h @@ -219,7 +219,9 @@ #define HAVE_FCNTL_H 1 /* Define to 1 if you have the `getline' function. */ -//#define HAVE_GETLINE 1 +#if defined(__aarch64__) || defined(__x86_64__) +#define HAVE_GETLINE 1 +#endif /* Define to 1 if you have the `getpwnam_r' function. */ //#define HAVE_GETPWNAM_R 1 @@ -282,7 +284,9 @@ #define HAVE_STDLIB_H 1 /* Define to 1 if you have the `stpcpy' function. */ -//#define HAVE_STPCPY 1 +#if defined(__aarch64__) || defined(__x86_64__) +#define HAVE_STPCPY 1 +#endif /* Define to 1 if you have the `stpncpy' function. */ //#define HAVE_STPNCPY 1 diff --git a/src/main/jni/pdnsd/src/ipvers.h b/src/main/jni/pdnsd/src/ipvers.h index e14b9aa4fb..b1d7a2cd9f 100644 --- a/src/main/jni/pdnsd/src/ipvers.h +++ b/src/main/jni/pdnsd/src/ipvers.h @@ -151,7 +151,9 @@ __cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg) __THROW /* This is the IPv6 flowid that we pass on to the IPv6 protocol stack. This value was not currently defined * at the time of writing. Should this change, define a appropriate flowinfo here. */ +#ifndef IPV6_FLOWINFO #define IPV6_FLOWINFO 0 +#endif /* There does not seem to be a function/macro to generate IPv6-mapped IPv4-Adresses. So here comes mine. * Pass an in_addr* and an in6_addr* */ diff --git a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala index e56a5fa809..1145525a4f 100644 --- a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala +++ b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala @@ -830,14 +830,6 @@ class Shadowsocks crash_recovery() - copyAssets(System.getABI) - - val ab = new ArrayBuffer[String] - for (executable <- Shadowsocks.EXECUTABLES) { - ab.append("chmod 755 " + Path.BASE + executable) - } - Console.runCommand(ab.toArray) - } private def recovery() { diff --git a/src/main/scala/com/github/shadowsocks/utils/Utils.scala b/src/main/scala/com/github/shadowsocks/utils/Utils.scala index 7c2b347484..fd62d047a3 100644 --- a/src/main/scala/com/github/shadowsocks/utils/Utils.scala +++ b/src/main/scala/com/github/shadowsocks/utils/Utils.scala @@ -68,8 +68,8 @@ object Utils { val DEFAULT_SHELL: String = "/system/bin/sh" val DEFAULT_ROOT: String = "/system/bin/su" val ALTERNATIVE_ROOT: String = "/system/xbin/su" - val DEFAULT_IPTABLES: String = "/data/data/com.github.shadowsocks/iptables" - val ALTERNATIVE_IPTABLES: String = "/system/bin/iptables" + val DEFAULT_IPTABLES: String = "/system/bin/iptables" + val ALTERNATIVE_IPTABLES: String = "/data/data/com.github.shadowsocks/iptables" val TIME_OUT: Int = -99 var initialized: Boolean = false var hasRedirectSupport: Int = -1