mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-11-14 18:35:34 +08:00
feat(proxies): drop ipv6 latency test & display
This commit is contained in:
parent
d88641ea5e
commit
cdd60cfc37
@ -21,8 +21,6 @@ import {
|
||||
setProxiesPreviewType,
|
||||
setRenderProxiesInTwoColumns,
|
||||
setUrlForLatencyTest,
|
||||
setUrlIPv6SupportTest,
|
||||
urlForIPv6SupportTest,
|
||||
urlForLatencyTest,
|
||||
} from '~/signals'
|
||||
|
||||
@ -76,16 +74,6 @@ export const ProxiesSettingsModal: Component<{
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col">
|
||||
<ConfigTitle withDivider>{t('urlForIPv6SupportTest')}</ConfigTitle>
|
||||
|
||||
<input
|
||||
class="input input-bordered w-full"
|
||||
value={urlForIPv6SupportTest()}
|
||||
onChange={(e) => setUrlIPv6SupportTest(e.target.value?.trim())}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<ConfigTitle withDivider>{t('proxiesSorting')}</ConfigTitle>
|
||||
|
||||
|
@ -16,16 +16,8 @@ export const ProxyNodeCard = (props: {
|
||||
onClick?: () => void
|
||||
}) => {
|
||||
const { proxyName, isSelected, onClick } = props
|
||||
const {
|
||||
getNowProxyNodeName,
|
||||
proxyIPv6SupportMap,
|
||||
proxyNodeMap,
|
||||
proxyLatencyTest,
|
||||
proxyLatencyTestingMap,
|
||||
} = useProxies()
|
||||
const supportIPv6 = createMemo(
|
||||
() => proxyIPv6SupportMap()[getNowProxyNodeName(proxyName || '')],
|
||||
)
|
||||
const { proxyNodeMap, proxyLatencyTest, proxyLatencyTestingMap } =
|
||||
useProxies()
|
||||
const proxyNode = createMemo(() => proxyNodeMap()[proxyName])
|
||||
|
||||
const specialType = () =>
|
||||
@ -60,21 +52,6 @@ export const ProxyNodeCard = (props: {
|
||||
{proxyName}
|
||||
</h2>
|
||||
|
||||
<span
|
||||
class={twMerge(
|
||||
'text-start text-xs',
|
||||
isSelected ? 'text-info-content' : 'text-neutral-content',
|
||||
)}
|
||||
>
|
||||
{[
|
||||
specialType(),
|
||||
supportIPv6() && 'IPv6',
|
||||
proxyNode().tfo && 'TFO',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' / ')}
|
||||
</span>
|
||||
|
||||
<div class="card-actions items-center justify-between">
|
||||
<div class="badge badge-secondary badge-sm font-bold uppercase">
|
||||
{formatProxyType(proxyNode()?.type)}
|
||||
@ -102,6 +79,17 @@ export const ProxyNodeCard = (props: {
|
||||
<div class="flex flex-col items-center gap-2 rounded-box bg-neutral p-2.5 text-neutral-content">
|
||||
<h2 class="text-lg font-bold">{proxyName}</h2>
|
||||
|
||||
<div
|
||||
class={twMerge(
|
||||
'w-full text-start text-xs',
|
||||
isSelected ? 'text-info-content' : 'text-neutral-content',
|
||||
)}
|
||||
>
|
||||
{[specialType(), proxyNode().tfo && 'TFO']
|
||||
.filter(Boolean)
|
||||
.join(' / ')}
|
||||
</div>
|
||||
|
||||
<ul class="timeline timeline-vertical timeline-compact timeline-snap-icon">
|
||||
<For each={proxyNode().latencyTestHistory}>
|
||||
{(latencyTestResult, index) => (
|
||||
|
@ -48,7 +48,6 @@ export default {
|
||||
auto: 'Auto',
|
||||
off: 'Off',
|
||||
proxiesPreviewType: 'Proxies Preview Type',
|
||||
urlForIPv6SupportTest: 'URL for IPv6 Support Test',
|
||||
urlForLatencyTest: 'URL for Latency Test',
|
||||
autoCloseConns: 'Automatically Close Connections',
|
||||
useTwemoji: 'Use Twemoji Mozilla Font',
|
||||
|
@ -50,7 +50,6 @@ export default {
|
||||
auto: '自适应',
|
||||
off: '关闭',
|
||||
proxiesPreviewType: '节点组预览样式',
|
||||
urlForIPv6SupportTest: '测试 IPv6 支持链接',
|
||||
urlForLatencyTest: '测速链接',
|
||||
autoCloseConns: '自动断开连接',
|
||||
useTwemoji: '使用 Twemoji Mozilla 字体',
|
||||
|
@ -53,13 +53,6 @@ export const [urlForLatencyTest, setUrlForLatencyTest] = makePersisted(
|
||||
{ name: 'urlForLatencyTest', storage: localStorage },
|
||||
)
|
||||
|
||||
export const urlForIPv6SupportTestDefault = 'https://ipv6.google.com'
|
||||
|
||||
export const [urlForIPv6SupportTest, setUrlIPv6SupportTest] = makePersisted(
|
||||
createSignal(urlForIPv6SupportTestDefault),
|
||||
{ name: 'urlForIPv6SupportTest', storage: localStorage },
|
||||
)
|
||||
|
||||
export const autoCloseConnsDefault = false
|
||||
|
||||
export const [autoCloseConns, setAutoCloseConns] = makePersisted(
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { makePersisted } from '@solid-primitives/storage'
|
||||
import {
|
||||
closeSingleConnectionAPI,
|
||||
fetchProxiesAPI,
|
||||
@ -16,7 +15,6 @@ import {
|
||||
latencyTestTimeoutDuration,
|
||||
latestConnectionMsg,
|
||||
restructRawMsgToConnection,
|
||||
urlForIPv6SupportTest,
|
||||
urlForLatencyTest,
|
||||
} from '~/signals'
|
||||
import type { Proxy, ProxyNode, ProxyProvider } from '~/types'
|
||||
@ -66,14 +64,6 @@ const [proxyNodeMap, setProxyNodeMap] = createSignal<Record<string, ProxyInfo>>(
|
||||
{},
|
||||
)
|
||||
|
||||
const [proxyIPv6SupportMap, setProxyIPv6SupportMap] = makePersisted(
|
||||
createSignal<Record<string, boolean>>({}),
|
||||
{
|
||||
name: 'proxyIPv6SupportMap',
|
||||
storage: localStorage,
|
||||
},
|
||||
)
|
||||
|
||||
const getLatencyFromProxy = (
|
||||
proxy: Pick<Proxy, 'extra' | 'history'>,
|
||||
url: string,
|
||||
@ -101,7 +91,6 @@ const setProxiesInfo = (
|
||||
) => {
|
||||
const newProxyNodeMap = { ...proxyNodeMap() }
|
||||
const newLatencyMap = { ...latencyMap() }
|
||||
const newProxyIPv6SupportMap = { ...proxyIPv6SupportMap() }
|
||||
|
||||
proxies.forEach((proxy) => {
|
||||
const { udp, xudp, type, now, history, name, tfo, provider = '' } = proxy
|
||||
@ -118,20 +107,11 @@ const setProxiesInfo = (
|
||||
}
|
||||
|
||||
newLatencyMap[proxy.name] = getLatencyFromProxy(proxy, urlForLatencyTest())
|
||||
|
||||
// we don't set it when false because sing-box didn't have "extra" so it will always be false
|
||||
if (
|
||||
getLatencyFromProxy(proxy, urlForIPv6SupportTest(), false) >
|
||||
latencyQualityMap().NOT_CONNECTED
|
||||
) {
|
||||
newProxyIPv6SupportMap[proxy.name] = true
|
||||
}
|
||||
})
|
||||
|
||||
batch(() => {
|
||||
setProxyNodeMap(newProxyNodeMap)
|
||||
setLatencyMap(newLatencyMap)
|
||||
setProxyIPv6SupportMap(newProxyIPv6SupportMap)
|
||||
})
|
||||
}
|
||||
|
||||
@ -201,7 +181,6 @@ export const useProxies = () => {
|
||||
const nodeName = getNowProxyNodeName(proxyName)
|
||||
|
||||
setProxyLatencyTestingMap(nodeName, async () => {
|
||||
await proxyIPv6SupportTest(nodeName, provider)
|
||||
try {
|
||||
const { delay } = await proxyLatencyTestAPI(
|
||||
nodeName,
|
||||
@ -225,7 +204,6 @@ export const useProxies = () => {
|
||||
|
||||
const proxyGroupLatencyTest = async (proxyGroupName: string) => {
|
||||
setProxyGroupLatencyTestingMap(proxyGroupName, async () => {
|
||||
await proxyGroupIPv6SupportTest(proxyGroupName)
|
||||
await proxyGroupLatencyTestAPI(
|
||||
proxyGroupName,
|
||||
urlForLatencyTest(),
|
||||
@ -235,75 +213,6 @@ export const useProxies = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const proxyIPv6SupportTest = async (proxyName: string, provider: string) => {
|
||||
const urlForTest = urlForIPv6SupportTest()
|
||||
|
||||
if (!urlForTest || urlForTest.length === 0) {
|
||||
setProxyIPv6SupportMap({})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
let support = false
|
||||
try {
|
||||
const { delay } = await proxyLatencyTestAPI(
|
||||
proxyName,
|
||||
provider,
|
||||
urlForTest,
|
||||
latencyTestTimeoutDuration(),
|
||||
)
|
||||
support = delay > latencyQualityMap().NOT_CONNECTED
|
||||
} catch {
|
||||
support = false
|
||||
}
|
||||
setProxyIPv6SupportMap((supportMap) => ({
|
||||
...supportMap,
|
||||
[proxyName]: support,
|
||||
}))
|
||||
}
|
||||
|
||||
const proxyGroupIPv6SupportTest = async (proxyGroupName: string) => {
|
||||
const urlForTest = urlForIPv6SupportTest()
|
||||
|
||||
if (!urlForTest || urlForTest.length === 0) {
|
||||
setProxyIPv6SupportMap({})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const newLatencyMap = await proxyGroupLatencyTestAPI(
|
||||
proxyGroupName,
|
||||
urlForTest,
|
||||
latencyTestTimeoutDuration(),
|
||||
)
|
||||
|
||||
const newSupportMap = Object.fromEntries(
|
||||
Object.entries(newLatencyMap).map(([nodeName, latency]) => [
|
||||
getNowProxyNodeName(nodeName),
|
||||
latency > latencyQualityMap().NOT_CONNECTED,
|
||||
]),
|
||||
)
|
||||
setProxyIPv6SupportMap((supportMap) => ({
|
||||
...supportMap,
|
||||
...newSupportMap,
|
||||
}))
|
||||
} catch {
|
||||
const allNodes = proxies().find((p) => p.name === proxyGroupName)?.all
|
||||
|
||||
if (!allNodes) {
|
||||
return
|
||||
}
|
||||
|
||||
setProxyIPv6SupportMap((proxyIPv6SupportMap) => ({
|
||||
...proxyIPv6SupportMap,
|
||||
...Object.fromEntries(
|
||||
allNodes.map((name) => [getNowProxyNodeName(name), false]),
|
||||
),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
const updateProviderByProviderName = (providerName: string) =>
|
||||
setUpdatingMap(providerName, async () => {
|
||||
try {
|
||||
@ -392,6 +301,5 @@ export const useProxies = () => {
|
||||
getNowProxyNodeName,
|
||||
getLatencyByName,
|
||||
isProxyGroup,
|
||||
proxyIPv6SupportMap,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user