Skip to content

Commit

Permalink
fix: IPv6 URL should has []
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaojianli committed Jan 20, 2025
1 parent 439c989 commit 2fc1691
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
8 changes: 4 additions & 4 deletions webui/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webui/src/utils/string.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isIPv6 } from 'is-ip'
export function hashString(str: string) {
let hash = 0,
i,
Expand All @@ -10,3 +11,6 @@ export function hashString(str: string) {
}
return hash
}

export const formatIPAddressPort = (address: string, port: number) =>
isIPv6(address) ? `[${address}]:${port}` : `${address}:${port}`
3 changes: 2 additions & 1 deletion webui/src/views/dashboard/components/peerListModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<countryFlag v-if="record.geo?.country?.iso" :iso="record.geo.country.iso" />
<a-typography-text copyable code style="white-space: nowrap">
<queryIpLink :ip="record.peer.address.ip" style="color: var(--color-text-2)">
{{ record.peer.address.ip }}:{{ record.peer.address.port }}
{{ formatIPAddressPort(record.peer.address.ip, record.peer.address.port) }}
</queryIpLink>
</a-typography-text>
</a-space>
Expand Down Expand Up @@ -84,6 +84,7 @@ import countryFlag from '@/components/countryFlag.vue'
import queryIpLink from '@/components/queryIpLink.vue'
import { getPeer } from '@/service/downloaders'
import { formatFileSize } from '@/utils/file'
import { formatIPAddressPort } from '@/utils/string'
import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { useRequest } from 'vue-request'
Expand Down
3 changes: 2 additions & 1 deletion webui/src/views/data-view/banlog/components/banlogTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<template #peerAddress="{ record }">
<a-typography-text copyable code>
<queryIpLink :ip="record.peerIp" style="color: var(--color-text-2)">
{{ record.peerIp }}:{{ record.peerPort }}
{{ formatIPAddressPort(record.peerIp, record.peerPort) }}
</queryIpLink>
</a-typography-text>
</template>
Expand Down Expand Up @@ -79,6 +79,7 @@ import { useAutoUpdatePlugin } from '@/stores/autoUpdate'
import { useEndpointStore } from '@/stores/endpoint'
import { formatFileSize } from '@/utils/file'
import { computed, ref, watch } from 'vue'
import { formatIPAddressPort } from '@/utils/string'
import { useI18n } from 'vue-i18n'
import { usePagination } from 'vue-request'
const forceLoading = ref(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<template #peerAddress="{ record }">
<a-typography-text code>
<queryIpLink :ip="record.peerIp" style="color: var(--color-text-2)">
{{ record.peerIp }}:{{ record.peerPort }}
{{ formatIPAddressPort(record.peerIp, record.peerPort) }}
</queryIpLink>
</a-typography-text>
</template>
Expand Down Expand Up @@ -91,6 +91,8 @@ import { useEndpointStore } from '@/stores/endpoint'
import { formatFileSize } from '@/utils/file'
import { computed, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { formatIPAddressPort } from '@/utils/string'
import { usePagination } from 'vue-request'
const endpointState = useEndpointStore()
Expand Down

0 comments on commit 2fc1691

Please sign in to comment.