Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions core/src/main/golang/native/tunnel/proxies.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type Proxy struct {
Subtitle string `json:"subtitle"`
Type string `json:"type"`
Delay int `json:"delay"`
IsGroup bool `json:"isGroup"`
}

type ProxyGroup struct {
Expand Down Expand Up @@ -171,9 +172,10 @@ func convertProxies(proxies []C.Proxy, uiSubtitlePattern *regexp2.Regexp) []*Pro
name := p.Name()
title := name
subtitle := p.Type().String()
_, isGroup := p.Adapter().(outboundgroup.ProxyGroup)

if uiSubtitlePattern != nil {
if _, ok := p.Adapter().(outboundgroup.ProxyGroup); !ok {
if !isGroup {
runes := []rune(name)
match, err := uiSubtitlePattern.FindRunesMatch(runes)
if err == nil && match != nil {
Expand All @@ -196,6 +198,7 @@ func convertProxies(proxies []C.Proxy, uiSubtitlePattern *regexp2.Regexp) []*Pro
Subtitle: strings.TrimSpace(subtitle),
Type: p.Type().String(),
Delay: int(p.LastDelayForTestUrl(testURL)),
IsGroup: isGroup,
})
}
return result
Expand All @@ -209,9 +212,10 @@ func collectProviders(providers []provider.ProxyProvider, uiSubtitlePattern *reg
name := px.Name()
title := name
subtitle := px.Type().String()
_, isGroup := px.Adapter().(outboundgroup.ProxyGroup)

if uiSubtitlePattern != nil {
if _, ok := px.Adapter().(outboundgroup.ProxyGroup); !ok {
if !isGroup {
runes := []rune(name)
match, err := uiSubtitlePattern.FindRunesMatch(runes)
if err == nil && match != nil {
Expand All @@ -235,6 +239,7 @@ func collectProviders(providers []provider.ProxyProvider, uiSubtitlePattern *reg
Subtitle: strings.TrimSpace(subtitle),
Type: px.Type().String(),
Delay: int(px.LastDelayForTestUrl(testURL)),
IsGroup: isGroup,
})
}
}
Expand Down
42 changes: 11 additions & 31 deletions core/src/main/kotlin/com/github/kr328/clash/core/model/Proxy.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.kr328.clash.core.model

import android.os.Parcelable
import kotlin.jvm.JvmInline
import kotlinx.parcelize.Parcelize
import kotlinx.serialization.Serializable

Expand All @@ -12,37 +13,16 @@ data class Proxy(
val subtitle: String,
val type: Type,
val delay: Int,
val isGroup: Boolean,
Comment thread
Goooler marked this conversation as resolved.
) : Parcelable {
enum class Type(val group: Boolean) {
Direct(false),
Reject(false),
RejectDrop(false),
Compatible(false),
Pass(false),
Shadowsocks(false),
ShadowsocksR(false),
Snell(false),
Socks5(false),
Http(false),
Vmess(false),
Vless(false),
Trojan(false),
Hysteria(false),
Hysteria2(false),
Tuic(false),
WireGuard(false),
Dns(false),
Ssh(false),
Mieru(false),
AnyTLS(false),
Sudoku(false),
Masque(false),
TrustTunnel(false),
Relay(true),
Selector(true),
Fallback(true),
URLTest(true),
LoadBalance(true),
Unknown(false),
@JvmInline
@Serializable
@Parcelize
value class Type(val name: String) : Parcelable {
companion object {
val Selector: Type = Type("Selector")
val URLTest: Type = Type("URLTest")
val Unknown: Type = Type("Unknown")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ private fun ProxyContentPreview() {
subtitle = "",
type = Proxy.Type.URLTest,
delay = 48,
isGroup = true,
),
linkIndex = 1,
),
Expand All @@ -658,8 +659,9 @@ private fun ProxyContentPreview() {
name = "hk-01",
title = "Hong Kong 01",
subtitle = "BGP | 1.2x",
type = Proxy.Type.Shadowsocks,
type = Proxy.Type("Shadowsocks"),
delay = 62,
isGroup = false,
),
linkIndex = -1,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ internal class ProxyViewModel(private val uiStore: UiStore) :
group.proxies.map { proxy ->
UiState.ProxyItemSource(
proxy = proxy,
linkIndex = if (proxy.type.group) nameIndexMap[proxy.name] ?: -1 else -1,
linkIndex = if (proxy.isGroup) nameIndexMap[proxy.name] ?: -1 else -1,
)
}
}
Expand Down Expand Up @@ -287,9 +287,9 @@ internal class ProxyViewModel(private val uiStore: UiStore) :
unselectedBackground
}
val controls = if (selected) selectedControl else unselectedControl
val title = if (proxy.type.group) proxy.name else proxy.title
val title = if (proxy.isGroup) proxy.name else proxy.title
val subtitle =
if (proxy.type.group) {
if (proxy.isGroup) {
if (linkNow == null) {
proxy.type.name
} else {
Expand Down