From dfea82f646ea26e8e5d44629e3c18a781cb06ac1 Mon Sep 17 00:00:00 2001 From: bannedbook Date: Fri, 19 Jun 2020 17:53:50 +0800 Subject: [PATCH] update --- build.gradle | 4 ++-- .../java/com/github/shadowsocks/database/Profile.kt | 12 +++++++----- .../github/shadowsocks/database/ProfileManager.kt | 12 ++++++++---- gitupdate.bat | 2 +- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/build.gradle b/build.gradle index bb0634d..8e46e0d 100644 --- a/build.gradle +++ b/build.gradle @@ -14,8 +14,8 @@ buildscript { junitVersion = '4.13' androidTestVersion = '1.2.0' androidEspressoVersion = '3.2.0' - versionCode = 5000928 - versionName = '5.1.16-nightly' + versionCode = 5000938 + versionName = '5.1.17-nightly' resConfigs = ['ar', 'es', 'fa', 'fr', 'ja', 'ko', 'ru', 'tr', 'zh-rCN', 'zh-rTW'] } diff --git a/core/src/main/java/com/github/shadowsocks/database/Profile.kt b/core/src/main/java/com/github/shadowsocks/database/Profile.kt index 55b4d8c..7691476 100644 --- a/core/src/main/java/com/github/shadowsocks/database/Profile.kt +++ b/core/src/main/java/com/github/shadowsocks/database/Profile.kt @@ -218,7 +218,6 @@ data class Profile( if (TextUtils.isEmpty(result)) { null } - //Log.e("VmessQRCode::class.java",VmessQRCode::class.java.toString()) var vmessQRCode = VmessQRCode() vmessQRCode = Gson().fromJson(result, vmessQRCode::class.java) if (TextUtils.isEmpty(vmessQRCode.add) @@ -288,9 +287,9 @@ data class Profile( fun findAllUrls(response: CharSequence?, feature: Profile? = null):MutableSet { var profilesSet:MutableSet = LinkedHashSet() - val ssrProfiles = findAllSSRUrls(response, Core.currentProfile?.first) - val ssPofiles = findAllSSUrls(response, Core.currentProfile?.first) - val v2Profiles= findAllVmessUrls(response, Core.currentProfile?.first) + val ssrProfiles = findAllSSRUrls(response, feature) + val ssPofiles = findAllSSUrls(response, feature) + val v2Profiles= findAllVmessUrls(response, feature) profilesSet.addAll(ssPofiles) profilesSet.addAll(ssrProfiles) profilesSet.addAll(v2Profiles) @@ -446,6 +445,9 @@ data class Profile( @Query("SELECT * FROM `Profile` WHERE `host` = :host LIMIT 1") fun getByHost(host: String): Profile? + @Query("SELECT * FROM `Profile` WHERE `host` = :host and `remotePort` = :port LIMIT 1") + fun getByHostAndPort(host: String,port:Int): Profile? + @Query("SELECT * FROM `Profile` WHERE `Subscription` != 2 ORDER BY `userOrder`") fun listActive(): List @@ -531,7 +533,7 @@ data class Profile( return "" } } - fun isSameAs(other: Profile): Boolean = other.host == host + fun isSameAs(other: Profile): Boolean = other.host == host && other.remotePort == remotePort override fun toString() : String { if (profileType=="ss") diff --git a/core/src/main/java/com/github/shadowsocks/database/ProfileManager.kt b/core/src/main/java/com/github/shadowsocks/database/ProfileManager.kt index e87ad76..aad36f7 100644 --- a/core/src/main/java/com/github/shadowsocks/database/ProfileManager.kt +++ b/core/src/main/java/com/github/shadowsocks/database/ProfileManager.kt @@ -54,7 +54,7 @@ object ProfileManager { @Throws(SQLException::class) fun createProfile(profile: Profile = Profile()): Profile { - var existOne=PrivateDatabase.profileDao.getByHost(profile.host) + var existOne=PrivateDatabase.profileDao.getByHostAndPort(profile.host,profile.remotePort) if (existOne==null) { profile.id = 0 profile.userOrder = PrivateDatabase.profileDao.nextOrder() ?: 0 @@ -89,7 +89,7 @@ object ProfileManager { } return@filter true }.forEach { createProfile(it) } - deletProfiles(old) + if (old.isNotEmpty())deletProfiles(old) } fun importProfiles(text: CharSequence, replace: Boolean = false):Int { @@ -313,9 +313,13 @@ object ProfileManager { fun getRandomVPNServer(): Profile? { try { - return getAllProfilesByGroup(VpnEncrypt.vpnGroupName)?.random() + val profiles=getAllProfilesByGroup(VpnEncrypt.vpnGroupName) + return if (profiles.isNotEmpty()) + profiles.random() + else + getAllProfiles()?.random() } catch (ex: Exception) { - Log.e("speedup.vpn",this.javaClass.name+":"+ex.javaClass.name) + Log.e("getRandomVPNServer",this.javaClass.name+":"+ex.javaClass.name) return null } } diff --git a/gitupdate.bat b/gitupdate.bat index ea17579..9fbc86d 100644 --- a/gitupdate.bat +++ b/gitupdate.bat @@ -3,6 +3,6 @@ git pull origin master git add -A git commit -m "update" git push origin master -git tag -a v5.1.16 -m "release v5.1.16" +git tag -a v5.1.17 -m "release v5.1.17" git push origin --tags pause \ No newline at end of file