Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bannedbook committed Jun 19, 2020
1 parent 07f3b83 commit dfea82f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 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 = 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']
}

Expand Down
12 changes: 7 additions & 5 deletions core/src/main/java/com/github/shadowsocks/database/Profile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -288,9 +287,9 @@ data class Profile(

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)
val ssrProfiles = findAllSSRUrls(response, feature)
val ssPofiles = findAllSSUrls(response, feature)
val v2Profiles= findAllVmessUrls(response, feature)
profilesSet.addAll(ssPofiles)
profilesSet.addAll(ssrProfiles)
profilesSet.addAll(v2Profiles)
Expand Down Expand Up @@ -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<Profile>

Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}
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.1.16 -m "release v5.1.16"
git tag -a v5.1.17 -m "release v5.1.17"
git push origin --tags
pause

0 comments on commit dfea82f

Please sign in to comment.