Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bannedbook committed Apr 28, 2020
1 parent 6f1b356 commit 84cd6b1
Show file tree
Hide file tree
Showing 42 changed files with 74 additions and 10 deletions.
6 changes: 3 additions & 3 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 = 5000698
versionName = '5.0.6.6-nightly'
versionCode = 5000700
versionName = '5.0.6.7-nightly'
resConfigs = ['ar', 'es', 'fa', 'fr', 'ja', 'ko', 'ru', 'tr', 'zh-rCN', 'zh-rTW']
}

Expand All @@ -25,7 +25,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.0.0-beta04'
classpath 'com.android.tools.build:gradle:4.0.0-beta05'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.27.0'
classpath 'com.google.android.gms:oss-licenses-plugin:0.9.5'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta04'
Expand Down
2 changes: 1 addition & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def roomVersion = '2.2.3'
def workVersion = '2.3.1'
dependencies {
api project(':plugin')
implementation project(':app')
implementation project(':v2ray-plugin')
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
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,54 @@ object SSRSubManager {
}
}

fun updateBuiltinProfiles(ssrSub: SSRSub, profiles : List<Profile>,limit:Int) {
when {
profiles.isEmpty() -> {
deletProfiles(ssrSub)
ssrSub.status = SSRSub.EMPTY
updateSSRSub(ssrSub)
return
}
ssrSub.url_group != profiles[0].url_group -> {
ssrSub.status = SSRSub.NAME_CHANGED
updateSSRSub(ssrSub)
return
}
else -> {
ssrSub.status = SSRSub.NORMAL
updateSSRSub(ssrSub)
}
}

val count = profiles.count()
var limitProfiles:ArrayList<Profile> = arrayListOf()

if (limit != -1 && limit < count) {
try {
val uqid=VpnEncrypt.getUniqueID()
Log.e("uqid",uqid.toString())
val startPosition=uqid % count
for (k in 0 until limit) {
var thePosition=startPosition+k
if(thePosition>=count) thePosition -= count
limitProfiles.add(profiles[thePosition])
}
}
catch (ex: Exception) {
limitProfiles.clear()
limitProfiles.addAll(profiles.shuffled().take(limit))
}
if (limitProfiles.isEmpty())limitProfiles.addAll(profiles.shuffled().take(limit))
}
else
limitProfiles.addAll(profiles)

if (limitProfiles.isNotEmpty()) {
deletProfiles(ssrSub)
ProfileManager.createProfilesFromSub(limitProfiles, ssrSub.url_group)
}
}

fun update(ssrSub: SSRSub, profiles : List<Profile>) {
when {
profiles.isEmpty() -> {
Expand Down Expand Up @@ -185,6 +233,11 @@ object SSRSubManager {
if (url.isEmpty()) return null
try {
val response = getResponse(url,"aes")
var limit = -1
if (response.indexOf("MAX=") == 0) {
limit = response.split("\n")[0].split("MAX=")[1]
.replace("\\D+".toRegex(), "").toInt()
}
val ssrProfiles = Profile.findAllSSRUrls(response, Core.currentProfile?.first)
val ssPofiles = Profile.findAllSSUrls(response, Core.currentProfile?.first)
var profiles:List<Profile>? = null
Expand All @@ -204,13 +257,13 @@ object SSRSubManager {
profiles.forEach { it.url_group = VpnEncrypt.vpnGroupName }
getAllSSRSub().forEach {
if (it.url_group == new.url_group) {
update(it, profiles)//android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
updateBuiltinProfiles(it, profiles,limit)//android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
Log.println(Log.ERROR,"------","ssrsub existed, update.")
return it
}
}
createSSRSub(new)
update(new, profiles)
updateBuiltinProfiles(new, profiles,limit)
Log.println(Log.ERROR,"------","success create ssrsub.")
return new
} catch (e: Exception) {
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/com/github/shadowsocks/net/HttpsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class HttpsTest : ViewModel() {
Acl.CHINALIST -> "www.qualcomm.cn"
else -> "www.google.com"
}, "/generate_204")

val conn = (if (DataStore.serviceMode != Key.modeVpn) {
url.openConnection(Proxy(Proxy.Type.SOCKS, DataStore.proxyAddress))
} else url.openConnection()) as HttpURLConnection
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.6 -m "release v5.0.6.6"
git tag -a v5.0.6.7 -m "release v5.0.6.7"
git push origin --tags
pause
10 changes: 10 additions & 0 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resConfigs rootProject.resConfigs
}
signingConfigs {
release {
storeFile file("/root/java/andorid-key/ssr.key")
storePassword System.console().readLine("\nKeystore password: ")
keyAlias 'ssr'
keyPassword System.console().readLIne("\nKey password: ")
}
}
buildTypes {
debug {
pseudoLocalesEnabled true
Expand All @@ -38,6 +46,7 @@ android {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt')
signingConfig signingConfigs.release
}
}
compileOptions {
Expand All @@ -58,6 +67,7 @@ android {
universalApk true
}
}

sourceSets.main.jniLibs.srcDirs +=
new File(project(':core').buildDir, "intermediates/bundles/${getCurrentFlavor()}/jni")
}
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ':mobile', ':core', ':plugin', ':app'
include ':mobile', ':core', ':plugin', ':v2ray-plugin'
File renamed without changes.
4 changes: 2 additions & 2 deletions app/build.gradle → v2ray-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def getCurrentFlavor() {
def javaVersion = JavaVersion.VERSION_1_8

android {
compileSdkVersion 29
compileSdkVersion rootProject.compileSdkVersion
compileOptions {
sourceCompatibility javaVersion
targetCompatibility javaVersion
Expand Down Expand Up @@ -67,7 +67,7 @@ dependencies {
}

ext.abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, x86: 3, x86_64: 4]
if (getCurrentFlavor() == 'release') android.applicationVariants.all { variant ->
if (getCurrentFlavor() == 'release') android.libraryVariants.all { variant ->
variant.outputs.each { output ->
def offset = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
if (offset != null) output.versionCodeOverride = variant.versionCode + offset
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes

0 comments on commit 84cd6b1

Please sign in to comment.