Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bannedbook committed May 7, 2020
1 parent 3b78028 commit ff833e4
Show file tree
Hide file tree
Showing 357 changed files with 102,305 additions and 13 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ buildscript {
junitVersion = '4.13'
androidTestVersion = '1.2.0'
androidEspressoVersion = '3.2.0'
versionCode = 5000708
versionName = '5.0.6.8-nightly'
versionCode = 5000718
versionName = '5.0.6.9-nightly'
resConfigs = ['ar', 'es', 'fa', 'fr', 'ja', 'ko', 'ru', 'tr', 'zh-rCN', 'zh-rTW']
}

Expand Down
1 change: 1 addition & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def workVersion = '2.3.1'
dependencies {
api project(':plugin')
implementation project(':ssvpn-v2ray')
implementation project(':obfs')
api 'androidx.fragment:fragment-ktx:1.2.1'
api "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
api "androidx.lifecycle:lifecycle-livedata-core-ktx:$lifecycleVersion"
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/SpeedUpVPN/VpnEncrypt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private object AES256{
return encstr
}
fun decrypt(str:String, secretKey:String):String{
val byteStr : ByteArray;
val byteStr : ByteArray
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O || isWindows())
byteStr=java.util.Base64.getDecoder().decode(str.toByteArray(Charsets.UTF_8))
else
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/com/github/shadowsocks/Core.kt
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ object Core {
val builder: AlertDialog.Builder? = activity.let {
AlertDialog.Builder(activity)
}
builder?.setMessage(msg)?.setTitle("SS VPN")?.setPositiveButton("ok", DialogInterface.OnClickListener {
builder?.setMessage(msg)?.setTitle("Alert")?.setPositiveButton("ok", DialogInterface.OnClickListener {
_, _ ->
})
val dialog: AlertDialog? = builder?.create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ object BaseService {

fun stateChanged(s: State, msg: String?) {
val profileName = profileName
//if(!msg.isNullOrEmpty() && msg.isNotBlank())Core.showMessage(msg)
broadcast { it.stateChanged(s.ordinal, profileName, msg) }
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
<string name="title_remove_invalid_servers">删除无效/按组排序</string>
<string name="title_sort_servers_by_speed">按测速结果排序</string>
<string name="toast_test_ended">啊!测试结束啦!</string>
<string name="toast_test_interrupted">"服务器:%s或前一个服务器导致测试中断,请检查之。并请确保安装了simple-obfs插件"</string>
<string name="toast_test_interrupted">"服务器:%s或前一个服务器导致测试中断,请检查/刪除之"</string>
<string name="recommended_site_1">"<![CDATA[
<html xmlns='http://www.w3.org/1999/xhtml' dir='ltr' lang='zh-CN'>
<head profile='http://gmpg.org/xfn/11'>
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
<string name="title_remove_invalid_servers">刪除無效/按組排序</string>
<string name="title_sort_servers_by_speed">按測速結果排序</string>
<string name="toast_test_ended">啊!測試結束啦!</string>
<string name="toast_test_interrupted">"伺服器:%s或前一個伺服器導致測試中斷,請檢查之。並請確保安裝了simple-obfs插件。"</string>
<string name="toast_test_interrupted">"伺服器:%s或前一個伺服器導致測試中斷,請檢查/刪除之"</string>
<string name="recommended_site_1"><![CDATA[
<html>
<body style=\'margin:0;padding:0;font-size:14px;text-align:right\'>
Expand All @@ -235,7 +235,7 @@
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
</head>
<body style=\'margin:0 auto;padding:5px 0;font-size:14px;text-align:center\'>
<a href=\'https://www.bannedbook.org/bnews/zh-tw/?utm_source=speedup.vpn.b5\' style=\'color:#e4f2fd\'>中美港臺時事熱點:每日火爆新聞,焦點評論</a>
<a href=\'https://www.bannedbook.org/bnews/zh-tw/?utm_source=ssvpn.b5\' style=\'color:#e4f2fd\'>中美港臺時事熱點:每日火爆新聞,焦點評論</a>
</body>
</html>
]]>"</string>
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
<string name="title_remove_invalid_servers">Remove invalid/Sort By Group</string>
<string name="title_sort_servers_by_speed">Sort servers by speed</string>
<string name="toast_test_ended">The test ended successfully</string>
<string name="toast_test_interrupted">Server: %s or the previous one caused the test to be interrupted, please check them. And please make sure that the simple-obfs plugin is installed.</string>
<string name="toast_test_interrupted">Server: %s or the previous one caused the test to be interrupted, please check/remove them.</string>
<string name="recommended_site_1">"<![CDATA[
<html xmlns='http://www.w3.org/1999/xhtml'>
<head profile='http://gmpg.org/xfn/11'>
Expand Down
2 changes: 1 addition & 1 deletion gitupdate.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ git pull origin master
git add -A
git commit -m "update"
git push origin master
git tag -a v5.0.6.8 -m "release v5.0.6.8"
git tag -a v5.0.6.9 -m "release v5.0.6.9"
git push origin --tags
pause
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ import android.os.SystemClock
import android.text.format.Formatter
import android.util.Log
import android.util.LongSparseArray
import android.view.LayoutInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.view.*
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.*
Expand Down Expand Up @@ -719,10 +716,12 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
val old = DataStore.profileId
Core.switchProfile(profilesAdapter.profiles[k].id)
activity?.runOnUiThread() {
try {activity.window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)}catch (e:Exception){}
layoutManager.scrollToPositionWithOffset(k, 0)
//layoutManager.stackFromEnd = true
profilesAdapter.refreshId(old)
profilesAdapter.refreshId(profilesAdapter.profiles[k].id)
try {activity.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)}catch (e:Exception){}
}

var result = tcping(profilesAdapter.profiles[k].host, profilesAdapter.profiles[k].remotePort)
Expand Down Expand Up @@ -770,6 +769,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
profilesAdapter.notifyDataSetChanged()
try{Core.alertMessage(activity.getString(R.string.toast_test_ended),activity)}catch (t:Throwable){}
}
try {activity.window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)}catch (e:Exception){}
}
}

