Compare commits

...
13 Commits
Author SHA1 Message Date
Mygod b8c593b110 Fix crash in GuardedProcess 2016-08-29 13:57:25 +08:00
Mygod 782af959a0 Fix #844 2016-08-29 12:54:55 +08:00
Max Lv 5b1432e4e8 Handle stdout/stderr of GuardedProcess properly 2016-08-28 17:42:19 +08:00
Max Lv 7ca4e4ec74 Enable android log for kcptun 2016-08-28 08:00:35 +08:00
Mygod 655ef1eed6 Refine TFO 2016-08-27 23:39:06 +08:00
Mygod 04be60577a Revert "Revert "Fix #839 #838""
This reverts commit 264b177b38.
2016-08-27 23:32:13 +08:00
Mygod 63d2ec7b02 Revert "Fix #838 #839"
This reverts commit 32f4d6af47.

Never mind then! I changed my mind.
2016-08-27 23:31:50 +08:00
Mygod 06b6afd557 Update sbt-android 2016-08-27 23:23:58 +08:00
Mygod 32f4d6af47 Fix #838 #839 2016-08-27 23:23:08 +08:00
Mygod 264b177b38 Revert "Fix #839 #838"
This reverts commit 069cc152ca.
2016-08-27 23:15:25 +08:00
Syrone Wong 67a1c5460a Drop redundant rule (#840)
[info] Android NDK: WARNING:jni/Android.mk:mbedtls: LOCAL_LDLIBS is always ignored for static libraries
2016-08-27 20:42:16 +08:00
Max Lv a20b7821f2 Bump version 2016-08-27 17:11:05 +08:00
Max Lv 069cc152ca Fix #839 #838 2016-08-27 17:10:12 +08:00
14 changed files with 48 additions and 44 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
addSbtPlugin("org.scala-android" % "sbt-android" % "1.6.13")
addSbtPlugin("org.scala-android" % "sbt-android" % "1.6.14")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.10")
+2 -2
View File
@@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" package="com.github.shadowsocks"
android:versionCode="148"
android:versionName="3.0.6">
android:versionCode="149"
android:versionName="3.0.7">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
-2
View File
@@ -559,8 +559,6 @@ MBEDTLS_SOURCES := $(wildcard $(LOCAL_PATH)/mbedtls/library/*.c)
LOCAL_SRC_FILES := $(MBEDTLS_SOURCES:$(LOCAL_PATH)/%=%)
LOCAL_LDLIBS := -ldl -llog
include $(BUILD_STATIC_LIBRARY)
# Import cpufeatures
-1
View File
@@ -112,7 +112,6 @@
<SwitchPreference
android:key="tcp_fastopen"
android:persistent="false"
android:summary="@string/tcp_fastopen_summary"
android:title="TCP Fast Open"/>
@@ -39,18 +39,35 @@
package com.github.shadowsocks
import java.io.{IOException, InputStream, OutputStream}
import java.io._
import java.lang.System.currentTimeMillis
import java.util.concurrent.Semaphore
import android.util.Log
import scala.collection.JavaConversions._
import scala.collection.immutable.Stream
import scala.util.control.Exception._
class StreamLogger(is: InputStream, tag: String) extends Thread {
def withCloseable[T <: Closeable, R](t: T)(f: T => R): R = {
allCatch.andFinally{t.close} apply { f(t) }
}
override def run() {
withCloseable(new BufferedReader(new InputStreamReader(is))) {
br => try Stream.continually(br.readLine()).takeWhile(_ != null).foreach(Log.i(tag, _)) catch {
case ignore: IOException =>
}
}
}
}
/**
* @author ayanamist@gmail.com
*/
class GuardedProcess(cmd: Seq[String]) extends Process {
class GuardedProcess(cmd: Seq[String]) {
private val TAG = classOf[GuardedProcess].getSimpleName
@volatile private var guardThread: Thread = _
@@ -72,6 +89,9 @@ class GuardedProcess(cmd: Seq[String]) extends Process {
process = new ProcessBuilder(cmd).redirectErrorStream(true).start
val is = process.getInputStream
new StreamLogger(is, TAG).start
if (callback == null) callback = onRestartCallback else callback()
semaphore.release
@@ -118,11 +138,6 @@ class GuardedProcess(cmd: Seq[String]) extends Process {
process.destroy()
}
def exitValue: Int = throw new UnsupportedOperationException
def getErrorStream: InputStream = throw new UnsupportedOperationException
def getInputStream: InputStream = throw new UnsupportedOperationException
def getOutputStream: OutputStream = throw new UnsupportedOperationException
@throws(classOf[InterruptedException])
def waitFor = {
guardThread.join()
@@ -46,7 +46,7 @@ import android.app.Application
import android.preference.PreferenceManager
import android.support.v7.app.AppCompatDelegate
import com.github.shadowsocks.database.{DBHelper, ProfileManager}
import com.github.shadowsocks.utils.{Key, Utils}
import com.github.shadowsocks.utils.{Key, Utils, TcpFastOpen}
import com.google.android.gms.analytics.{GoogleAnalytics, HitBuilders, StandardExceptionParser}
import com.google.android.gms.common.api.ResultCallback
import com.google.android.gms.tagmanager.{ContainerHolder, TagManager}
@@ -111,6 +111,8 @@ class ShadowsocksApplication extends Application {
}
}
pending.setResultCallback(callback, 2, TimeUnit.SECONDS)
TcpFastOpen.enabled(settings.getBoolean(Key.tfo, false))
}
def refreshContainerHolder {
@@ -40,7 +40,6 @@
package com.github.shadowsocks
import java.io.File
import java.lang.Process
import java.net.{Inet6Address, InetAddress}
import java.util.Locale
@@ -65,10 +64,10 @@ class ShadowsocksNatService extends BaseService {
private var notification: ShadowsocksNotification = _
val myUid = android.os.Process.myUid()
var sslocalProcess: Process = _
var sstunnelProcess: Process = _
var redsocksProcess: Process = _
var pdnsdProcess: Process = _
var sslocalProcess: GuardedProcess = _
var sstunnelProcess: GuardedProcess = _
var redsocksProcess: GuardedProcess = _
var pdnsdProcess: GuardedProcess = _
var su: Shell.Interactive = _
def startShadowsocksDaemon() {
@@ -68,7 +68,7 @@ class ShadowsocksQuickSwitchActivity extends AppCompatActivity {
profilesList.setItemAnimator(new DefaultItemAnimator)
profilesList.setAdapter(profilesAdapter)
if (app.profileId >= 0) lm.scrollToPosition(profilesAdapter.profiles.zipWithIndex.collectFirst {
case (profile, i) if profile.id == app.profileId => i + 1
case (profile, i) if profile.id == app.profileId => i
}.getOrElse(0))
}
}
@@ -155,7 +155,7 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
}
switch.setChecked(BootReceiver.getEnabled(activity))
val tfo = findPreference("tcp_fastopen").asInstanceOf[SwitchPreference]
val tfo = findPreference(Key.tfo).asInstanceOf[SwitchPreference]
tfo.setChecked(TcpFastOpen.sendEnabled)
tfo.setOnPreferenceChangeListener((_, v) => {
val value = v.asInstanceOf[Boolean]
@@ -40,7 +40,6 @@
package com.github.shadowsocks
import java.io.File
import java.lang.Process
import java.util.Locale
import android.content._
@@ -63,10 +62,10 @@ class ShadowsocksVpnService extends VpnService with BaseService {
var vpnThread: ShadowsocksVpnThread = _
private var notification: ShadowsocksNotification = _
var sslocalProcess: Process = _
var sstunnelProcess: Process = _
var pdnsdProcess: Process = _
var tun2socksProcess: Process = _
var sslocalProcess: GuardedProcess = _
var sstunnelProcess: GuardedProcess = _
var pdnsdProcess: GuardedProcess = _
var tun2socksProcess: GuardedProcess = _
override def onBind(intent: Intent): IBinder = {
val action = intent.getAction
@@ -171,6 +171,8 @@ object Key {
val kcp = "kcp"
val kcpPort = "kcpPort"
val kcpcli = "kcpcli"
val tfo = "tcp_fastopen"
}
object State {
@@ -28,23 +28,13 @@ object TcpFastOpen {
file.canRead && (Utils.readAllLines(file).toInt & 1) > 0
}
def enabled(value: Boolean) =
Shell.run("su", Array(
def enabled(value: Boolean): String = if (sendEnabled != value) {
val res = Shell.run("su", Array(
"if echo " + (if (value) 3 else 0) + " > /proc/sys/net/ipv4/tcp_fastopen; then",
" success=-1",
" if mount -o rw,remount /dev/block/platform/msm_sdcc.1/by-name/system /system; then",
if (value) " echo '#!/system/bin/sh\n" +
"echo 3 > /proc/sys/net/ipv4/tcp_fastopen' > /etc/init.d/tcp_fastopen && chmod 755 /etc/init.d/tcp_fastopen"
else "rm -f /etc/init.d/tcp_fastopen",
" success=$?",
" mount -o ro,remount /dev/block/platform/msm_sdcc.1/by-name/system /system",
" fi",
" if [ $success -eq 0 ]; then",
" echo Success.",
" else",
" echo Warning: Unable to create boot script.",
" fi",
" echo Success.",
"else",
" echo Failed.",
"fi"), null, true).asScala.mkString("\n")
"fi"), null, true)
if (res != null) res.asScala.mkString("\n") else null
} else null
}