Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bannedbook committed Jun 9, 2020
1 parent 814b94b commit 7595332
Show file tree
Hide file tree
Showing 38 changed files with 952 additions and 178 deletions.
53 changes: 53 additions & 0 deletions build-aar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

set -e

export ANDROID_HOME="/root/java/android-sdk"
export ANDROID_NDK_HOME="${ANDROID_HOME}/ndk-bundle"

export GOROOT="/usr/local/go"
export GOBIN="$GOROOT/bin"
export GOPATH="/root/go"
export GO111MODULE=off
export GOPROXY=direct

export PATH=${PATH}:${GOBIN}:${GOPATH}/bin:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools

# change dir
cd ${GOPATH}/src/AndroidLibV2rayLite

download_data=0
update_go_dep=0

for param in "$@"; do
case $param in
data*)
download_data=1
;;
dep*)
update_go_dep=1
;;
esac
done

echo "Update go dep......"
if [[ ${update_go_dep} == "1" ]] ; then
# download dep
go get -u github.com/golang/protobuf/protoc-gen-go/...
go get -u golang.org/x/mobile/cmd/...
go get -u github.com/jteeuwen/go-bindata/...
go get -u -insecure v2ray.com/core/...

#go get AndroidLibV2rayLite
fi


if [[ ${download_data} == "1" ]] ; then
echo "Download geo data....."
/bin/bash gen_assets.sh download
fi

cd shippedBinarys && make shippedBinary && cd ..

echo "compile aar"
gomobile init && gomobile bind -v -tags json .
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 = 5000868
versionName = '5.1.10-nightly'
versionCode = 5000878
versionName = '5.1.11-nightly'
resConfigs = ['ar', 'es', 'fa', 'fr', 'ja', 'ko', 'ru', 'tr', 'zh-rCN', 'zh-rTW']
}

Expand Down
26 changes: 24 additions & 2 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,29 @@ android {
"room.schemaLocation": "$projectDir/schemas".toString(),
]
}

