Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8c593b110 | ||
|
|
782af959a0 | ||
|
|
5b1432e4e8 | ||
|
|
7ca4e4ec74 | ||
|
|
655ef1eed6 | ||
|
|
04be60577a | ||
|
|
63d2ec7b02 | ||
|
|
06b6afd557 | ||
|
|
32f4d6af47 | ||
|
|
264b177b38 | ||
|
|
67a1c5460a | ||
|
|
a20b7821f2 | ||
|
|
069cc152ca |
+1
-1
Submodule kcptun/kcptun updated: 69c4702115...c4054b07a6
+1
-1
@@ -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")
|
||||
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
@@ -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
-1
Submodule src/main/jni/pdnsd updated: b51fd4f65c...7a76962795
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user