summaryrefslogtreecommitdiff
path: root/src/validators/port-range
blob: abf0b09d5cba3ee7aabfccc7bf23a67c99f2a5ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/python3

import sys
import re

if __name__ == '__main__':
    if len(sys.argv)>1:
        port_range = sys.argv[1]
        if re.search('[0-9]{1,5}-[0-9]{1,5}', port_range):
            for tmp in port_range.split('-'):
                if int(tmp) not in range(1, 65535):
                    sys.exit(1)
        else:
            if int(port_range) not in range(1, 65535):
                sys.exit(1)
    else:
        sys.exit(2)

    sys.exit(0)