Expand Down
5 changes: 5 additions & 0 deletions obfs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/build
/release
# no tests written yet
/src/androidTest
/src/test
48 changes: 48 additions & 0 deletions obfs/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

// ./gradlew app:build
//app/build/outputs/aar/app-release.aar

def javaVersion = JavaVersion.VERSION_1_8

android {
compileSdkVersion 29
compileOptions {
sourceCompatibility javaVersion
targetCompatibility javaVersion
}
kotlinOptions.jvmTarget = javaVersion
defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion 29
//versionCode 1030100
//versionName "1.3.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
//consumerProguardFiles 'proguard-rules.pro' //added this line
}
}

externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
packagingOptions.exclude '**/*.kotlin_*'

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.preference:preference:1.1.1'
implementation 'com.github.shadowsocks:plugin:1.3.4'
implementation 'com.takisoft.preferencex:preferencex-simplemenu:1.1.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
22 changes: 22 additions & 0 deletions obfs/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
-keepattributes SourceFile,LineNumberTable
-dontobfuscate

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
35 changes: 35 additions & 0 deletions obfs/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.shadowsocks.plugin.obfs_local">
<uses-feature android:name="android.hardware.touchscreen"
android:required="false"/>
<application android:icon="@mipmap/ic_launcher">
<provider android:name=".SSVpnBinaryProvider"
android:exported="true"
android:authorities="com.github.shadowsocks.plugin.obfs_local.SSVpnBinaryProvider">
<intent-filter>
<action android:name="com.github.shadowsocks.plugin.ACTION_NATIVE_PLUGIN"/>
</intent-filter>
<intent-filter>
<action android:name="com.github.shadowsocks.plugin.ACTION_NATIVE_PLUGIN"/>
<data android:scheme="plugin"
android:host="com.github.shadowsocks"
android:pathPrefix="/obfs-local"/>
</intent-filter>
<meta-data android:name="com.github.shadowsocks.plugin.id"
android:value="obfs-local"/>
<meta-data android:name="com.github.shadowsocks.plugin.default_config"
android:value="obfs=http"/>
<meta-data android:name="com.github.shadowsocks.plugin.executable_path"
android:value="libobfs-local.so"/>
</provider>
<activity android:name=".ConfigActivity">
<intent-filter>
<action android:name="com.github.shadowsocks.plugin.ACTION_CONFIGURE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="plugin"
android:host="com.github.shadowsocks"
android:path="/obfs-local"/>
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.github.shadowsocks.plugin.obfs_local

import android.net.Uri
import android.os.ParcelFileDescriptor
import com.github.shadowsocks.plugin.NativePluginProvider
import com.github.shadowsocks.plugin.PathProvider
import java.io.File
import java.io.FileNotFoundException

