- Timestamp:
- Mar 7, 2012, 11:03:33 PM (13 years ago)
- Location:
- tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/genesis-to-yaml.pl
r10053 r10054 82 82 } 83 83 84 foreach $key ('internalif', 'nat', 'internalroute', 'remote_access', 'gateway', 'firewall_block' ) {84 foreach $key ('internalif', 'nat', 'internalroute', 'remote_access', 'gateway', 'firewall_block', 'proxyid') { 85 85 if ($$key) { 86 86 print "$key: $$key\n"; -
tools/gformat.py
r10053 r10054 56 56 'rc.conf.local', 57 57 'resolv.conf', 58 'wleiden.yaml' 58 'wleiden.yaml', 59 59 ] 60 60 … … 262 262 output = generate_header("#"); 263 263 output += """\ 264 hostname='%( nodetype)s%(nodename)s.%(domain)s'264 hostname='%(autogen_fqdn)s.%(domain)s' 265 265 location='%(location)s' 266 266 """ % datadump … … 278 278 279 279 # Extra Proxy configuration 280 datadump['ileiden_enable'] = 'yes' if datadump['ileiden'] else 'no' 280 281 if datadump['nodetype'] == 'Proxy': 281 output += '\n# Disable routing\ngateway_enable="no"\n' 282 283 output += '\ninternalif="%s"\n' % datadump['internalif'] 284 285 output += '\n' 282 output += """ 283 # 284 # PROXY Configuration 285 # 286 sshtun_enable="YES" 287 sshtun_flags="-R 22%(proxyid)02i:localhost:22" 288 289 static_routes="wleiden" 290 route_wleiden="-net 172.16.0.0/12 %(internalroute)s" 291 292 internalif="%(internalif)s" 293 294 # PROXY iLeiden Configuration 295 ileiden_enable="%(ileiden_enable)s" 296 gateway_enable="%(ileiden_enable)s" 297 firewall_enable="%(ileiden_enable)s" 298 firewall_script="/etc/ipfw.sh" 299 firewall_nat_enable="%(ileiden_enable)s" 300 """ % datadump 301 302 if datadump['nodetype'] == 'CNode' and datadump['ileiden']: 303 output += """ 304 # NODE iLeiden Configuration 305 ileiden_enable="%(ileiden_enable)s" 306 307 captive_portal_whitelist="" 308 captive_portal_interfaces="%(autogen_dhcp_interfaces)s" 309 """ % datadump 310 286 311 # lo0 configuration: 287 312 # - 172.32.255.1/32 is the proxy.wleiden.net deflector … … 299 324 addrs_list['lo0'].append(datadump['masterip'] + "/32") 300 325 301 wlan_count = 0302 326 for iface_key in datadump['iface_keys']: 303 327 ifacedump = datadump[iface_key] … … 320 344 # XXX: Might want to deduct type directly from interface name 321 345 if ifacedump['type'] in ['11a', '11b', '11g', 'wireless']: 322 # Create wlanX interface323 ifacedump['wlanif'] ="wlan%i" % wlan_count324 iface_map[interface] = ifacedump['wlanif']325 wlan_count += 1326 327 346 # Default to station (client) mode 328 347 ifacedump['wlanmode'] = "sta" … … 344 363 ifacedump['extra'] = 'regdomain ETSI country NL' 345 364 346 output += "wlans_%(interface)s='%( wlanif)s'\n" % ifacedump347 output += ("create_args_%( wlanif)s='wlanmode %(wlanmode)s mode " +\365 output += "wlans_%(interface)s='%(autogen_ifname)s'\n" % ifacedump 366 output += ("create_args_%(autogen_ifname)s='wlanmode %(wlanmode)s mode " +\ 348 367 "%(mode)s ssid %(ssid)s %(extra)s channel %(channel)s'\n") % ifacedump 349 368 … … 372 391 datadump = yaml.load(f,Loader=Loader) 373 392 datadump['autogen_iface_keys'] = get_interface_keys(datadump) 393 394 wlan_count=0 395 for key in datadump['autogen_iface_keys']: 396 if datadump[key]['type'] in ['11a', '11b', '11g', 'wireless']: 397 datadump[key]['autogen_ifname'] = 'wlan%i' % wlan_count 398 wlan_count += 1 399 else: 400 datadump[key]['autogen_ifname'] = datadump[key]['interface'] 401 402 403 dhcp_interfaces = [datadump[key]['autogen_ifname'] for key in datadump['autogen_iface_keys'] if datadump[key]['dhcp'] != 'no'] 404 datadump['autogen_dhcp_interfaces'] = ' '.join(dhcp_interfaces) 374 405 datadump['autogen_item'] = item 406 datadump['autogen_fqdn'] = get_fqdn(datadump) 375 407 f.close() 376 408 … … 399 431 def get_interface_keys(config): 400 432 """ Quick hack to get all interface keys, later stage convert this to a iterator """ 401 return [elem for elem in config.keys() if (elem.startswith('iface_') and not "lo0" in elem)]433 return sorted([elem for elem in config.keys() if (elem.startswith('iface_') and not "lo0" in elem)]) 402 434 403 435 … … 485 517 if key.startswith('autogen_'): 486 518 del datadump[key] 519 # Interface autogen cleanups 520 elif type(datadump[key]) == dict: 521 for key2 in datadump[key].keys(): 522 if key2.startswith('autogen_'): 523 del datadump[key][key2] 524 487 525 488 526 output = generate_header("#")
Note:
See TracChangeset
for help on using the changeset viewer.