-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: latency test for selector and ipv6 test
- Loading branch information
1 parent
e84b348
commit 4b2e4ad
Showing
5 changed files
with
135 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import { useProxies } from '~/signals' | ||
import { proxyIPv6SupportMap } from '~/signals/ipv6' | ||
|
||
export const IPv6Support = (props: { name?: string }) => { | ||
const { proxyIPv6SupportMap } = useProxies() | ||
const support = createMemo(() => proxyIPv6SupportMap()[props.name!] === true) | ||
export const IPv6Support = (props: { name?: string; class?: string }) => { | ||
const { getRealProxyNodeName } = useProxies() | ||
|
||
const support = createMemo(() => { | ||
return proxyIPv6SupportMap()[getRealProxyNodeName(props.name || '')] | ||
}) | ||
|
||
return ( | ||
<Show when={support()}> | ||
<span class="badge badge-sm p-px"> | ||
<span class="scale-75">IPv6</span> | ||
</span> | ||
<span class={`scale-75 ${props.class}`}>IPv6</span> | ||
</Show> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { proxyGroupLatencyTestAPI, proxyLatencyTestAPI } from '~/apis' | ||
import { | ||
latencyQualityMap, | ||
latencyTestTimeoutDuration, | ||
urlForIPv6SupportTest, | ||
} from './config' | ||
|
||
export const [proxyIPv6SupportMap, setProxyIPv6SupportMap] = createSignal< | ||
Record<string, boolean> | ||
>({}) | ||
|
||
export 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, | ||
})) | ||
} | ||
|
||
export const proxyGroupIPv6SupportTest = async (proxyGroupName: string) => { | ||
const urlForTest = urlForIPv6SupportTest() | ||
|
||
if (!urlForTest || urlForTest.length === 0) { | ||
setProxyIPv6SupportMap({}) | ||
|
||
return | ||
} | ||
|
||
const newLatencyMap = await proxyGroupLatencyTestAPI( | ||
proxyGroupName, | ||
urlForTest, | ||
latencyTestTimeoutDuration(), | ||
) | ||
const newSupportMap = Object.fromEntries( | ||
Object.entries(newLatencyMap).map(([k, v]) => [ | ||
k, | ||
v > latencyQualityMap().NOT_CONNECTED, | ||
]), | ||
) | ||
setProxyIPv6SupportMap((supportMap) => ({ | ||
...supportMap, | ||
...newSupportMap, | ||
})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters