Commit ea848f3b authored by Mygod's avatar Mygod

Merge branch 'master' into develop

parents 53af99eb 93274ffb
...@@ -29,7 +29,8 @@ _Put an `x` inside the [ ] that applies._ ...@@ -29,7 +29,8 @@ _Put an `x` inside the [ ] that applies._
* [ ] IPv6 route * [ ] IPv6 route
* [ ] Per-App Proxy * [ ] Per-App Proxy
* [ ] Bypass mode * [ ] Bypass mode
* [ ] UDP Forwarding * Remote DNS: 8.8.8.8
* [ ] DNS Forwarding
* Plugin configuration (if applicable): * Plugin configuration (if applicable):
* [ ] Auto Connect * [ ] Auto Connect
* [ ] TCP Fast Open * [ ] TCP Fast Open
......
...@@ -10,3 +10,15 @@ local.sbt ...@@ -10,3 +10,15 @@ local.sbt
mobile/src/main/libs mobile/src/main/libs
mobile/src/main/obj mobile/src/main/obj
mobile/src/main/jni/overture mobile/src/main/jni/overture
mobile/src/overture/.deps
mobile/src/overture/bin
mobile/src/overture/pkg
mobile/src/overture/src/github.com/Sirupsen
mobile/src/overture/src/github.com/mattn
mobile/src/overture/src/github.com/miekg
mobile/src/overture/src/github.com/shawn1m
mobile/src/overture/src/github.com/tools
mobile/src/overture/src/golang.org
mobile/src/overture/src/gopkg.in
...@@ -33,6 +33,9 @@ ...@@ -33,6 +33,9 @@
[submodule "mobile/src/main/jni/libudns"] [submodule "mobile/src/main/jni/libudns"]
path = mobile/src/main/jni/libudns path = mobile/src/main/jni/libudns
url = https://github.com/shadowsocks/libudns.git url = https://github.com/shadowsocks/libudns.git
[submodule "mobile/src/overture"] [submodule "mobile/src/overture/go"]
path = mobile/src/overture path = mobile/src/overture/go
url = https://github.com/shadowsocks/overture-android.git url = https://github.com/shadowsocks/go.git
[submodule "mobile/src/overture/src/github.com/shadowsocks/overture"]
path = mobile/src/overture/src/github.com/shadowsocks/overture
url = https://github.com/shadowsocks/overture.git
-XX:MaxPermSize=512m
-Xms1g -Xms1g
-Xmx3g -Xmx3g
-Xss2m -Xss2m
......
lazy val commonSettings = Seq( lazy val commonSettings = Seq(
scalaVersion := "2.11.8", scalaVersion := "2.11.9",
dexMaxHeap := "4g", dexMaxHeap := "4g",
organization := "com.github.shadowsocks", organization := "com.github.shadowsocks",
...@@ -11,7 +11,7 @@ lazy val commonSettings = Seq( ...@@ -11,7 +11,7 @@ lazy val commonSettings = Seq(
scalacOptions ++= "-target:jvm-1.7" :: "-Xexperimental" :: Nil, scalacOptions ++= "-target:jvm-1.7" :: "-Xexperimental" :: Nil,
ndkArgs := "-j" :: java.lang.Runtime.getRuntime.availableProcessors.toString :: Nil, ndkArgs := "-j" :: java.lang.Runtime.getRuntime.availableProcessors.toString :: Nil,
proguardVersion := "5.3.2", proguardVersion := "5.3.3",
proguardCache := Seq(), proguardCache := Seq(),
shrinkResources := true, shrinkResources := true,
......
...@@ -2,8 +2,8 @@ enablePlugins(AndroidApp) ...@@ -2,8 +2,8 @@ enablePlugins(AndroidApp)
android.useSupportVectors android.useSupportVectors
name := "shadowsocks" name := "shadowsocks"
version := "4.1.3" version := "4.1.4"
versionCode := Some(183) versionCode := Some(184)
proguardOptions ++= proguardOptions ++=
"-keep class com.github.shadowsocks.JniHelper { *; }" :: "-keep class com.github.shadowsocks.JniHelper { *; }" ::
...@@ -13,29 +13,29 @@ proguardOptions ++= ...@@ -13,29 +13,29 @@ proguardOptions ++=
"-dontwarn org.xbill.**" :: "-dontwarn org.xbill.**" ::
Nil Nil
val playServicesVersion = "10.2.0" val playServicesVersion = "10.2.1"
resolvers += Resolver.jcenterRepo resolvers += Resolver.jcenterRepo
libraryDependencies ++= libraryDependencies ++=
"com.futuremind.recyclerfastscroll" % "fastscroll" % "0.2.5" :: "com.futuremind.recyclerfastscroll" % "fastscroll" % "0.2.5" ::
"com.evernote" % "android-job" % "1.1.7" :: "com.evernote" % "android-job" % "1.1.9" ::
"com.github.jorgecastilloprz" % "fabprogresscircle" % "1.01" :: "com.github.jorgecastilloprz" % "fabprogresscircle" % "1.01" ::
"com.google.android.gms" % "play-services-ads" % playServicesVersion :: "com.google.android.gms" % "play-services-ads" % playServicesVersion ::
"com.google.android.gms" % "play-services-analytics" % playServicesVersion :: "com.google.android.gms" % "play-services-analytics" % playServicesVersion ::
"com.google.android.gms" % "play-services-gcm" % playServicesVersion :: "com.google.android.gms" % "play-services-gcm" % playServicesVersion ::
"com.j256.ormlite" % "ormlite-android" % "5.0" :: "com.j256.ormlite" % "ormlite-android" % "5.0" ::
"com.mikepenz" % "crossfader" % "1.5.0" :: "com.mikepenz" % "crossfader" % "1.5.0" ::
"com.mikepenz" % "fastadapter" % "2.1.7" :: "com.mikepenz" % "fastadapter" % "2.5.0" ::
"com.mikepenz" % "iconics-core" % "2.8.2" :: "com.mikepenz" % "iconics-core" % "2.8.2" ::
"com.mikepenz" % "materialdrawer" % "5.8.2" :: "com.mikepenz" % "materialdrawer" % "5.9.0" ::
"com.mikepenz" % "materialize" % "1.0.1" :: "com.mikepenz" % "materialize" % "1.0.1" ::
"com.squareup.okhttp3" % "okhttp" % "3.6.0" :: "com.squareup.okhttp3" % "okhttp" % "3.6.0" ::
"com.twofortyfouram" % "android-plugin-api-for-locale" % "1.0.2" :: "com.twofortyfouram" % "android-plugin-api-for-locale" % "1.0.2" ::
"dnsjava" % "dnsjava" % "2.1.8" :: "dnsjava" % "dnsjava" % "2.1.8" ::
"eu.chainfire" % "libsuperuser" % "1.0.0.201608240809" :: "eu.chainfire" % "libsuperuser" % "1.0.0.201704021214" ::
"net.glxn.qrgen" % "android" % "2.0" :: "net.glxn.qrgen" % "android" % "2.0" ::
Nil Nil
lazy val goBuild = TaskKey[Unit]("go-build", "Build go and kcptun") lazy val goBuild = TaskKey[Unit]("go-build", "Build go and overture")
goBuild := { goBuild := {
Process(Seq("mobile/src/overture/make.bash", minSdkVersion.value)) ! streams.value.log match { Process(Seq("mobile/src/overture/make.bash", minSdkVersion.value)) ! streams.value.log match {
case 0 => // Success! case 0 => // Success!
......
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
<string name="app_name">Shadowsocks</string> <string name="app_name">Shadowsocks</string>
<string name="quick_toggle">Toggle</string> <string name="quick_toggle">Toggle</string>
<!-- global/misc category --> <!-- misc -->
<string name="misc_cat">Misc</string>
<string name="profile">Profile</string> <string name="profile">Profile</string>
<string name="profile_summary">Switch to another profile or add new profiles</string> <string name="profile_summary">Switch to another profile or add new profiles</string>
<string name="nat">NAT mode (deprecated)</string> <string name="nat">NAT mode (deprecated)</string>
...@@ -54,7 +53,7 @@ ...@@ -54,7 +53,7 @@
<string name="tcp_fastopen_summary">Toggling requires ROOT permission</string> <string name="tcp_fastopen_summary">Toggling requires ROOT permission</string>
<string name="tcp_fastopen_summary_unsupported">Unsupported kernel version: %s &lt; 3.7.1</string> <string name="tcp_fastopen_summary_unsupported">Unsupported kernel version: %s &lt; 3.7.1</string>
<string name="udp_dns">DNS Forwarding</string> <string name="udp_dns">DNS Forwarding</string>
<string name="udp_dns_summary">Force to forward DNS packets to remote</string> <string name="udp_dns_summary">Forward all DNS requests to remote</string>
<!-- notification category --> <!-- notification category -->
<string name="forward_success">Shadowsocks started.</string> <string name="forward_success">Shadowsocks started.</string>
......
...@@ -25,6 +25,8 @@ import java.net.InetAddress ...@@ -25,6 +25,8 @@ import java.net.InetAddress
import java.util import java.util
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import java.util.{Timer, TimerTask} import java.util.{Timer, TimerTask}
import java.net.InetAddress
import java.net.Inet6Address
import android.app.Service import android.app.Service
import android.content.{BroadcastReceiver, Context, Intent, IntentFilter} import android.content.{BroadcastReceiver, Context, Intent, IntentFilter}
...@@ -124,6 +126,7 @@ trait BaseService extends Service { ...@@ -124,6 +126,7 @@ trait BaseService extends Service {
} else true } else true
def connect() { def connect() {
profile.name = profile.getName // save original name before it's (possibly) overwritten by IP addresses
if (profile.host == "198.199.101.152") { if (profile.host == "198.199.101.152") {
val holder = app.containerHolder val holder = app.containerHolder
val container = holder.getContainer val container = holder.getContainer
...@@ -329,6 +332,13 @@ trait BaseService extends Service { ...@@ -329,6 +332,13 @@ trait BaseService extends Service {
file file
} }
private final def buildRemoteDns(remoteDns: String): String = {
val addr = InetAddress.getByName(remoteDns)
if (addr.isInstanceOf[Inet6Address])
return "[" + remoteDns + "]"
remoteDns
}
protected final def buildOvertureConfig(file: String): String = { protected final def buildOvertureConfig(file: String): String = {
val config = new JSONObject() val config = new JSONObject()
.put("BindAddress", ":" + (profile.localPort + 53)) .put("BindAddress", ":" + (profile.localPort + 53))
...@@ -355,14 +365,17 @@ trait BaseService extends Service { ...@@ -355,14 +365,17 @@ trait BaseService extends Service {
makeDns("Primary-1", "119.29.29.29", edns = false), makeDns("Primary-1", "119.29.29.29", edns = false),
makeDns("Primary-2", "114.114.114.114", edns = false) makeDns("Primary-2", "114.114.114.114", edns = false)
))) )))
.put("AlternativeDNS", new JSONArray().put(makeDns("Alternative", profile.remoteDns))) .put("AlternativeDNS", new JSONArray().put(makeDns("Alternative",
buildRemoteDns(profile.remoteDns.trim))))
.put("IPNetworkFile", "china_ip_list.txt") .put("IPNetworkFile", "china_ip_list.txt")
.put("DomainFile", "gfwlist.txt") .put("DomainFile", "gfwlist.txt")
case Acl.CHINALIST => config case Acl.CHINALIST => config
.put("PrimaryDNS", new JSONArray().put(makeDns("Primary", "119.29.29.29"))) .put("PrimaryDNS", new JSONArray().put(makeDns("Primary", "119.29.29.29")))
.put("AlternativeDNS", new JSONArray().put(makeDns("Alternative", profile.remoteDns))) .put("AlternativeDNS", new JSONArray().put(makeDns("Alternative",
buildRemoteDns(profile.remoteDns.trim))))
case _ => config case _ => config
.put("PrimaryDNS", new JSONArray().put(makeDns("Primary", profile.remoteDns))) .put("PrimaryDNS", new JSONArray().put(makeDns("Primary",
buildRemoteDns(profile.remoteDns.trim))))
.put("AlternativeDNS", new JSONArray().put(makeDns("Alternative", "208.67.222.222"))) .put("AlternativeDNS", new JSONArray().put(makeDns("Alternative", "208.67.222.222")))
} }
IOUtils.writeString(new File(getFilesDir, file), config.toString) IOUtils.writeString(new File(getFilesDir, file), config.toString)
......
...@@ -352,15 +352,21 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic ...@@ -352,15 +352,21 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
def onMenuItemClick(item: MenuItem): Boolean = item.getItemId match { def onMenuItemClick(item: MenuItem): Boolean = item.getItemId match {
case R.id.action_scan_qr_code => case R.id.action_scan_qr_code =>
def installScanner() = {
Toast.makeText(getActivity, R.string.add_profile_scanner_not_installed, Toast.LENGTH_LONG).show()
try startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=tw.com.quickmark"))) catch {
case exc: ActivityNotFoundException => exc.printStackTrace()
}
}
try startActivityForResult(new Intent("com.google.zxing.client.android.SCAN") try startActivityForResult(new Intent("com.google.zxing.client.android.SCAN")
.addCategory(Intent.CATEGORY_DEFAULT) .addCategory(Intent.CATEGORY_DEFAULT)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_DOCUMENT), .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_DOCUMENT),
REQUEST_SCAN_QR_CODE) catch { REQUEST_SCAN_QR_CODE) catch {
case _: ActivityNotFoundException => case _: ActivityNotFoundException => installScanner()
Toast.makeText(getActivity, R.string.add_profile_scanner_not_installed, Toast.LENGTH_LONG).show() case e: SecurityException =>
try startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=tw.com.quickmark"))) catch { e.printStackTrace()
case exc: ActivityNotFoundException => exc.printStackTrace() app.track(e)
} installScanner()
} }
true true
case R.id.action_import => case R.id.action_import =>
......
...@@ -204,7 +204,7 @@ class ShadowsocksNatService extends BaseService { ...@@ -204,7 +204,7 @@ class ShadowsocksNatService extends BaseService {
AclSyncJob.schedule(profile.route) AclSyncJob.schedule(profile.route)
changeState(State.CONNECTED) changeState(State.CONNECTED)
notification = new ShadowsocksNotification(this, profile.getName, true) notification = new ShadowsocksNotification(this, profile.name, true)
} }
override def stopRunner(stopService: Boolean, msg: String = null) { override def stopRunner(stopService: Boolean, msg: String = null) {
......
...@@ -22,6 +22,8 @@ package com.github.shadowsocks ...@@ -22,6 +22,8 @@ package com.github.shadowsocks
import java.io.File import java.io.File
import java.util.Locale import java.util.Locale
import java.net.InetAddress
import java.net.Inet6Address
import android.content._ import android.content._
import android.content.pm.PackageManager.NameNotFoundException import android.content.pm.PackageManager.NameNotFoundException
...@@ -138,7 +140,7 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -138,7 +140,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
if (profile.route != Acl.ALL && profile.route != Acl.CUSTOM_RULES) if (profile.route != Acl.ALL && profile.route != Acl.CUSTOM_RULES)
AclSyncJob.schedule(profile.route) AclSyncJob.schedule(profile.route)
notification = new ShadowsocksNotification(this, profile.getName) notification = new ShadowsocksNotification(this, profile.name)
} }
/** Called when the activity is first created. */ /** Called when the activity is first created. */
...@@ -189,7 +191,7 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -189,7 +191,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
.setMtu(VPN_MTU) .setMtu(VPN_MTU)
.addAddress(PRIVATE_VLAN.formatLocal(Locale.ENGLISH, "1"), 24) .addAddress(PRIVATE_VLAN.formatLocal(Locale.ENGLISH, "1"), 24)
builder.addDnsServer(profile.remoteDns.trim) builder.addDnsServer("8.8.8.8") // It's fake DNS for tun2socks, not the real remote DNS
if (profile.ipv6) { if (profile.ipv6) {
builder.addAddress(PRIVATE_VLAN6.formatLocal(Locale.ENGLISH, "1"), 126) builder.addAddress(PRIVATE_VLAN6.formatLocal(Locale.ENGLISH, "1"), 126)
...@@ -221,7 +223,11 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -221,7 +223,11 @@ class ShadowsocksVpnService extends VpnService with BaseService {
val subnet = Subnet.fromString(cidr) val subnet = Subnet.fromString(cidr)
builder.addRoute(subnet.address.getHostAddress, subnet.prefixSize) builder.addRoute(subnet.address.getHostAddress, subnet.prefixSize)
}) })
builder.addRoute(profile.remoteDns.trim, 32) val addr = InetAddress.getByName(profile.remoteDns.trim)
if (addr.isInstanceOf[Inet6Address])
builder.addRoute(addr, 128)
else if (addr.isInstanceOf[InetAddress])
builder.addRoute(addr, 32)
} }
conn = builder.establish() conn = builder.establish()
......
Subproject commit 862ce347e19483fdd6f0a5c84f173c2efdc7d920
Subproject commit 86036dcce8fc7e2bd772969e6af56776cc9d8d53
#!/bin/bash
function try () {
"$@" || exit -1
}
[ -z "$ANDROID_NDK_HOME" ] && ANDROID_NDK_HOME=~/android-ndk-r12b
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
MIN_API=$1
TARGET=$DIR/../main/jni/overture
DEPS=$DIR/.deps
ANDROID_ARM_TOOLCHAIN=$DEPS/android-toolchain-${MIN_API}-arm
ANDROID_ARM64_TOOLCHAIN=$DEPS/android-toolchain-21-arm64
ANDROID_X86_TOOLCHAIN=$DEPS/android-toolchain-${MIN_API}-x86
ANDROID_ARM_CC=$ANDROID_ARM_TOOLCHAIN/bin/arm-linux-androideabi-gcc
ANDROID_ARM_STRIP=$ANDROID_ARM_TOOLCHAIN/bin/arm-linux-androideabi-strip
ANDROID_ARM64_CC=$ANDROID_ARM64_TOOLCHAIN/bin/aarch64-linux-android-gcc
ANDROID_ARM64_STRIP=$ANDROID_ARM64_TOOLCHAIN/bin/aarch64-linux-android-strip
ANDROID_X86_CC=$ANDROID_X86_TOOLCHAIN/bin/i686-linux-android-gcc
ANDROID_X86_STRIP=$ANDROID_X86_TOOLCHAIN/bin/i686-linux-android-strip
try mkdir -p $DEPS $TARGET/armeabi-v7a $TARGET/x86 $TARGET/arm64-v8a
if [ ! -d "$ANDROID_ARM_TOOLCHAIN" ]; then
echo "Make standalone toolchain for ARM arch"
$ANDROID_NDK_HOME/build/tools/make_standalone_toolchain.py --arch arm \
--api $MIN_API --install-dir $ANDROID_ARM_TOOLCHAIN
fi
if [ ! -d "$ANDROID_ARM64_TOOLCHAIN" ]; then
echo "Make standalone toolchain for ARM64 arch"
$ANDROID_NDK_HOME/build/tools/make_standalone_toolchain.py --arch arm64 \
--api 21 --install-dir $ANDROID_ARM64_TOOLCHAIN
fi
if [ ! -d "$ANDROID_X86_TOOLCHAIN" ]; then
echo "Make standalone toolchain for X86 arch"
$ANDROID_NDK_HOME/build/tools/make_standalone_toolchain.py --arch x86 \
--api $MIN_API --install-dir $ANDROID_X86_TOOLCHAIN
fi
if [ ! -d "$DIR/go/bin" ]; then
echo "Build the custom go"
pushd $DIR/go/src
try ./make.bash
popd
fi
export GOROOT=$DIR/go
export GOPATH=$DIR
export PATH=$GOROOT/bin:$GOPATH/bin:$PATH
echo "Get dependences for overture"
go get -u github.com/tools/godep
pushd $GOPATH/src/github.com/shadowsocks/overture/main
godep restore
echo "Cross compile overture for arm"
try env CGO_ENABLED=1 CC=$ANDROID_ARM_CC GOOS=android GOARCH=arm GOARM=7 go build -ldflags="-s -w"
try $ANDROID_ARM_STRIP main
try mv main $TARGET/armeabi-v7a/liboverture.so
echo "Cross compile overture for arm64"
try env CGO_ENABLED=1 CC=$ANDROID_ARM64_CC GOOS=android GOARCH=arm64 go build -ldflags="-s -w"
try $ANDROID_ARM64_STRIP main
try mv main $TARGET/arm64-v8a/liboverture.so
echo "Cross compile overture for x86"
try env CGO_ENABLED=1 CC=$ANDROID_X86_CC GOOS=android GOARCH=386 go build -ldflags="-s -w"
try $ANDROID_X86_STRIP main
try mv main $TARGET/x86/liboverture.so
popd
echo "Successfully build overture"
Subproject commit 7263b82d2eba2e28d70766aed36ffbc7cf0e1451
addSbtPlugin("org.scala-android" % "sbt-android" % "1.7.6") addSbtPlugin("org.scala-android" % "sbt-android" % "1.7.7")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.10") addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.10")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment