2015-08-17 22:53:40 +00:00
|
|
|
#!/usr/bin/lua
|
|
|
|
|
2016-11-30 19:29:25 +00:00
|
|
|
local site = require 'gluon.site_config'
|
2015-08-17 22:53:40 +00:00
|
|
|
local sysconfig = require 'gluon.sysconfig'
|
2017-01-17 22:57:39 +00:00
|
|
|
local util = require 'gluon.util'
|
2016-05-01 12:21:20 +00:00
|
|
|
|
2016-11-30 19:29:25 +00:00
|
|
|
local ip = require 'luci.ip'
|
2016-05-01 12:21:20 +00:00
|
|
|
local lutil = require 'luci.util'
|
2015-08-17 22:53:40 +00:00
|
|
|
local uci = require('luci.model.uci').cursor()
|
|
|
|
|
|
|
|
|
2016-11-30 19:29:25 +00:00
|
|
|
local ip4, netmask, ip6
|
|
|
|
|
|
|
|
if site.next_node.ip4 then
|
|
|
|
ip4 = site.next_node.ip4
|
|
|
|
netmask = ip.IPv4(site.prefix4):mask():string()
|
|
|
|
end
|
|
|
|
|
|
|
|
if site.next_node.ip6 then
|
|
|
|
ip6 = site.next_node.ip6 .. '/128'
|
|
|
|
end
|
|
|
|
|
2016-05-01 12:21:20 +00:00
|
|
|
uci:section('network', 'interface', 'client',
|
2016-11-30 19:29:25 +00:00
|
|
|
{
|
|
|
|
type = 'bridge',
|
|
|
|
proto = 'static',
|
|
|
|
macaddr = site.next_node.mac,
|
|
|
|
ipaddr = ip4,
|
|
|
|
netmask = netmask,
|
|
|
|
ip6addr = ip6,
|
|
|
|
}
|
2016-05-01 12:21:20 +00:00
|
|
|
)
|
2015-08-17 22:53:40 +00:00
|
|
|
|
2016-11-30 19:29:25 +00:00
|
|
|
uci:delete('network', 'client', 'reqprefix')
|
|
|
|
uci:delete('network', 'client', 'peerdns')
|
|
|
|
uci:delete('network', 'client', 'sourcefilter')
|
|
|
|
|
|
|
|
|
2017-01-17 22:57:39 +00:00
|
|
|
local interfaces = uci:get('network', 'client', 'ifname') or {}
|
2015-08-17 22:53:40 +00:00
|
|
|
|
2017-01-17 22:57:39 +00:00
|
|
|
if type(interfaces) == 'string' then
|
|
|
|
local ifname = interfaces
|
|
|
|
interfaces = {}
|
|
|
|
for iface in ifname:gmatch("[^%s]+") do
|
|
|
|
util.add_to_set(interfaces, iface)
|
2016-11-30 19:29:25 +00:00
|
|
|
end
|
2015-08-17 22:53:40 +00:00
|
|
|
end
|
|
|
|
|
2016-05-01 12:21:20 +00:00
|
|
|
if sysconfig.lan_ifname and not ifname and not uci:get_bool('network', 'mesh_lan', 'auto') then
|
2016-11-30 19:29:25 +00:00
|
|
|
for _, lanif in ipairs(lutil.split(sysconfig.lan_ifname, ' ')) do
|
2017-01-17 22:57:39 +00:00
|
|
|
util.add_to_set(interfaces, lanif)
|
2016-11-30 19:29:25 +00:00
|
|
|
end
|
2016-05-01 12:21:20 +00:00
|
|
|
end
|
|
|
|
|
2017-01-17 22:57:39 +00:00
|
|
|
uci:set_list('network', 'client', 'ifname', interfaces)
|
|
|
|
|
2016-11-30 19:29:25 +00:00
|
|
|
uci:save('network')
|
2016-05-01 12:21:20 +00:00
|
|
|
|
2015-08-17 22:53:40 +00:00
|
|
|
|
2016-11-30 19:29:25 +00:00
|
|
|
local dnsmasq = uci:get_first('dhcp', 'dnsmasq')
|
|
|
|
uci:set('dhcp', dnsmasq, 'boguspriv', 0)
|
|
|
|
uci:set('dhcp', dnsmasq, 'localise_queries', 0)
|
|
|
|
uci:set('dhcp', dnsmasq, 'rebind_protection', 0)
|
|
|
|
|
|
|
|
uci:delete('dhcp', 'client')
|
|
|
|
uci:section('dhcp', 'dhcp', 'client',
|
|
|
|
{
|
|
|
|
interface = 'client',
|
|
|
|
ignore = 1,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
uci:save('dhcp')
|