Gluon-core: Allow multiple domain names for next_node-feature
* change type from next_node.names * create domain entry for each entry and add to dnsmasq configuration
This commit is contained in:
parent
bc75ce5c86
commit
728130004c
@ -83,6 +83,7 @@
|
||||
-- connected to using a known IP address.
|
||||
next_node = {
|
||||
-- anycast IPs of all nodes
|
||||
-- name = { 'nextnode.location.community.example.org', 'nextnode', 'nn' },
|
||||
ip4 = '10.xxx.0.xxx',
|
||||
ip6 = 'fdxx:xxxx:xxxx::xxxx',
|
||||
},
|
||||
|
@ -163,6 +163,7 @@ next_node \: package
|
||||
::
|
||||
|
||||
next_node = {
|
||||
name = { 'nextnode.location.community.example.org', 'nextnode', 'nn' },
|
||||
ip4 = '10.23.42.1',
|
||||
ip6 = 'fdca:ffee:babe:1::1',
|
||||
mac = '16:41:95:40:f7:dc'
|
||||
@ -172,7 +173,8 @@ next_node \: package
|
||||
omitted, there will be no IPv4 or IPv6 anycast address. The MAC address
|
||||
defaults to ``16:41:95:40:f7:dc``; this value usually doesn't need to be
|
||||
changed, but it can be adjusted to match existing deployments that use a
|
||||
different value.
|
||||
different value. Each entry in the ``name``-field will be resolved as the
|
||||
ipv4 and ipv6-address.
|
||||
|
||||
mesh \: optional
|
||||
Options specific to routing protocols.
|
||||
|
@ -70,6 +70,12 @@ if need_table({'dns'}, nil, false) then
|
||||
need_number({'dns', 'cacheentries'}, false)
|
||||
end
|
||||
|
||||
if need_table('next_node', nil, false) then
|
||||
need_string_match('next_node.ip6', '^[%x:]+$', false)
|
||||
need_string_match('next_node.ip4', '^%d+.%d+.%d+.%d+$', false)
|
||||
need_string_array('next_node.name', false)
|
||||
end
|
||||
|
||||
need_string_match(in_domain({'next_node', 'ip6'}), '^[%x:]+$', false)
|
||||
need_string_match(in_domain({'next_node', 'ip4'}), '^%d+.%d+.%d+.%d+$', false)
|
||||
|
||||
|
@ -25,22 +25,25 @@ if dns.servers then
|
||||
})
|
||||
end
|
||||
|
||||
if next_node.name and next_node.ip4 then
|
||||
uci:section('dhcp', 'domain', 'nextnode4', {
|
||||
name = next_node.name,
|
||||
ip = next_node.ip4,
|
||||
local function set_dns_record(name, ip, sectionname)
|
||||
if not ip then return end
|
||||
uci:section('dhcp', 'domain', sectionname, {
|
||||
name = name,
|
||||
ip = ip,
|
||||
})
|
||||
else
|
||||
uci:delete('dhcp', 'domain', 'nextnode4')
|
||||
end
|
||||
|
||||
if next_node.name and next_node.ip6 then
|
||||
uci:section('dhcp', 'domain', 'nextnode6', {
|
||||
name = next_node.name,
|
||||
ip = next_node.ip6,
|
||||
})
|
||||
else
|
||||
uci:delete('dhcp', 'domain', 'nextnode6')
|
||||
uci:foreach("dhcp", "domain", function(s)
|
||||
for key, value in pairs(s) do
|
||||
if (key == ".name" and string.gmatch(value, "^nextnode[46]")) then
|
||||
uci:delete("dhcp", value)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
for i, name in ipairs(next_node.name or {}) do
|
||||
set_dns_record(name, next_node.ip4, 'nextnode4_' .. i)
|
||||
set_dns_record(name, next_node.ip6, 'nextnode6_' .. i)
|
||||
end
|
||||
|
||||
uci:save('dhcp')
|
||||
|
Loading…
Reference in New Issue
Block a user