Changeset 13861 in genesis for tools


Ignore:
Timestamp:
May 9, 2017, 6:15:37 AM (8 years ago)
Author:
rick
Message:

Make rdr_rules global for multi-access use.

Allowing them to be used at all exit-nodes, which could be usefull if one
exit-node is down and service still need to continue working.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/gformat.py

    r13843 r13861  
    175175
    176176    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)
    177179
    178180    # Default values
     
    184186    f = open(gfile, 'r')
    185187    datadump.update(yaml.load(f,Loader=Loader))
     188    datadump['autogen_global_rdr_rules'] = d['global_rdr_rules']
    186189    if datadump['nodetype'] == 'Hybrid':
    187190      # 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'):
    189192        datadump['service_incoming_rdr'] = True
    190193      # Use some boring defaults
     
    507510  """ Generate config file '/usr/local/etc/dhcpd.conf """
    508511  # 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)]
    510513  output = generate_header(datadump)
    511514  output += Template("""\
    512515# option definitions common to all supported networks...
    513516option domain-name "dhcp.{{ autogen_fqdn }}";
    514 
    515 option domain-name-servers {{ autogen_domain_name_servers|join(", ") }};
    516517
    517518default-lease-time 600;
     
    569570    datadump[iface_key]['autogen_dhcp_start'] = dhcp_part + "." + dhcp_start
    570571    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'])
    571573
    572574    # Assume the first 10 IPs could be used for static entries
     
    586588        range %(autogen_dhcp_start)s %(autogen_dhcp_stop)s;
    587589        option routers %(autogen_addr)s;
     590        option domain-name-servers %(autogen_dns_servers)s;
     591
    588592      }
    589593      """ % datadump[iface_key]))
     
    11681172  """ Generate configuration file '/etc/pf.hybrid.conf.local' """
    11691173  datadump['autogen_header'] = generate_header(datadump, "#")
     1174  if datadump['service_incoming_rdr']:
     1175    datadump['global_rdr_rules'] = datadump['autogen_global_rdr_rules']
    11701176  return Template("""\
    11711177{{ autogen_header }}
    11721178
    11731179# 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 -%}
     1182rdr 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.
    11751185{% for protocol, src_port,dest_ip,dest_port in rdr_rules -%}
    11761186rdr 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.