Skip to content

Commit

Permalink
Improved duplicate configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Nov 16, 2024
1 parent eb5627c commit 633ee63
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
44 changes: 39 additions & 5 deletions V2rayNG/app/src/main/java/com/v2ray/ang/dto/ProfileItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,44 @@ data class ProfileItem(
return Utils.getIpv6Address(server) + ":" + serverPort
}

fun getKeyProperty(): ProfileItem {
val copy = this.copy()
copy.subscriptionId = ""
copy.addedTime = 0L
return copy
override fun equals(other: Any?): Boolean {
if (other == null) return false
val obj = other as ProfileItem

return (this.server == obj.server
&& this.serverPort == obj.serverPort
&& this.password == obj.password
&& this.method == obj.method
&& this.flow == obj.flow
&& this.username == obj.username

&& this.network == obj.network
&& this.headerType == obj.headerType
&& this.host == obj.host
&& this.path == obj.path
&& this.seed == obj.seed
&& this.quicSecurity == obj.quicSecurity
&& this.quicKey == obj.quicKey
&& this.mode == obj.mode
&& this.serviceName == obj.serviceName
&& this.authority == obj.authority

&& this.security == obj.security
&& this.sni == obj.sni
&& this.alpn == obj.alpn
&& this.fingerPrint == obj.fingerPrint
&& this.publicKey == obj.publicKey
&& this.shortId == obj.shortId

&& this.secretKey == obj.secretKey
&& this.localAddress == obj.localAddress
&& this.reserved == obj.reserved
&& this.mtu == obj.mtu

&& this.obfsPassword == obj.obfsPassword
&& this.portHopping == obj.portHopping
&& this.portHoppingInterval == obj.portHoppingInterval
&& this.pinSHA256 == obj.pinSHA256
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {

val deleteServer = mutableListOf<String>()
serversCacheCopy.forEachIndexed { index, it ->
val outbound = it.second.getKeyProperty()
val outbound = it.second
serversCacheCopy.forEachIndexed { index2, it2 ->
if (index2 > index) {
val outbound2 = it2.second.getKeyProperty()
val outbound2 = it2.second
if (outbound.equals(outbound2) && !deleteServer.contains(it2.first)) {
deleteServer.add(it2.first)
}
Expand Down

0 comments on commit 633ee63

Please sign in to comment.