fix(proxies): group type does not show UDP

This commit is contained in:
riolu.rs 2023-09-05 01:30:17 +08:00
parent 9973c2042c
commit f0fbe09838
5 changed files with 32 additions and 4 deletions

View File

@ -1,7 +1,7 @@
import { createMemo } from 'solid-js'
import { twMerge } from 'tailwind-merge'
import { Latency } from '~/components'
import { formatProxyType } from '~/helpers'
import { filterGroupType, formatProxyType } from '~/helpers'
import { useProxies } from '~/signals'
export const ProxyNodeCard = (props: {
@ -32,7 +32,15 @@ export const ProxyNodeCard = (props: {
)}
>
{formatProxyType(proxyNode()?.type)}
{proxyNode()?.udp && ' :: udp'}
{filterGroupType(proxyNode()?.type) ? (
<span>
{' :: '}
{proxyNode()?.xudp && 'x'}
{proxyNode()?.udp && 'udp'}
</span>
) : (
<span>{proxyNode()?.now}</span>
)}
</div>
<div class="text-xs">
<Latency name={props.proxyName} />

View File

@ -28,12 +28,27 @@ export const formatProxyType = (type = '') => {
const t = type.toLowerCase()
if (t.includes('shadowsocks')) {
return t.replace('shadowsocks', 'ss')
return 'ss'
}
return t
}
export const filterGroupType = (type = '') => {
const t = type.toLowerCase()
const conditions = [
'selector',
'direct',
'reject',
'urltest',
'loadbalance',
'fallback',
'relay',
]
return !conditions.includes(t)
}
export const sortProxiesByOrderingType = (
proxyNames: string[],
proxyLatencyMap: Record<string, number>,

View File

@ -71,7 +71,7 @@ export default () => {
</Button>
</div>
<div class="text-sm text-slate-500">
{proxy.type} :: {proxy.now}
{proxy.type} {proxy.now?.length > 0 && ` :: ${proxy.now}`}
</div>
<Show when={!collapsedMap()[`group-${proxy.name}`]}>
<ProxyNodePreview

View File

@ -5,6 +5,8 @@ import type { Proxy, ProxyNode, ProxyProvider } from '~/types'
type ProxyInfo = {
name: string
udp: boolean
now: string
xudp: boolean
type: string
}
// these signals should be global state
@ -25,7 +27,9 @@ const setProxiesInfo = (proxies: (Proxy | ProxyNode)[]) => {
newProxyNodeMap[proxy.name] = {
udp: proxy.udp,
xudp: proxy.xudp,
type: proxy.type,
now: proxy.now,
name: proxy.name,
}
newLatencyMap[proxy.name] = latency

View File

@ -28,6 +28,7 @@ export type ProxyNode = {
tfo: boolean
udp: boolean
xudp: boolean
now: string
id: string
extra: Record<string, unknown>
history: {