check_site.lua 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. need_string(in_site({'site_code'}))
  2. need_string(in_site({'site_name'}))
  3. -- this_domain() returns nil when multidomain support is disabled
  4. if this_domain() then
  5. function need_domain_name(path)
  6. need_string(path)
  7. need(path, function(default_domain)
  8. local f = io.open(os.getenv('IPKG_INSTROOT') .. '/lib/gluon/domains/' .. default_domain .. '.json')
  9. if not f then return false end
  10. f:close()
  11. return true
  12. end, nil, 'be a valid domain name')
  13. end
  14. need_domain_name(in_site({'default_domain'}))
  15. need_table(in_domain({'domain_names'}), function(domain)
  16. need_alphanumeric_key(domain)
  17. need_string(domain)
  18. end)
  19. need_string(in_domain({'domain_names', this_domain()}))
  20. end
  21. need_string_match(in_domain({'domain_seed'}), '^' .. ('%x'):rep(64) .. '$')
  22. need_string({'opkg', 'lede'}, false)
  23. need_table({'opkg', 'extra'}, function(extra_repo)
  24. need_alphanumeric_key(extra_repo)
  25. need_string(extra_repo)
  26. end, false)
  27. need_string(in_site({'hostname_prefix'}), false)
  28. need_string(in_site({'timezone'}))
  29. need_string_array({'ntp_servers'}, false)
  30. need_string_match(in_domain({'prefix6'}), '^[%x:]+/64$')
  31. for _, config in ipairs({'wifi24', 'wifi5'}) do
  32. if need_table({config}, nil, false) then
  33. need_string(in_site({'regdom'})) -- regdom is only required when wifi24 or wifi5 is configured
  34. need_number({config, 'channel'})
  35. local rates = {1000, 2000, 5500, 6000, 9000, 11000, 12000, 18000, 24000, 36000, 48000, 54000}
  36. local supported_rates = need_array_of(in_site({config, 'supported_rates'}), rates, false)
  37. need_array_of({config, 'basic_rate'}, supported_rates or rates, supported_rates ~= nil)
  38. if need_table({config, 'ibss'}, nil, false) then
  39. need_string(in_domain({config, 'ibss', 'ssid'}))
  40. need_string_match(in_domain({config, 'ibss', 'bssid'}), '^%x[02468aAcCeE]:%x%x:%x%x:%x%x:%x%x:%x%x$')
  41. need_one_of({config, 'ibss', 'mcast_rate'}, supported_rates or rates, false)
  42. need_number({config, 'ibss', 'vlan'}, false)
  43. need_boolean({config, 'ibss', 'disabled'}, false)
  44. end
  45. if need_table({config, 'mesh'}, nil, false) then
  46. need_string(in_domain({config, 'mesh', 'id'}))
  47. need_one_of({config, 'mesh', 'mcast_rate'}, supported_rates or rates, false)
  48. need_boolean({config, 'mesh', 'disabled'}, false)
  49. end
  50. end
  51. end
  52. need_boolean(in_site({'poe_passthrough'}), false)
  53. if need_table({'dns'}, nil, false) then
  54. need_string_array_match({'dns', 'servers'}, '^[%x:]+$')
  55. need_number({'dns', 'cacheentries'}, false)
  56. end
  57. need_string_match(in_domain({'next_node', 'ip6'}), '^[%x:]+$', false)
  58. need_string_match(in_domain({'next_node', 'ip4'}), '^%d+.%d+.%d+.%d+$', false)
  59. need_boolean(in_site({'mesh_on_wan'}), false)
  60. need_boolean(in_site({'mesh_on_lan'}), false)
  61. need_boolean(in_site({'single_as_lan'}), false)