mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-14 21:57:24 +08:00
feat: show NAT type of all nodes in GUI (#1464)
This commit is contained in:
@@ -22,6 +22,7 @@ const peerRouteInfos = computed(() => {
|
|||||||
ipv4_addr: my_node_info?.virtual_ipv4,
|
ipv4_addr: my_node_info?.virtual_ipv4,
|
||||||
hostname: my_node_info?.hostname,
|
hostname: my_node_info?.hostname,
|
||||||
version: my_node_info?.version,
|
version: my_node_info?.version,
|
||||||
|
stun_info: my_node_info?.stun_info
|
||||||
},
|
},
|
||||||
}, ...(props.curNetworkInst.detail?.peer_route_pairs || [])]
|
}, ...(props.curNetworkInst.detail?.peer_route_pairs || [])]
|
||||||
}
|
}
|
||||||
@@ -145,6 +146,34 @@ interface Chip {
|
|||||||
icon: string
|
icon: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// udp nat type
|
||||||
|
enum NatType {
|
||||||
|
// has NAT; but own a single public IP, port is not changed
|
||||||
|
Unknown = 0,
|
||||||
|
OpenInternet = 1,
|
||||||
|
NoPAT = 2,
|
||||||
|
FullCone = 3,
|
||||||
|
Restricted = 4,
|
||||||
|
PortRestricted = 5,
|
||||||
|
Symmetric = 6,
|
||||||
|
SymUdpFirewall = 7,
|
||||||
|
SymmetricEasyInc = 8,
|
||||||
|
SymmetricEasyDec = 9,
|
||||||
|
};
|
||||||
|
|
||||||
|
const udpNatTypeStrMap = {
|
||||||
|
[NatType.Unknown]: 'Unknown',
|
||||||
|
[NatType.OpenInternet]: 'Open Internet',
|
||||||
|
[NatType.NoPAT]: 'No PAT',
|
||||||
|
[NatType.FullCone]: 'Full Cone',
|
||||||
|
[NatType.Restricted]: 'Restricted',
|
||||||
|
[NatType.PortRestricted]: 'Port Restricted',
|
||||||
|
[NatType.Symmetric]: 'Symmetric',
|
||||||
|
[NatType.SymUdpFirewall]: 'Symmetric UDP Firewall',
|
||||||
|
[NatType.SymmetricEasyInc]: 'Symmetric Easy Inc',
|
||||||
|
[NatType.SymmetricEasyDec]: 'Symmetric Easy Dec',
|
||||||
|
}
|
||||||
|
|
||||||
const myNodeInfoChips = computed(() => {
|
const myNodeInfoChips = computed(() => {
|
||||||
if (!props.curNetworkInst)
|
if (!props.curNetworkInst)
|
||||||
return []
|
return []
|
||||||
@@ -213,35 +242,8 @@ const myNodeInfoChips = computed(() => {
|
|||||||
} as Chip)
|
} as Chip)
|
||||||
}
|
}
|
||||||
|
|
||||||
// udp nat type
|
|
||||||
enum NatType {
|
|
||||||
// has NAT; but own a single public IP, port is not changed
|
|
||||||
Unknown = 0,
|
|
||||||
OpenInternet = 1,
|
|
||||||
NoPAT = 2,
|
|
||||||
FullCone = 3,
|
|
||||||
Restricted = 4,
|
|
||||||
PortRestricted = 5,
|
|
||||||
Symmetric = 6,
|
|
||||||
SymUdpFirewall = 7,
|
|
||||||
SymmetricEasyInc = 8,
|
|
||||||
SymmetricEasyDec = 9,
|
|
||||||
};
|
|
||||||
const udpNatType: NatType = my_node_info.stun_info?.udp_nat_type
|
const udpNatType: NatType = my_node_info.stun_info?.udp_nat_type
|
||||||
if (udpNatType !== undefined) {
|
if (udpNatType !== undefined) {
|
||||||
const udpNatTypeStrMap = {
|
|
||||||
[NatType.Unknown]: 'Unknown',
|
|
||||||
[NatType.OpenInternet]: 'Open Internet',
|
|
||||||
[NatType.NoPAT]: 'No PAT',
|
|
||||||
[NatType.FullCone]: 'Full Cone',
|
|
||||||
[NatType.Restricted]: 'Restricted',
|
|
||||||
[NatType.PortRestricted]: 'Port Restricted',
|
|
||||||
[NatType.Symmetric]: 'Symmetric',
|
|
||||||
[NatType.SymUdpFirewall]: 'Symmetric UDP Firewall',
|
|
||||||
[NatType.SymmetricEasyInc]: 'Symmetric Easy Inc',
|
|
||||||
[NatType.SymmetricEasyDec]: 'Symmetric Easy Dec',
|
|
||||||
}
|
|
||||||
|
|
||||||
chips.push({
|
chips.push({
|
||||||
label: `UDP NAT Type: ${udpNatTypeStrMap[udpNatType]}`,
|
label: `UDP NAT Type: ${udpNatTypeStrMap[udpNatType]}`,
|
||||||
icon: '',
|
icon: '',
|
||||||
@@ -272,6 +274,14 @@ function rxGlobalSum() {
|
|||||||
return globalSumCommon('stats.rx_bytes')
|
return globalSumCommon('stats.rx_bytes')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function natType(info: PeerRoutePair): string {
|
||||||
|
const udpNatType = info.route?.stun_info?.udp_nat_type;
|
||||||
|
if (udpNatType !== undefined)
|
||||||
|
return udpNatTypeStrMap[udpNatType as NatType]
|
||||||
|
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
const peerCount = computed(() => {
|
const peerCount = computed(() => {
|
||||||
if (!peerRouteInfos.value)
|
if (!peerRouteInfos.value)
|
||||||
return 0
|
return 0
|
||||||
@@ -439,6 +449,7 @@ function showEventLogs() {
|
|||||||
<Column :field="txBytes" :header="t('upload_bytes')" />
|
<Column :field="txBytes" :header="t('upload_bytes')" />
|
||||||
<Column :field="rxBytes" :header="t('download_bytes')" />
|
<Column :field="rxBytes" :header="t('download_bytes')" />
|
||||||
<Column :field="lossRate" :header="t('loss_rate')" />
|
<Column :field="lossRate" :header="t('loss_rate')" />
|
||||||
|
<Column :field="natType" :header="t('nat_type')" />
|
||||||
<Column :header="t('status.version')">
|
<Column :header="t('status.version')">
|
||||||
<template #body="slotProps">
|
<template #body="slotProps">
|
||||||
<span>{{ version(slotProps.data) }}</span>
|
<span>{{ version(slotProps.data) }}</span>
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ latency: 延迟
|
|||||||
upload_bytes: 上传
|
upload_bytes: 上传
|
||||||
download_bytes: 下载
|
download_bytes: 下载
|
||||||
loss_rate: 丢包率
|
loss_rate: 丢包率
|
||||||
|
nat_type: NAT 类型
|
||||||
|
|
||||||
flags_switch: 功能开关
|
flags_switch: 功能开关
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ latency: Latency
|
|||||||
upload_bytes: Upload
|
upload_bytes: Upload
|
||||||
download_bytes: Download
|
download_bytes: Download
|
||||||
loss_rate: Loss Rate
|
loss_rate: Loss Rate
|
||||||
|
nat_type: NAT Type
|
||||||
|
|
||||||
flags_switch: Feature Switch
|
flags_switch: Feature Switch
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user