flavorDimensions "encryption"
productFlavors {
ssvpn {
dimension "encryption"
resValue 'string', 'app_name', "SS VPN"
resValue 'string', 'about_title', "SS VPN %s"
resValue 'string', 'admob_appid', "ca-app-pub-2194043486084479~5832794268"
resValue 'string', 'banner_adUnitId', "ca-app-pub-2194043486084479/4292721507"
resValue 'string', 'native_adUnitId', "ca-app-pub-2194043486084479/8267385919"
}
v2free {
dimension "encryption"
resValue 'string', 'app_name', "V2free"
resValue 'string', 'about_title', "V2free %s"
resValue 'string', 'admob_appid', "ca-app-pub-2194043486084479~8520668797"
resValue 'string', 'banner_adUnitId', "ca-app-pub-2194043486084479/7710984154"
resValue 'string', 'native_adUnitId', "ca-app-pub-2194043486084479/5507178325"
}
}
sourceSets {
ssvpn.setRoot('src/ssvpn')
v2free.setRoot('src/v2free')
}
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility javaVersion
Expand Down Expand Up @@ -55,7 +77,7 @@ def roomVersion = '2.2.3'
def workVersion = '2.3.1'
dependencies {
api project(':plugin')
implementation project(':dpreference')
//implementation project(':dpreference')
implementation project(':libv2ray')
//implementation project(':ssvpn-v2ray')
implementation project(':obfs')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ class ProfileTest {
.toList()
Assert.assertEquals(1, results.size)
Assert.assertEquals("ss://[email protected]:8888#example-server".toUri(),
results.single().toUri())
results.single())
}
}
5 changes: 5 additions & 0 deletions core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,10 @@
android:directBootAware="true"
tools:ignore="Instantiatable"
tools:replace="android:directBootAware"/>
<provider
android:name="me.dozen.dpreference.PreferenceProvider"
android:enabled="true"
android:authorities="${applicationId}.dpreference"
android:exported="false" />
</application>
</manifest>
11 changes: 6 additions & 5 deletions core/src/main/java/SpeedUpVPN/VpnEncrypt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@ object VpnEncrypt{
@JvmStatic fun aesEncrypt(v:String, secretKey:String=theKey) = AES256.encrypt(v, secretKey)
@JvmStatic fun aesDecrypt(v:String, secretKey:String=theKey) = AES256.decrypt(v, secretKey)
@JvmStatic fun readFileAsTextUsingInputStream(fileName: String) = File(fileName).inputStream().readBytes().toString(Charsets.UTF_8)
@JvmStatic fun getUniqueID(): Int {
@JvmStatic fun getUniqueID(appname:String): Int {
var szDevIDShort = "168169"
try {
szDevIDShort+=Build.BOARD.length % 10 + Build.BRAND.length % 10 + Build.DEVICE.length % 10 + Build.MANUFACTURER.length % 10 + Build.MODEL.length % 10 + Build.PRODUCT.length % 10
} catch (exception: Exception) {}
} catch (exception: Exception) {exception.printStackTrace()}
var serial: String? = null
try {
serial = Build::class.java.getField("SERIAL")[null].toString()
serial = Build::class.java.getField("SERIAL")[null].toString()+appname
// Go ahead and return the serial for api => 9
return UUID(szDevIDShort.hashCode() as Long, serial.hashCode() as Long).hashCode()
return UUID(szDevIDShort.hashCode().toLong(), serial.hashCode().toLong()).hashCode()
} catch (exception: Exception) { // String needs to be initialized
serial = "https://git.io/jww" // some value
exception.printStackTrace()
serial = "https://git.io/jww"+appname // some value
}

return UUID(szDevIDShort.hashCode().toLong(), serial.hashCode().toLong()).hashCode()
Expand Down
16 changes: 11 additions & 5 deletions core/src/main/java/com/github/shadowsocks/Core.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ import androidx.work.WorkManager
import com.crashlytics.android.Crashlytics
import com.github.shadowsocks.acl.Acl
import com.github.shadowsocks.aidl.ShadowsocksConnection
import com.github.shadowsocks.bg.*
import com.github.shadowsocks.bg.BaseService
import com.github.shadowsocks.bg.ProxyTestService
import com.github.shadowsocks.bg.V2RayTestService
import com.github.shadowsocks.core.BuildConfig
import com.github.shadowsocks.core.R
import com.github.shadowsocks.database.Profile
import com.github.shadowsocks.database.ProfileManager
Expand All @@ -59,13 +62,13 @@ import kotlinx.coroutines.DEBUG_PROPERTY_NAME
import kotlinx.coroutines.DEBUG_PROPERTY_VALUE_ON
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import me.dozen.dpreference.DPreference
import java.io.File
import java.io.IOException
import kotlin.reflect.KClass
import me.dozen.dpreference.DPreference
import java.net.InetSocketAddress
import java.net.Socket
import java.net.UnknownHostException
import kotlin.reflect.KClass

object Core {
const val TAG = "Core"
Expand All @@ -84,6 +87,9 @@ object Core {
DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE_PER_USER
}

const val appName = BuildConfig.FLAVOR
val applicationId = if (appName === "v2free") "free.v2ray.proxy.VPN" else "free.shadowsocks.proxy.VPN"

val activeProfileIds get() = ProfileManager.getProfile(DataStore.profileId).let {
if (it == null) emptyList() else listOfNotNull(it.id, it.udpFallback)
}
Expand Down Expand Up @@ -128,7 +134,7 @@ object Core {
GlobalScope.launch {
var builtinSubUrls = app.resources.getStringArray(R.array.builtinSubUrls)
for (i in 0 until builtinSubUrls.size) {
var builtinSub=SSRSubManager.createBuiltInSub(builtinSubUrls.get(i))
var builtinSub=SSRSubManager.createSSSub(builtinSubUrls.get(i),VpnEncrypt.vpnGroupName)
if (builtinSub != null) break
}
if (DataStore.is_get_free_servers)importFreeSubs()
Expand All @@ -142,7 +148,7 @@ object Core {
GlobalScope.launch {
var freesuburl = app.resources.getStringArray(R.array.freesuburl)
for (i in freesuburl.indices) {
var freeSub=SSRSubManager.createSSSub(freesuburl[i])
var freeSub=SSRSubManager.createSSSub(freesuburl[i],VpnEncrypt.freesubGroupName)
if (freeSub != null) break
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package com.github.shadowsocks.database
* App Config Const
*/
object AppConfig {
const val ANG_PACKAGE = "free.v2ray.proxy.VPN"
const val ANG_CONFIG = "ang_config"
const val PREF_CURR_CONFIG = "pref_v2ray_config"
const val PREF_CURR_CONFIG_GUID = "pref_v2ray_config_guid"
Expand Down
18 changes: 14 additions & 4 deletions core/src/main/java/com/github/shadowsocks/database/Profile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import android.util.Log
import android.util.LongSparseArray
import androidx.core.net.toUri
import androidx.room.*
import com.github.shadowsocks.Core
import com.github.shadowsocks.plugin.PluginConfiguration
import com.github.shadowsocks.plugin.PluginOptions
import com.github.shadowsocks.preference.DataStore
Expand Down Expand Up @@ -250,7 +251,7 @@ data class Profile(
Log.e(TAG, "Invalid Vmess URI: ${it.value}")
null
}
}.filterNotNull().toMutableSet()
}.filterNotNull()

fun findAllSSRUrls(data: CharSequence?, feature: Profile? = null) = pattern_ssr.findAll(data
?: "").map {
Expand Down Expand Up @@ -283,10 +284,19 @@ data class Profile(
Log.e(TAG, "Invalid SSR URI: ${it.value}")
null
}
}.filterNotNull().toMutableSet()
}.filterNotNull()

fun findAllSSUrls(data: CharSequence?, feature: Profile? = null) = findAllUrls(data,feature).toMutableSet()
fun findAllUrls(data: CharSequence?, feature: Profile? = null) = pattern.findAll(data ?: "").map {
fun findAllUrls(response: CharSequence?, feature: Profile? = null):MutableSet<Profile> {
var profilesSet:MutableSet<Profile> = LinkedHashSet<Profile>()
val ssrProfiles = findAllSSRUrls(response, Core.currentProfile?.first)
val ssPofiles = findAllSSUrls(response, Core.currentProfile?.first)
val v2Profiles= findAllVmessUrls(response, Core.currentProfile?.first)
profilesSet.addAll(ssPofiles)
profilesSet.addAll(ssrProfiles)
profilesSet.addAll(v2Profiles)
return profilesSet
}
fun findAllSSUrls(data: CharSequence?, feature: Profile? = null) = pattern.findAll(data ?: "").map {
val uri = it.value.toUri()
try {
if (uri.userInfo == null) {
Expand Down
Loading

0 comments on commit 7595332

Please sign in to comment.