keep proxy original order

This commit is contained in:
Kr328 committed 2019-12-07 15:01:05 +08:00
1 parent 5ffa1aeb1d
commit b41b9267bd
4 files changed
+11 -3

No files matched your search

@@ -101,7 +101,7 @@ class ProxyActivity : BaseActivity() {
{
it.value.type != ProxyPacket.Type.SELECT
}, {
it.value.name
it.value.order
})
)
.flatMap {
+7
View File
@@ -76,6 +76,8 @@ func handleQueryProxies(client *net.UnixConn) {
root.Mode = tunnel.Instance().Mode().String()
root.Proxies = make(map[string]interface{})
var order int = 0
for k, p := range proxies {
inner, err := p.MarshalJSON()
@@ -86,6 +88,11 @@ func handleQueryProxies(client *net.UnixConn) {
mapping := map[string]interface{}{}
json.Unmarshal(inner, &mapping)
mapping["order"] = order
order += 1
root.Proxies[k] = mapping
}
@@ -8,7 +8,7 @@ import kotlinx.serialization.Serializable
@Serializable
data class ProxyPacket(val mode: String, val proxies: Map<Int, Proxy>): Parcelable {
@Serializable
data class Proxy(val name: String, val type: Type, val now: Int, val all: Set<Int>, val delay: Long)
data class Proxy(val name: String, val type: Type, val order: Int, val now: Int, val all: Set<Int>, val delay: Long)
enum class Type {
SELECT,
@@ -81,7 +81,7 @@ data class ProxyPacket(val mode: String, val proxies: Map<Int, Proxy>): Parcelab
val all = entry.value.second.all.mapNotNull { hashed[it]?.first }.toSet()
val delay = entry.value.second.history.firstOrNull()?.delay ?: 0
entry.value.first to Proxy(entry.key, type, now, all, delay)
entry.value.first to Proxy(entry.key, type,entry.value.second.order, now, all, delay)
}
return ProxyPacket(rawProxy.mode, proxies.toMap())
@@ -7,6 +7,7 @@ data class RawProxyPacket(val mode: String, val proxies: Map<String, RawProxy>)
@Serializable
data class RawProxy(val type: String,
val all: List<String> = emptyList(),
val order: Int = 0,
val now: String = "",
val history: List<History> = emptyList()) {
@Serializable