/
getCIDRBroadcast.ts
40 lines (38 loc) · 1.29 KB
/
getCIDRBroadcast.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { getCIDRBroadcast } from '@terascope/utils';
import { FieldType } from '@terascope/types';
import {
ProcessMode, FunctionDefinitionType, FunctionDefinitionCategory, FieldTransformConfig
} from '../interfaces';
export const getCIDRBroadcastConfig: FieldTransformConfig = {
name: 'getCIDRBroadcast',
type: FunctionDefinitionType.FIELD_TRANSFORM,
process_mode: ProcessMode.INDIVIDUAL_VALUES,
category: FunctionDefinitionCategory.IP,
examples: [
{
args: {},
config: { version: 1, fields: { testField: { type: FieldType.String } } },
field: 'testField',
input: '8.8.12.118/24',
output: '8.8.12.255',
},
{
args: {},
config: { version: 1, fields: { testField: { type: FieldType.String } } },
field: 'testField',
input: '1.2.3.4/32',
output: '1.2.3.4',
}
],
description: 'Returns the broadcast address of a CIDR range, only applicable to IPv4 addresses',
create() { return getCIDRBroadcast; },
accepts: [FieldType.String, FieldType.IPRange],
output_type({ field_config }) {
return {
field_config: {
...field_config,
type: FieldType.IP
}
};
}
};