summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorzephyr <[email protected]>2023-06-25 11:14:33 +0800
committerzephyr <[email protected]>2023-06-25 11:14:33 +0800
commitcc21971645a4a6d60fce48b4da936232bddac9b9 (patch)
tree8cbf67768186c1d82eb7938e67138b5cd181aae2 /src/components
parentfb724a16b86a5ef1d905577fd3e14126e7b8c842 (diff)
fix: no default reg for sourceip table
Diffstat (limited to 'src/components')
-rw-r--r--src/components/Connections.tsx27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/components/Connections.tsx b/src/components/Connections.tsx
index a0d0f37..2cfa731 100644
--- a/src/components/Connections.tsx
+++ b/src/components/Connections.tsx
@@ -102,16 +102,26 @@ function getConnIpList(conns: FormattedConn[], sourceMap: { reg: string; name: s
});
}
-function getNameFromSource(source: string, sourceMap: { reg: string; name: string }[]): string {
- let sourceName = source;
+function getNameFromSource(
+ source: string,
+ sourceMap: { reg: string; name: string }[],
+ defaultVal?: string
+): string {
+ let sourceName = defaultVal ?? source;
sourceMap.forEach(({ reg, name }) => {
if (!reg) return;
- const regExp = new RegExp(reg, 'g');
+ if (reg.startsWith('/')) {
+ const regExp = new RegExp(reg.replace('/', ''), 'g');
- if (regExp.test(source) && name) {
- sourceName = `${name}(${source})`;
+ if (regExp.test(source) && name) {
+ sourceName = `${name}(${source})`;
+ }
+ } else {
+ if (source === reg && name) {
+ sourceName = `${name}(${source})`;
+ }
}
});
@@ -154,7 +164,7 @@ function formatConnectionDataItem(
host: `${host2}:${destinationPort}`,
sniffHost: sniffHost ? sniffHost : '-',
type: `${type}(${network})`,
- source: getNameFromSource(source, sourceMap),
+ source: getNameFromSource(sourceIP, sourceMap, source),
downloadSpeedCurr: download - (prev ? prev.download : 0),
uploadSpeedCurr: upload - (prev ? prev.upload : 0),
process: process ? process : '-',
@@ -319,7 +329,10 @@ function Conn({ apiConfig }) {
))}
</tbody>
</table>
- <Button onClick={() => sourceMap.push({ reg: '', name: '' })}>{t('add_tag')}</Button>
+ <div>
+ <div>{t('sourceip_tip')}</div>
+ <Button onClick={() => sourceMap.push({ reg: '', name: '' })}>{t('add_tag')}</Button>
+ </div>
</BaseModal>
<div className={s.header}>
<ContentHeader title={t('Connections')} />