Skip to content

Commit

Permalink
feat(connections): split source info into sourceIP and sourcePort
Browse files Browse the repository at this point in the history
  • Loading branch information
kunish committed Sep 6, 2023
1 parent 3bf39db commit 2d61f45
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 20 deletions.
3 changes: 2 additions & 1 deletion src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ export enum CONNECTIONS_TABLE_ACCESSOR_KEY {
Download = 'dl',
Upload = 'ul',
ConnectTime = 'connectTime',
Source = 'source',
SourceIP = 'sourceIP',
SourcePort = 'sourcePort',
Destination = 'destination',
}

Expand Down
5 changes: 3 additions & 2 deletions src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export default {
ulSpeed: 'UL Speed',
dl: 'DL',
ul: 'UL',
source: 'Source',
sourceIP: 'Source IP',
sourcePort: 'Source Port',
destination: 'Destination',
close: 'Close',
reset: 'Reset',
Expand Down Expand Up @@ -66,6 +67,6 @@ export default {
lg: 'Large size',
switchEndpoint: 'Switch Endpoint',
switchLanguage: 'Switch Language',
speedtestTimeoutDuration: 'Speedtest Timeout Duration',
latencyTestTimeoutDuration: 'Latency Test Timeout Duration',
closedConnections: 'Closed Connections',
}
5 changes: 3 additions & 2 deletions src/i18n/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export default {
ulSpeed: '上传速度',
dl: '下载量',
ul: '上传量',
source: '源地址',
sourceIP: '源地址',
sourcePort: '源端口',
destination: '目标地址',
close: '关闭',
reset: '重置',
Expand Down Expand Up @@ -66,6 +67,6 @@ export default {
lg: '超大尺寸',
switchEndpoint: '切换后端',
switchLanguage: '切换语言',
speedtestTimeoutDuration: '测速超时时间',
latencyTestTimeoutDuration: '测速超时时间',
closedConnections: '已关闭连接',
}
10 changes: 6 additions & 4 deletions src/pages/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
autoSwitchTheme,
favDayTheme,
favNightTheme,
latencyTestTimeoutDuration,
proxiesOrderingType,
proxiesPreviewType,
renderInTwoColumn,
Expand All @@ -34,16 +35,15 @@ import {
setAutoSwitchTheme,
setFavDayTheme,
setFavNightTheme,
setLatencyTestTimeoutDuration,
setProxiesOrderingType,
setProxiesPreviewType,
setRenderInTwoColumn,
setRenderProxiesInSamePage,
setSelectedEndpoint,
setSpeedtestTimeoutDuration,
setTableSize,
setTwemoji,
setUrlForLatencyTest,
speedtestTimeoutDuration,
tableSize,
urlForLatencyTest,
useRequest,
Expand Down Expand Up @@ -240,8 +240,10 @@ const ConfigForm = () => {
<input
type="number"
class="input input-bordered w-full max-w-md"
value={speedtestTimeoutDuration()}
onChange={(e) => setSpeedtestTimeoutDuration(Number(e.target.value))}
value={latencyTestTimeoutDuration()}
onChange={(e) =>
setLatencyTestTimeoutDuration(Number(e.target.value))
}
/>
</div>

Expand Down
16 changes: 9 additions & 7 deletions src/pages/Connections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
} from '@tanstack/solid-table'
import byteSize from 'byte-size'
import dayjs from 'dayjs'
import { isIPv6 } from 'is-ip'
import { differenceWith, isEqualWith } from 'lodash'
import { For, createEffect, createMemo, createSignal, untrack } from 'solid-js'
import { twMerge } from 'tailwind-merge'
Expand Down Expand Up @@ -260,12 +259,14 @@ export default () => {
sortingFn: (prev, next) => prev.original.upload - next.original.upload,
},
{
header: () => t('source'),
accessorKey: CONNECTIONS_TABLE_ACCESSOR_KEY.Source,
accessorFn: (row) =>
isIPv6(row.metadata.sourceIP)
? `[${row.metadata.sourceIP}]:${row.metadata.sourcePort}`
: `${row.metadata.sourceIP}:${row.metadata.sourcePort}`,
header: () => t('sourceIP'),
accessorKey: CONNECTIONS_TABLE_ACCESSOR_KEY.SourceIP,
accessorFn: (row) => row.metadata.sourceIP,
},
{
header: () => t('sourcePort'),
accessorKey: CONNECTIONS_TABLE_ACCESSOR_KEY.SourcePort,
accessorFn: (row) => row.metadata.sourcePort,
},
{
header: () => t('destination'),
Expand Down Expand Up @@ -468,6 +469,7 @@ export default () => {
<IconZoomInFilled size={18} />
)}
</div>

<div>
{flexRender(
cell.column.columnDef.cell,
Expand Down
4 changes: 2 additions & 2 deletions src/signals/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ export const tableSizeClassName = (size: TAILWINDCSS_SIZE) => {
return className
}

export const [speedtestTimeoutDuration, setSpeedtestTimeoutDuration] =
export const [latencyTestTimeoutDuration, setLatencyTestTimeoutDuration] =
makePersisted(createSignal(2000), {
name: 'speedtestTimeoutDuration',
name: 'latencyTestTimeoutDuration',
storage: localStorage,
})

Expand Down
4 changes: 2 additions & 2 deletions src/signals/proxies.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createSignal } from 'solid-js'
import {
autoCloseConns,
speedtestTimeoutDuration,
latencyTestTimeoutDuration,
urlForLatencyTest,
useRequest,
} from '~/signals'
Expand Down Expand Up @@ -98,7 +98,7 @@ export const useProxies = () => {
.get(`group/${proxyGroupName}/delay`, {
searchParams: {
url: urlForLatencyTest(),
timeout: speedtestTimeoutDuration(),
timeout: latencyTestTimeoutDuration(),
},
})
.json()
Expand Down

0 comments on commit 2d61f45

Please sign in to comment.