feat(connections): split source info into sourceIP and sourcePort

This commit is contained in:
kunish 2023-09-06 11:55:12 +08:00
parent 3bf39db149
commit 2d61f45372
No known key found for this signature in database
GPG Key ID: 647A12B4F782C430
7 changed files with 27 additions and 20 deletions

View File

@ -122,7 +122,8 @@ export enum CONNECTIONS_TABLE_ACCESSOR_KEY {
Download = 'dl', Download = 'dl',
Upload = 'ul', Upload = 'ul',
ConnectTime = 'connectTime', ConnectTime = 'connectTime',
Source = 'source', SourceIP = 'sourceIP',
SourcePort = 'sourcePort',
Destination = 'destination', Destination = 'destination',
} }

View File

@ -30,7 +30,8 @@ export default {
ulSpeed: 'UL Speed', ulSpeed: 'UL Speed',
dl: 'DL', dl: 'DL',
ul: 'UL', ul: 'UL',
source: 'Source', sourceIP: 'Source IP',
sourcePort: 'Source Port',
destination: 'Destination', destination: 'Destination',
close: 'Close', close: 'Close',
reset: 'Reset', reset: 'Reset',
@ -66,6 +67,6 @@ export default {
lg: 'Large size', lg: 'Large size',
switchEndpoint: 'Switch Endpoint', switchEndpoint: 'Switch Endpoint',
switchLanguage: 'Switch Language', switchLanguage: 'Switch Language',
speedtestTimeoutDuration: 'Speedtest Timeout Duration', latencyTestTimeoutDuration: 'Latency Test Timeout Duration',
closedConnections: 'Closed Connections', closedConnections: 'Closed Connections',
} }

View File

@ -30,7 +30,8 @@ export default {
ulSpeed: '上传速度', ulSpeed: '上传速度',
dl: '下载量', dl: '下载量',
ul: '上传量', ul: '上传量',
source: '源地址', sourceIP: '源地址',
sourcePort: '源端口',
destination: '目标地址', destination: '目标地址',
close: '关闭', close: '关闭',
reset: '重置', reset: '重置',
@ -66,6 +67,6 @@ export default {
lg: '超大尺寸', lg: '超大尺寸',
switchEndpoint: '切换后端', switchEndpoint: '切换后端',
switchLanguage: '切换语言', switchLanguage: '切换语言',
speedtestTimeoutDuration: '测速超时时间', latencyTestTimeoutDuration: '测速超时时间',
closedConnections: '已关闭连接', closedConnections: '已关闭连接',
} }

View File

@ -26,6 +26,7 @@ import {
autoSwitchTheme, autoSwitchTheme,
favDayTheme, favDayTheme,
favNightTheme, favNightTheme,
latencyTestTimeoutDuration,
proxiesOrderingType, proxiesOrderingType,
proxiesPreviewType, proxiesPreviewType,
renderInTwoColumn, renderInTwoColumn,
@ -34,16 +35,15 @@ import {
setAutoSwitchTheme, setAutoSwitchTheme,
setFavDayTheme, setFavDayTheme,
setFavNightTheme, setFavNightTheme,
setLatencyTestTimeoutDuration,
setProxiesOrderingType, setProxiesOrderingType,
setProxiesPreviewType, setProxiesPreviewType,
setRenderInTwoColumn, setRenderInTwoColumn,
setRenderProxiesInSamePage, setRenderProxiesInSamePage,
setSelectedEndpoint, setSelectedEndpoint,
setSpeedtestTimeoutDuration,
setTableSize, setTableSize,
setTwemoji, setTwemoji,
setUrlForLatencyTest, setUrlForLatencyTest,
speedtestTimeoutDuration,
tableSize, tableSize,
urlForLatencyTest, urlForLatencyTest,
useRequest, useRequest,
@ -240,8 +240,10 @@ const ConfigForm = () => {
<input <input
type="number" type="number"
class="input input-bordered w-full max-w-md" class="input input-bordered w-full max-w-md"
value={speedtestTimeoutDuration()} value={latencyTestTimeoutDuration()}
onChange={(e) => setSpeedtestTimeoutDuration(Number(e.target.value))} onChange={(e) =>
setLatencyTestTimeoutDuration(Number(e.target.value))
}
/> />
</div> </div>

View File

@ -27,7 +27,6 @@ import {
} from '@tanstack/solid-table' } from '@tanstack/solid-table'
import byteSize from 'byte-size' import byteSize from 'byte-size'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { isIPv6 } from 'is-ip'
import { differenceWith, isEqualWith } from 'lodash' import { differenceWith, isEqualWith } from 'lodash'
import { For, createEffect, createMemo, createSignal, untrack } from 'solid-js' import { For, createEffect, createMemo, createSignal, untrack } from 'solid-js'
import { twMerge } from 'tailwind-merge' import { twMerge } from 'tailwind-merge'
@ -260,12 +259,14 @@ export default () => {
sortingFn: (prev, next) => prev.original.upload - next.original.upload, sortingFn: (prev, next) => prev.original.upload - next.original.upload,
}, },
{ {
header: () => t('source'), header: () => t('sourceIP'),
accessorKey: CONNECTIONS_TABLE_ACCESSOR_KEY.Source, accessorKey: CONNECTIONS_TABLE_ACCESSOR_KEY.SourceIP,
accessorFn: (row) => accessorFn: (row) => row.metadata.sourceIP,
isIPv6(row.metadata.sourceIP) },
? `[${row.metadata.sourceIP}]:${row.metadata.sourcePort}` {
: `${row.metadata.sourceIP}:${row.metadata.sourcePort}`, header: () => t('sourcePort'),
accessorKey: CONNECTIONS_TABLE_ACCESSOR_KEY.SourcePort,
accessorFn: (row) => row.metadata.sourcePort,
}, },
{ {
header: () => t('destination'), header: () => t('destination'),
@ -468,6 +469,7 @@ export default () => {
<IconZoomInFilled size={18} /> <IconZoomInFilled size={18} />
)} )}
</div> </div>
<div> <div>
{flexRender( {flexRender(
cell.column.columnDef.cell, cell.column.columnDef.cell,

View File

@ -76,9 +76,9 @@ export const tableSizeClassName = (size: TAILWINDCSS_SIZE) => {
return className return className
} }
export const [speedtestTimeoutDuration, setSpeedtestTimeoutDuration] = export const [latencyTestTimeoutDuration, setLatencyTestTimeoutDuration] =
makePersisted(createSignal(2000), { makePersisted(createSignal(2000), {
name: 'speedtestTimeoutDuration', name: 'latencyTestTimeoutDuration',
storage: localStorage, storage: localStorage,
}) })

View File

@ -1,7 +1,7 @@
import { createSignal } from 'solid-js' import { createSignal } from 'solid-js'
import { import {
autoCloseConns, autoCloseConns,
speedtestTimeoutDuration, latencyTestTimeoutDuration,
urlForLatencyTest, urlForLatencyTest,
useRequest, useRequest,
} from '~/signals' } from '~/signals'
@ -98,7 +98,7 @@ export const useProxies = () => {
.get(`group/${proxyGroupName}/delay`, { .get(`group/${proxyGroupName}/delay`, {
searchParams: { searchParams: {
url: urlForLatencyTest(), url: urlForLatencyTest(),
timeout: speedtestTimeoutDuration(), timeout: latencyTestTimeoutDuration(),
}, },
}) })
.json() .json()