blob: 6bb42be1e1496cfdce732f835a3c93f300601fd1 (
plain)
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
|
#!/usr/bin/env python3
# Conntrack syntax version 3
# Enables all conntrack modules (previous default behaviour) and omits manually disabled modules.
import sys
from vyos.configtree import ConfigTree
if len(sys.argv) < 2:
print('Must specify file name!')
sys.exit(1)
filename = sys.argv[1]
with open(filename, 'r') as f:
config = ConfigTree(f.read())
module_path = ['system', 'conntrack', 'modules']
# Go over all conntrack modules available as of v1.3.0.
for module in ['ftp', 'h323', 'nfs', 'pptp', 'sip', 'sqlnet', 'tftp']:
# 'disable' is being phased out.
if config.exists(module_path + [module, 'disable']):
config.delete(module_path + [module])
# If it wasn't manually 'disable'd, it was enabled by default.
else:
config.set(module_path + [module])
try:
if config.exists(module_path):
with open(filename, 'w') as f:
f.write(config.to_string())
except OSError as e:
print(f'Failed to save the modified config: {e}')
sys.exit(1)
|