- Timestamp:
- May 9, 2017, 6:15:37 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/gformat.py
r13843 r13861 175 175 176 176 gfile = os.path.join(NODE_DIR,item,'wleiden.yaml') 177 global_rdr_file = os.path.join(NODE_DIR,'global_rdr_rules.yaml') 178 d = yaml.load(open(global_rdr_file, 'r'), Loader=Loader) 177 179 178 180 # Default values … … 184 186 f = open(gfile, 'r') 185 187 datadump.update(yaml.load(f,Loader=Loader)) 188 datadump['autogen_global_rdr_rules'] = d['global_rdr_rules'] 186 189 if datadump['nodetype'] == 'Hybrid': 187 190 # Some values are defined implicitly 188 if datadump.has_key('rdr_ rules') and datadump['rdr_rules'] and not datadump.has_key('service_incoming_rdr'):191 if datadump.has_key('rdr_host') and datadump['rdr_host'] and not datadump.has_key('service_incoming_rdr'): 189 192 datadump['service_incoming_rdr'] = True 190 193 # Use some boring defaults … … 507 510 """ Generate config file '/usr/local/etc/dhcpd.conf """ 508 511 # Redundency support, in cause local DNS server is not running/responding. 509 datadump['autogen_ domain_name_servers'] = [datadump['masterip']] +[x[1] for x in get_neighbours(datadump)]512 datadump['autogen_backup_dns_servers'] = [x[1] for x in get_neighbours(datadump)] 510 513 output = generate_header(datadump) 511 514 output += Template("""\ 512 515 # option definitions common to all supported networks... 513 516 option domain-name "dhcp.{{ autogen_fqdn }}"; 514 515 option domain-name-servers {{ autogen_domain_name_servers|join(", ") }};516 517 517 518 default-lease-time 600; … … 569 570 datadump[iface_key]['autogen_dhcp_start'] = dhcp_part + "." + dhcp_start 570 571 datadump[iface_key]['autogen_dhcp_stop'] = dhcp_part + "." + dhcp_stop 572 datadump[iface_key]['autogen_dns_servers'] = ','.join([datadump[iface_key]['autogen_addr']] + datadump['autogen_backup_dns_servers']) 571 573 572 574 # Assume the first 10 IPs could be used for static entries … … 586 588 range %(autogen_dhcp_start)s %(autogen_dhcp_stop)s; 587 589 option routers %(autogen_addr)s; 590 option domain-name-servers %(autogen_dns_servers)s; 591 588 592 } 589 593 """ % datadump[iface_key])) … … 1168 1172 """ Generate configuration file '/etc/pf.hybrid.conf.local' """ 1169 1173 datadump['autogen_header'] = generate_header(datadump, "#") 1174 if datadump['service_incoming_rdr']: 1175 datadump['global_rdr_rules'] = datadump['autogen_global_rdr_rules'] 1170 1176 return Template("""\ 1171 1177 {{ autogen_header }} 1172 1178 1173 1179 # Redirect some internal facing services outside (7) 1174 # INFO: {{ rdr_rules|count }} rdr_rules (outside to internal redirect rules) defined. 1180 # INFO: {{ global_rdr_rules|count }} global_rdr_rules active on this node. 1181 {% for protocol, src_port,dest_ip,dest_port in global_rdr_rules -%} 1182 rdr on $ext_if inet proto {{ protocol }} from any to $ext_if port {{ src_port }} tag SRV -> {{ dest_ip }} port {{ dest_port }} 1183 {% endfor -%} 1184 # INFO: {{ rdr_rules|count }} node specific rdr_rules defined. 1175 1185 {% for protocol, src_port,dest_ip,dest_port in rdr_rules -%} 1176 1186 rdr on $ext_if inet proto {{ protocol }} from any to $ext_if port {{ src_port }} tag SRV -> {{ dest_ip }} port {{ dest_port }}
Note:
See TracChangeset
for help on using the changeset viewer.