diff options
| author | Christian Poessinger <christian@poessinger.com> | 2022-09-02 07:41:32 +0200 | 
|---|---|---|
| committer | Christian Poessinger <christian@poessinger.com> | 2022-09-02 06:21:32 +0200 | 
| commit | 96302a27db8e9aaad3f2c1a81457c5e8e048dd4b (patch) | |
| tree | 06c63cba1e38428ebd110685f9ff511ebce22282 /src | |
| parent | 735767f09f891c438e43565f935b927e6f1b317d (diff) | |
| parent | 312ee15058fbb26feb6a93520417f0d5343ad15b (diff) | |
| download | vyos-1x-96302a27db8e9aaad3f2c1a81457c5e8e048dd4b.tar.gz vyos-1x-96302a27db8e9aaad3f2c1a81457c5e8e048dd4b.zip | |
Merge branch 'T4651' of https://github.com/nicolas-fort/vyos-1x into firewall
* 'T4651' of https://github.com/nicolas-fort/vyos-1x:
  Firewall: T4651: Change proposed cli from ip-length to packet-length
  Firewall: T4651: Add options to match packet size on firewall rules.
Diffstat (limited to 'src')
| -rwxr-xr-x | src/validators/packet-length | 29 | 
1 files changed, 29 insertions, 0 deletions
| diff --git a/src/validators/packet-length b/src/validators/packet-length new file mode 100755 index 000000000..d96093849 --- /dev/null +++ b/src/validators/packet-length @@ -0,0 +1,29 @@ +#!/usr/bin/python3 + +from sys import argv +from sys import exit +import re + +if __name__ == '__main__': +    if len(argv)>1: +        lengths = argv[1].split(",") + +        for length in lengths: +            if length and length[0] == '!': +                length = length[1:] +            if re.match('^[0-9]{1,5}-[0-9]{1,5}$', length): +                length_1, length_2 = length.split('-') +                if int(length_1) not in range(0, 65536) or int(length_2) not in range(0, 65536): +                    print(f'Error: {length} is not a valid length range') +                    exit(1) +                if int(length_1) > int(length_2): +                    print(f'Error: {length} is not a valid length range') +                    exit(1) +            elif length.isnumeric(): +                if int(length) not in range(0, 65536): +                    print(f'Error: {length} is not a valid length value') +                    exit(1) +    else: +        exit(2) + +    exit(0)
\ No newline at end of file | 
