Skip to content

Commit

Permalink
Use flags list
Browse files Browse the repository at this point in the history
  • Loading branch information
jotak committed Nov 14, 2024
1 parent 866485e commit 9407e7d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion web/src/api/ipfix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export interface Fields {
/** Network Events */
NetworkEvents?: string[];
/** Logical OR combination of unique TCP flags comprised in the flow, as per RFC-9293, with additional custom flags to represent the following per-packet combinations: SYN+ACK (0x100), FIN+ACK (0x200) and RST+ACK (0x400). */
Flags?: string;
Flags?: string[];
/** Number of packets */
Packets?: number;
/** In conversation tracking, A to B packets counter per conversation */
Expand Down
30 changes: 16 additions & 14 deletions web/src/components/drawer/record/record-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -473,21 +473,23 @@ export const RecordField: React.FC<RecordFieldProps> = ({
}
case ColumnsId.tcpflags: {
let child = emptyText();
const sVal = String(value);
const flags = getFlagsList(sVal);
if (detailed) {
let description = `${t('Value')}: ${value}`;
if (flags.length === 1) {
description += '. ' + flags[0].description;
} else if (flags.length > 1) {
description +=
'. ' +
t('The flow contains packets with various flags: ') +
flags.map(f => f.name + ' (' + f.description + ')').join('; ');
if (Array.isArray(value) && value.length > 0) {
const flags = getFlagsList(value as string[]);
const joined = value.join(', ');
if (detailed) {
let description = `${t('Value')}: ${value}`;
if (flags.length === 1) {
description += '. ' + flags[0].description;
} else if (flags.length > 1) {
description +=
'. ' +
t('The flow contains packets with various flags: ') +
flags.map(f => f.name + ' (' + f.description + ')').join('; ');
}
child = clickableContent(joined, description, getTCPFlagsDocUrl());
} else {
child = simpleTextWithTooltip(joined)!;
}
child = clickableContent(sVal, description, getTCPFlagsDocUrl());
} else {
child = simpleTextWithTooltip(sVal)!;
}
return singleContainer(child);
}
Expand Down
3 changes: 1 addition & 2 deletions web/src/utils/tcp-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const tcpFlagsList = [
{ name: 'RST_ACK', description: 'Acknowledgement of RST (custom flag)' }
] as const;

export const getFlagsList = (joined: string): { name: string, description: string}[] => {
const names = joined.split(',');
export const getFlagsList = (names: string[]): { name: string, description: string}[] => {
return tcpFlagsList.filter(f => names.includes(f.name));
};

0 comments on commit 9407e7d

Please sign in to comment.