mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-13 19:48:21 +00:00
Implement PortServiceDisplay
This commit is contained in:
parent
2ae4c7f5fb
commit
c168fb1a60
1 changed files with 33 additions and 0 deletions
33
client/src/components/display/PortServiceDisplay.vue
Normal file
33
client/src/components/display/PortServiceDisplay.vue
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
const props = withDefaults(defineProps<{
|
||||||
|
data: match | undefined,
|
||||||
|
}>(), {
|
||||||
|
data: undefined,
|
||||||
|
});
|
||||||
|
type port = { single?: { port: number }, range?: { start_port: number, end_port: number } };
|
||||||
|
type portOrAny = string | port;
|
||||||
|
type match = { source: portOrAny, destination: portOrAny };
|
||||||
|
|
||||||
|
const value = computed(() => {
|
||||||
|
if (props.data === undefined) {
|
||||||
|
return 'unknown';
|
||||||
|
}
|
||||||
|
return `${computePort(props.data.source)}->${computePort(props.data.destination)}`;
|
||||||
|
});
|
||||||
|
|
||||||
|
function computePort(port: portOrAny) {
|
||||||
|
if (typeof port === 'string') {
|
||||||
|
return 'any';
|
||||||
|
} else if (port.single !== undefined) {
|
||||||
|
return port.single.port;
|
||||||
|
} else if (port.range != undefined){
|
||||||
|
return `(${port.range.start_port}-${port.range.end_port})`;
|
||||||
|
} else {
|
||||||
|
return 'unknown';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
{{ value }}
|
||||||
|
</template>
|
Loading…
Add table
Reference in a new issue