class SSVpnBinaryProvider : NativePluginProvider() {
override fun populateFiles(provider: PathProvider) {
provider.addPath("obfs-local", 755)
}

override fun getExecutable() = context!!.applicationInfo.nativeLibraryDir + "/libobfs-local.so"
override fun openFile(uri: Uri): ParcelFileDescriptor = when (uri.path) {
"/obfs-local" -> ParcelFileDescriptor.open(File(getExecutable()), ParcelFileDescriptor.MODE_READ_ONLY)
else -> throw FileNotFoundException()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.github.shadowsocks.plugin.obfs_local

import android.os.Bundle
import android.view.MenuItem
import android.view.View
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.widget.Toolbar
import androidx.core.view.updatePadding
import com.github.shadowsocks.plugin.ConfigurationActivity
import com.github.shadowsocks.plugin.PluginOptions

class ConfigActivity : ConfigurationActivity(), Toolbar.OnMenuItemClickListener {
//fix activity_main: Error inflating class fragment
//https://stackoverflow.com/questions/19874882/android-view-inflateexception-binary-xml-file-error-inflating-class-fragment
private lateinit var child: ConfigFragment
private lateinit var oldOptions: PluginOptions

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_config)
findViewById<View>(android.R.id.content).apply {
setOnApplyWindowInsetsListener { view, insets ->
view.updatePadding(insets.systemWindowInsetLeft, insets.systemWindowInsetTop,
insets.systemWindowInsetRight)
@Suppress("DEPRECATION")
insets.replaceSystemWindowInsets(0, 0, 0, insets.systemWindowInsetBottom)
}
systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
}
findViewById<Toolbar>(R.id.toolbar).apply {
title = this@ConfigActivity.title
setNavigationIcon(R.drawable.ic_navigation_close)
setNavigationOnClickListener { onBackPressed() }
inflateMenu(R.menu.menu_config)
setOnMenuItemClickListener(this@ConfigActivity)
}

child = ConfigFragment()
supportFragmentManager.beginTransaction()
.replace(R.id.fragment_container, child)
.commit()
}

override fun onInitializePluginOptions(options: PluginOptions) {
oldOptions = options
child.onInitializePluginOptions(options)
}

override fun onMenuItemClick(item: MenuItem?) = when (item?.itemId) {
R.id.action_apply -> {
saveChanges(child.options)
finish()
true
}
else -> false
}

override fun onBackPressed() {
if (child.options != oldOptions) AlertDialog.Builder(this).run {
setTitle(R.string.unsaved_changes_prompt)
setPositiveButton(R.string.yes) { _, _ ->
saveChanges(child.options)
finish()
}
setNegativeButton(R.string.no) { _, _ -> finish() }
setNeutralButton(android.R.string.cancel, null)
create()
}.show() else super.onBackPressed()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.github.shadowsocks.plugin.obfs_local

import android.os.Bundle
import android.text.InputType
import android.view.View
import androidx.core.view.updatePadding
import androidx.preference.EditTextPreference
import androidx.preference.ListPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import com.github.shadowsocks.plugin.PluginOptions

class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChangeListener {
private val obfs by lazy { findPreference<ListPreference>("obfs")!! }
private val obfshost by lazy { findPreference<EditTextPreference>("obfs-host")!! }
private val obfsuri by lazy { findPreference<EditTextPreference>("obfs-uri")!! }
val options get() = PluginOptions().apply {
put("obfs", obfs.value ?: "http")
put("obfs-host", obfshost.text ?: "cloudfront.net")
//put("obfs-uri", obfsuri.text ?: "/")
}

fun onInitializePluginOptions(options: PluginOptions) {
//Log.e("obfs.value","onInitializePluginOptions "+ obfs.value)
//Log.e("obfs.value","options[\"obfs\"] "+ options["obfs"])
obfs.value = options["obfs"] ?: "http"
//Log.e("obfs.value","onInitializePluginOptions "+ obfs.value)
obfshost.text = options["obfs-host"] ?: "cloudfront.net"
//obfsuri.text = options["obfs-uri"] ?: "/"
}

override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
addPreferencesFromResource(R.xml.config)
obfs.onPreferenceChangeListener = this
obfshost.setOnBindEditTextListener { it.inputType = InputType.TYPE_TEXT_VARIATION_URI }
obfsuri.isVisible=false
obfsuri.isEnabled=false
//obfsuri.setOnBindEditTextListener { it.inputType = InputType.TYPE_TEXT_VARIATION_URI }
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
listView.setOnApplyWindowInsetsListener { v, insets ->
insets.apply { v.updatePadding(bottom = systemWindowInsetBottom) }
}

//if (savedInstanceState != null) {
// onInitializePluginOptions(PluginOptions(savedInstanceState.getString(PluginContract.EXTRA_OPTIONS)))
//}
}

/*
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putString(PluginContract.EXTRA_OPTIONS, options.toString())
}
*/

override fun onPreferenceChange(preference: Preference?, newValue: Any?): Boolean {
return true
}
}
Loading

0 comments on commit ff833e4

Please sign in to comment.