check_site.lua 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. need_string(in_site({'site_code'}))
  2. need_string(in_site({'site_name'}))
  3. need_string_match(in_domain({'domain_seed'}), '^' .. ('%x'):rep(64) .. '$')
  4. need_string({'opkg', 'lede'}, false)
  5. need_table({'opkg', 'extra'}, function(extra_repo)
  6. need_alphanumeric_key(extra_repo)
  7. need_string(extra_repo)
  8. end, false)
  9. need_string(in_site({'hostname_prefix'}), false)
  10. need_string(in_site({'timezone'}))
  11. need_string_array({'ntp_servers'}, false)
  12. need_string_match(in_domain({'prefix6'}), '^[%x:]+/64$')
  13. for _, config in ipairs({'wifi24', 'wifi5'}) do
  14. if need_table({config}, nil, false) then
  15. need_string(in_site({'regdom'})) -- regdom is only required when wifi24 or wifi5 is configured
  16. need_number({config, 'channel'})
  17. local rates = {1000, 2000, 5500, 6000, 9000, 11000, 12000, 18000, 24000, 36000, 48000, 54000}
  18. local supported_rates = need_array_of(in_site({config, 'supported_rates'}), rates, false)
  19. need_array_of({config, 'basic_rate'}, supported_rates or rates, supported_rates ~= nil)
  20. if need_table({config, 'ibss'}, nil, false) then
  21. need_string(in_domain({config, 'ibss', 'ssid'}))
  22. need_string_match(in_domain({config, 'ibss', 'bssid'}), '^%x[02468aAcCeE]:%x%x:%x%x:%x%x:%x%x:%x%x$')
  23. need_one_of({config, 'ibss', 'mcast_rate'}, supported_rates or rates, false)
  24. need_number({config, 'ibss', 'vlan'}, false)
  25. need_boolean({config, 'ibss', 'disabled'}, false)
  26. end
  27. if need_table({config, 'mesh'}, nil, false) then
  28. need_string(in_domain({config, 'mesh', 'id'}))
  29. need_one_of({config, 'mesh', 'mcast_rate'}, supported_rates or rates, false)
  30. need_boolean({config, 'mesh', 'disabled'}, false)
  31. end
  32. end
  33. end
  34. need_boolean(in_site({'poe_passthrough'}), false)
  35. if need_table({'dns'}, nil, false) then
  36. need_string_array_match({'dns', 'servers'}, '^[%x:]+$')
  37. need_number({'dns', 'cacheentries'}, false)
  38. end
  39. need_string_match(in_domain({'next_node', 'ip6'}), '^[%x:]+$', false)
  40. need_string_match(in_domain({'next_node', 'ip4'}), '^%d+.%d+.%d+.%d+$', false)
  41. need_boolean(in_site({'mesh_on_wan'}), false)
  42. need_boolean(in_site({'mesh_on_lan'}), false)
  43. need_boolean(in_site({'single_as_lan'}), false)