Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08d5d56e46 | ||
|
|
e22b145023 | ||
|
|
a10889bb5b | ||
|
|
800e85dc0d | ||
|
|
e778a313ba |
@@ -1,14 +1,12 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.github.shadowsocks"
|
package="com.github.shadowsocks"
|
||||||
android:versionCode="81"
|
android:versionCode="84"
|
||||||
android:versionName="2.4.1">
|
android:versionName="2.4.4">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||||
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
|
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
|
||||||
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
|
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.hardware.touchscreen"
|
android:name="android.hardware.touchscreen"
|
||||||
|
|||||||
@@ -70,6 +70,61 @@
|
|||||||
|
|
||||||
#include <generated/blog_channel_tun2socks.h>
|
#include <generated/blog_channel_tun2socks.h>
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
#include <structure/BAVL.h>
|
||||||
|
BAVL connections_tree;
|
||||||
|
typedef struct {
|
||||||
|
BAddr local_addr;
|
||||||
|
BAddr remote_addr;
|
||||||
|
uint16_t port;
|
||||||
|
int count;
|
||||||
|
BAVLNode connections_tree_node;
|
||||||
|
} Connection;
|
||||||
|
|
||||||
|
static int conaddr_comparator (void *unused, uint16_t *v1, uint16_t *v2)
|
||||||
|
{
|
||||||
|
if (*v1 == *v2) return 0;
|
||||||
|
else if (*v1 > *v2) return 1;
|
||||||
|
else return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Connection * find_connection (uint16_t port)
|
||||||
|
{
|
||||||
|
BAVLNode *tree_node = BAVL_LookupExact(&connections_tree, &port);
|
||||||
|
if (!tree_node) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return UPPER_OBJECT(tree_node, Connection, connections_tree_node);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void remove_connection (Connection *con)
|
||||||
|
{
|
||||||
|
con->count -= 1;
|
||||||
|
if (con->count <= 0)
|
||||||
|
{
|
||||||
|
BAVL_Remove(&connections_tree, &con->connections_tree_node);
|
||||||
|
free(con);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void insert_connection (BAddr local_addr, BAddr remote_addr, uint16_t port)
|
||||||
|
{
|
||||||
|
Connection * con = find_connection(port);
|
||||||
|
if (con != NULL)
|
||||||
|
con->count += 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Connection * tmp = (Connection *)malloc(sizeof(Connection));
|
||||||
|
tmp->local_addr = local_addr;
|
||||||
|
tmp->remote_addr = remote_addr;
|
||||||
|
tmp->port = port;
|
||||||
|
tmp->count = 1;
|
||||||
|
BAVL_Insert(&connections_tree, &tmp->connections_tree_node, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LOGGER_STDOUT 1
|
#define LOGGER_STDOUT 1
|
||||||
#define LOGGER_SYSLOG 2
|
#define LOGGER_SYSLOG 2
|
||||||
|
|
||||||
@@ -1199,8 +1254,6 @@ int process_device_dns_packet (uint8_t *data, int data_len)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BAddr local_addr;
|
|
||||||
static BAddr remote_addr;
|
|
||||||
static int init = 0;
|
static int init = 0;
|
||||||
|
|
||||||
int to_dns;
|
int to_dns;
|
||||||
@@ -1257,9 +1310,13 @@ int process_device_dns_packet (uint8_t *data, int data_len)
|
|||||||
// construct addresses
|
// construct addresses
|
||||||
if (!init) {
|
if (!init) {
|
||||||
init = 1;
|
init = 1;
|
||||||
BAddr_InitIPv4(&local_addr, ipv4_header.source_address, udp_header.source_port);
|
BAVL_Init(&connections_tree, OFFSET_DIFF(Connection, port, connections_tree_node), (BAVL_comparator)conaddr_comparator, NULL);
|
||||||
BAddr_InitIPv4(&remote_addr, ipv4_header.destination_address, udp_header.dest_port);
|
|
||||||
}
|
}
|
||||||
|
BAddr local_addr;
|
||||||
|
BAddr remote_addr;
|
||||||
|
BAddr_InitIPv4(&local_addr, ipv4_header.source_address, udp_header.source_port);
|
||||||
|
BAddr_InitIPv4(&remote_addr, ipv4_header.destination_address, udp_header.dest_port);
|
||||||
|
insert_connection(local_addr, remote_addr, udp_header.source_port);
|
||||||
|
|
||||||
// build IP header
|
// build IP header
|
||||||
ipv4_header.destination_address = dnsgw.ipv4.ip;
|
ipv4_header.destination_address = dnsgw.ipv4.ip;
|
||||||
@@ -1277,13 +1334,23 @@ int process_device_dns_packet (uint8_t *data, int data_len)
|
|||||||
|
|
||||||
BLog(BLOG_INFO, "UDP: from DNS %d bytes", data_len);
|
BLog(BLOG_INFO, "UDP: from DNS %d bytes", data_len);
|
||||||
|
|
||||||
// build IP header
|
Connection * con = find_connection(udp_header.dest_port);
|
||||||
ipv4_header.source_address = remote_addr.ipv4.ip;
|
if (con != NULL)
|
||||||
ipv4_header.destination_address = local_addr.ipv4.ip;
|
{
|
||||||
|
// build IP header
|
||||||
|
ipv4_header.source_address = con->remote_addr.ipv4.ip;
|
||||||
|
ipv4_header.destination_address = con->local_addr.ipv4.ip;
|
||||||
|
|
||||||
// build UDP header
|
// build UDP header
|
||||||
udp_header.source_port = remote_addr.ipv4.port;
|
udp_header.source_port = con->remote_addr.ipv4.port;
|
||||||
|
|
||||||
|
remove_connection(con);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update IPv4 header's checksum
|
// update IPv4 header's checksum
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ LOCAL_CFLAGS += -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_SCTP \
|
|||||||
# LOCAL_CFLAGS += -DOPENSSL_NO_DEPRECATED
|
# LOCAL_CFLAGS += -DOPENSSL_NO_DEPRECATED
|
||||||
|
|
||||||
# Extra
|
# Extra
|
||||||
LOCAL_CFLAGS += -DOPENSSL_NO_HW -DOPENSSL_NO_ASM -DOPENSSL_NO_ENGINE -DZLIB
|
LOCAL_CFLAGS += -DOPENSSL_NO_HW -DOPENSSL_NO_ENGINE -DZLIB
|
||||||
|
|
||||||
# Debug
|
# Debug
|
||||||
# LOCAL_CFLAGS += -DCIPHER_DEBUG
|
# LOCAL_CFLAGS += -DCIPHER_DEBUG
|
||||||
|
|||||||
@@ -100,8 +100,8 @@ static int rc4_hmac_md5_init_key(EVP_CIPHER_CTX *ctx,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disable asm for Android x86_64
|
||||||
#if !defined(OPENSSL_NO_ASM) && ( \
|
#if !defined(OPENSSL_NO_ASM) && ( \
|
||||||
defined(__x86_64) || defined(__x86_64__) || \
|
|
||||||
defined(_M_AMD64) || defined(_M_X64) || \
|
defined(_M_AMD64) || defined(_M_X64) || \
|
||||||
defined(__INTEL__) ) && \
|
defined(__INTEL__) ) && \
|
||||||
!(defined(__APPLE__) && defined(__MACH__))
|
!(defined(__APPLE__) && defined(__MACH__))
|
||||||
|
|||||||
+1
-1
Submodule src/main/jni/shadowsocks updated: bf902a573a...e9f2369486
@@ -6,13 +6,18 @@
|
|||||||
<!-- Enable automatic Activity measurement -->
|
<!-- Enable automatic Activity measurement -->
|
||||||
<bool name="ga_autoActivityTracking">true</bool>
|
<bool name="ga_autoActivityTracking">true</bool>
|
||||||
|
|
||||||
|
<!-- Enable exception reports -->
|
||||||
|
<bool name="ga_reportUncaughtExceptions">true</bool>
|
||||||
|
|
||||||
<!-- The screen names that will appear in reports -->
|
<!-- The screen names that will appear in reports -->
|
||||||
<screenName name="com.google.android.gms.analytics.samples.mobileplayground.ScreenviewFragment">
|
<screenName name="com.google.android.gms.analytics.samples.mobileplayground.ScreenviewFragment">
|
||||||
Shadowsocks ScreenView
|
Shadowsocks ScreenView
|
||||||
</screenName>
|
</screenName>
|
||||||
|
|
||||||
<screenName name="com.google.android.gms.analytics.samples.mobileplayground.EcommerceFragment">
|
<screenName name="com.google.android.gms.analytics.samples.mobileplayground.EcommerceFragment">
|
||||||
Shadowsocks EcommerceView
|
Shadowsocks EcommerceView
|
||||||
</screenName>
|
</screenName>
|
||||||
|
|
||||||
<!-- The following value should be replaced with correct property id. -->
|
<!-- The following value should be replaced with correct property id. -->
|
||||||
<string name="ga_trackingId">UA-37082941-1</string>
|
<string name="ga_trackingId">UA-37082941-1</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -128,11 +128,6 @@ object Shadowsocks {
|
|||||||
// Helper functions
|
// Helper functions
|
||||||
def updateListPreference(pref: Preference, value: String) {
|
def updateListPreference(pref: Preference, value: String) {
|
||||||
pref.asInstanceOf[ListPreference].setValue(value)
|
pref.asInstanceOf[ListPreference].setValue(value)
|
||||||
val entry = pref.asInstanceOf[ListPreference].getEntry
|
|
||||||
if (entry != null)
|
|
||||||
pref.setSummary(entry)
|
|
||||||
else
|
|
||||||
pref.setSummary(value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def updatePasswordEditTextPreference(pref: Preference, value: String) {
|
def updatePasswordEditTextPreference(pref: Preference, value: String) {
|
||||||
@@ -329,10 +324,12 @@ class Shadowsocks
|
|||||||
private def crash_recovery() {
|
private def crash_recovery() {
|
||||||
val ab = new ArrayBuffer[String]
|
val ab = new ArrayBuffer[String]
|
||||||
|
|
||||||
ab.append("kill -9 `cat /data/data/com.github.shadowsocks/pdnsd.pid`")
|
|
||||||
ab.append("kill -9 `cat /data/data/com.github.shadowsocks/ss-local.pid`")
|
ab.append("kill -9 `cat /data/data/com.github.shadowsocks/ss-local.pid`")
|
||||||
ab.append("kill -9 `cat /data/data/com.github.shadowsocks/ss-tunnel.pid`")
|
ab.append("kill -9 `cat /data/data/com.github.shadowsocks/ss-tunnel.pid`")
|
||||||
ab.append("kill -9 `cat /data/data/com.github.shadowsocks/tun2socks.pid`")
|
ab.append("kill -9 `cat /data/data/com.github.shadowsocks/tun2socks.pid`")
|
||||||
|
|
||||||
|
ab.append("kill -9 `cat /data/data/com.github.shadowsocks/pdnsd.pid`")
|
||||||
|
ab.append("rm /data/data/com.github.shadowsocks/pdnsd.pid")
|
||||||
ab.append("rm /data/data/com.github.shadowsocks/pdnsd.conf")
|
ab.append("rm /data/data/com.github.shadowsocks/pdnsd.conf")
|
||||||
ab.append("rm /data/data/com.github.shadowsocks/pdnsd.cache")
|
ab.append("rm /data/data/com.github.shadowsocks/pdnsd.cache")
|
||||||
|
|
||||||
@@ -340,9 +337,16 @@ class Shadowsocks
|
|||||||
|
|
||||||
if (!Utils.isLollipopOrAbove) {
|
if (!Utils.isLollipopOrAbove) {
|
||||||
ab.clear()
|
ab.clear()
|
||||||
|
|
||||||
ab.append("kill -9 `cat /data/data/com.github.shadowsocks/redsocks.pid`")
|
ab.append("kill -9 `cat /data/data/com.github.shadowsocks/redsocks.pid`")
|
||||||
ab.append("rm /data/data/com.github.shadowsocks/redsocks.conf")
|
ab.append("rm /data/data/com.github.shadowsocks/redsocks.conf")
|
||||||
ab.append("rm /data/data/com.github.shadowsocks/redsocks.pid")
|
ab.append("rm /data/data/com.github.shadowsocks/redsocks.pid")
|
||||||
|
|
||||||
|
ab.append("kill -9 `cat /data/data/com.github.shadowsocks/pdnsd.pid`")
|
||||||
|
ab.append("rm /data/data/com.github.shadowsocks/pdnsd.pid")
|
||||||
|
ab.append("rm /data/data/com.github.shadowsocks/pdnsd.conf")
|
||||||
|
ab.append("rm /data/data/com.github.shadowsocks/pdnsd.cache")
|
||||||
|
|
||||||
ab.append(Utils.getIptables + " -t nat -F OUTPUT")
|
ab.append(Utils.getIptables + " -t nat -F OUTPUT")
|
||||||
|
|
||||||
Console.runRootCommand(ab.toArray)
|
Console.runRootCommand(ab.toArray)
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class SummaryListPreference(context: Context, attrs: AttributeSet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
override def setSummary(summary: CharSequence) {
|
override def setSummary(summary: CharSequence) {
|
||||||
if (summary.toString.isEmpty) {
|
if (summary == null || summary.toString.isEmpty) {
|
||||||
super.setSummary("")
|
super.setSummary("")
|
||||||
} else {
|
} else {
|
||||||
super.setSummary(summary)
|
super.setSummary(summary)
|
||||||
|
|||||||
Reference in New Issue
Block a user