Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 0x4A6F-master
  • 0x4A6F-rpi4
  • autinerd/experimental-openwrt-24.10
  • experimental
  • feature/addMikrotikwAP
  • master
  • nrb/airmax-test
  • nrb/ar9344-reset-sequence
  • nrb/ex400-remove-wps
  • nrb/gluon-master-cpe510
  • nrb/test-radv-filter
  • nrbffs/fastd-remove-delay
  • nrbffs/netgear-ex6120
  • v2018.2.2-ffs
  • v2018.2.3-ffs
  • v2019.1-ffs
  • v2019.1.1-ffs
  • v2019.1.2-ffs
  • v2020.1-ffs
  • v2020.1.1-ffs
  • v2020.1.3-ffs
  • v2020.2-ffs
  • v2020.2.1-ffs
  • v2020.2.2-ffs
  • v2020.2.3-ffs
  • v2021.1-ffs
  • v2021.1.1-ffs
  • v2021.1.2-ffs
  • v2022.1.1-ffs
  • v2022.1.3-ffs
  • v2022.1.4-ffs
  • v2023.1-ffs
  • v2023.2-ffs
  • v2023.2.2-ffs
  • v2023.2.3-ffs
  • v2023.2.4-ffs
  • v2023.2.5-ffs
  • experimental-2022-09-24
  • experimental-2022-09-24-base
  • experimental-2023-03-11
  • experimental-2023-03-11-base
  • experimental-2023-03-12
  • experimental-2023-03-12-base
  • experimental-2023-03-16
  • experimental-2023-03-16-base
  • experimental-2023-03-20
  • experimental-2023-03-20-base
  • experimental-2023-03-23
  • experimental-2023-03-23-base
  • experimental-2023-03-25
  • experimental-2023-03-25-base
  • experimental-2023-03-26
  • experimental-2023-03-26-base
  • experimental-2023-03-30
  • experimental-2023-03-30-base
  • experimental-2023-03-31
  • experimental-2023-03-31-base
  • experimental-2023-04-01
  • experimental-2023-04-01-base
  • experimental-2023-04-08
  • experimental-2023-04-08-base
  • experimental-2023-04-10
  • experimental-2023-04-10-base
  • experimental-2023-04-13
  • experimental-2023-04-13-base
  • experimental-2023-04-15
  • experimental-2023-04-15-base
  • experimental-2023-04-16
  • experimental-2023-04-16-base
  • experimental-2023-04-18
  • experimental-2023-04-18-base
  • experimental-2023-04-20
  • experimental-2023-04-20-base
  • experimental-2023-04-26
  • experimental-2023-04-26-base
  • experimental-2023-04-28
  • experimental-2023-04-28-base
  • experimental-2023-04-30
  • experimental-2023-04-30-base
  • experimental-2023-05-02
  • experimental-2023-05-02-base
  • experimental-2023-05-03
  • experimental-2023-05-03-base
  • experimental-2023-05-12
  • experimental-2023-05-12-base
  • experimental-2023-05-21
  • experimental-2023-05-21-base
  • experimental-2023-05-25
  • experimental-2023-05-25-base
  • experimental-2023-07-02
  • experimental-2023-07-02-base
  • experimental-2023-07-04
  • experimental-2023-07-04-base
  • experimental-2023-07-12
  • experimental-2023-07-12-base
  • experimental-2023-07-16
  • experimental-2023-07-16-base
  • experimental-2023-08-04
  • experimental-2023-08-04-base
  • experimental-2023-08-10
  • experimental-2023-08-10-base
  • experimental-2023-09-08
  • experimental-2023-09-08-base
  • experimental-2023-09-09
  • experimental-2023-09-09-base
  • experimental-2023-09-10
  • experimental-2023-09-10-base
  • experimental-2023-09-11
  • experimental-2023-09-11-base
  • experimental-2023-09-12
  • experimental-2023-09-12-base
  • experimental-2023-09-13
  • experimental-2023-09-13-base
  • experimental-2023-09-15
  • experimental-2023-09-15-base
  • experimental-2023-09-16
  • experimental-2023-09-16-base
  • experimental-2023-09-18
  • experimental-2023-09-18-base
  • experimental-2023-09-20
  • experimental-2023-09-20-base
  • experimental-2023-09-27
  • experimental-2023-09-27-base
  • experimental-2023-09-28
  • experimental-2023-09-28-base
  • experimental-2023-09-29
  • experimental-2023-09-29-base
  • experimental-2023-10-02
  • experimental-2023-10-02-base
  • experimental-2023-10-13
  • experimental-2023-10-13-base
  • experimental-2023-10-14
  • experimental-2023-10-14-base
  • experimental-2023-10-16
  • experimental-2023-10-16-base
  • experimental-2023-10-23
  • experimental-2023-10-23-base
137 results

Target

Select target project
  • firmware/gluon
  • 0x4A6F/gluon
  • patrick/gluon
3 results
Select Git revision
  • 0x4A6F-master
  • 0x4A6F-rpi4
  • 2014.3.x
  • 2014.4.x
  • babel
  • experimental
  • hoodselector
  • master
  • nrb/gluon-master-cpe510
  • nrb/test-radv-filter
  • nrbffs/fastd-remove-delay
  • nrbffs/netgear-ex6120
  • radv-filterd
  • v2015.1.x
  • v2016.1.x
  • v2016.2.4-batmanbug
  • v2016.2.x
  • v2018.2.2-ffs
  • v2018.2.3-ffs
  • v2018.2.x
  • v2019.1-ffs
  • v2019.1.1-ffs
  • v2019.1.2-ffs
  • v2020.1-ffs
  • v2020.1.1-ffs
  • v2020.1.3-ffs
  • v2020.2-ffs
  • v2020.2.1-ffs
  • v2020.2.2-ffs
  • v2020.2.3-ffs
  • v2020.2.x
  • v2021.1-ffs
  • v2021.1.1-ffs
  • v2021.1.2-ffs
  • v2014.1
  • v2014.2
  • v2014.3
  • v2014.3.1
  • v2014.4
  • v2015.1
  • v2015.1.1
  • v2015.1.2
  • v2016.1
  • v2016.1.1
  • v2016.1.2
  • v2016.1.3
  • v2016.1.4
  • v2016.1.5
  • v2016.1.6
  • v2016.2
  • v2016.2.1
  • v2016.2.2
  • v2016.2.3
  • v2016.2.4
  • v2016.2.5
  • v2016.2.6
  • v2016.2.7
  • v2017.1
  • v2017.1.1
  • v2017.1.2
  • v2017.1.3
  • v2017.1.4
  • v2017.1.5
  • v2017.1.6
  • v2017.1.7
  • v2017.1.8
  • v2018.1
  • v2018.1.1
  • v2018.1.2
  • v2018.1.3
  • v2018.1.4
  • v2018.2
  • v2018.2-ffs0.1
  • v2018.2.1
  • v2018.2.1-ffs0.1
  • v2018.2.2-ffs0.1
  • v2018.2.3-ffs0.1
  • v2019.1-ffs0.1
  • v2019.1.1-ffs0.1
  • v2019.1.2-ffs0.1
  • v2020.1-ffs0.1
  • v2020.1.1-ffs0.1
  • v2020.1.3-ffs0.1
  • v2020.2
  • v2020.2-ffs0.1
  • v2020.2.1-ffs0.1
  • v2020.2.2-ffs0.1
  • v2020.2.3-ffs0.1
  • v2020.2.3-ffs0.2
  • v2020.2.3-ffs0.3
  • v2020.2.x-ffs0.1
  • v2021.1-ffs0.1
  • v2021.1.1-ffs0.1
  • v2021.1.1-ffs0.2
  • v2021.1.1-ffs0.3
  • v2021.1.1-ffs0.4
  • v2021.1.2-ffs0.1
  • v2021.1.2-ffs0.2
98 results
Show changes
Showing
with 592 additions and 224 deletions
#!/usr/bin/lua
local platform = require 'gluon.platform'
local uci = require('simple-uci').cursor()
local switch_vlans = {
-- device identifier, lan ports, wan ports
["ubnt,unifiac-mesh-pro"] = {"3 0t", "2 0t"},
["ubnt,unifiac-pro"] = {"2 0t", "3 0t"},
}
local board_name = platform.get_board_name()
local assignments = switch_vlans[board_name]
if not platform.match('ath79', 'generic') or not assignments then
return
end
uci:delete_all('network', 'switch_vlan')
for vlan, ports in ipairs(assignments) do
uci:section("network", "switch_vlan", nil, {
device = "switch0",
vlan = vlan,
ports = ports,
})
end
uci:save('network')
...@@ -13,6 +13,7 @@ end ...@@ -13,6 +13,7 @@ end
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local platform = require 'gluon.platform' local platform = require 'gluon.platform'
local wireless = require 'gluon.wireless'
local config = site.wifi5.outdoors('preset') local config = site.wifi5.outdoors('preset')
local outdoor local outdoor
...@@ -22,7 +23,7 @@ if sysconfig.gluon_version then ...@@ -22,7 +23,7 @@ if sysconfig.gluon_version then
outdoor = false outdoor = false
elseif config == 'preset' then elseif config == 'preset' then
-- enable outdoor mode through presets on new installs -- enable outdoor mode through presets on new installs
outdoor = platform.is_outdoor_device() and platform.device_uses_11a(uci) outdoor = platform.is_outdoor_device() and wireless.device_uses_11a(uci)
else else
-- enable/disable outdoor mode unconditionally on new installs -- enable/disable outdoor mode unconditionally on new installs
outdoor = config outdoor = config
......
#!/usr/bin/lua
local wireless = require 'gluon.wireless'
local uci = require('simple-uci').cursor()
local preserve_channels = wireless.preserve_channels(uci)
uci:section('gluon', 'wireless', 'wireless', {
preserve_channels = preserve_channels or false,
})
uci:save('gluon')
...@@ -38,11 +38,11 @@ if not sysconfig.gluon_version then ...@@ -38,11 +38,11 @@ if not sysconfig.gluon_version then
if radio_band_count["band24"] <= radio_band_count["band5"] then if radio_band_count["band24"] <= radio_band_count["band5"] then
-- Assign radio to 2.4GHz band -- Assign radio to 2.4GHz band
radio_band_count["band24"] = radio_band_count["band24"] + 1 radio_band_count["band24"] = radio_band_count["band24"] + 1
uci:set('wireless', radio_name, 'hwmode', '11g') uci:set('wireless', radio_name, 'band', '2g')
else else
-- Assign radio to 5GHz band -- Assign radio to 5GHz band
radio_band_count["band5"] = radio_band_count["band5"] + 1 radio_band_count["band5"] = radio_band_count["band5"] + 1
uci:set('wireless', radio_name, 'hwmode', '11a') uci:set('wireless', radio_name, 'band', '5g')
end end
end end
end) end)
...@@ -53,20 +53,20 @@ local function is_outdoor() ...@@ -53,20 +53,20 @@ local function is_outdoor()
end end
local function get_channel(radio, config) local function get_channel(radio, config)
local channel if radio.band == '5g' and is_outdoor() then
if uci:get_first('gluon-core', 'wireless', 'preserve_channels') then
-- preserved channel always wins
channel = radio.channel
elseif (radio.hwmode == '11a' or radio.hwmode == '11na') and is_outdoor() then
-- actual channel will be picked and probed from chanlist -- actual channel will be picked and probed from chanlist
channel = 'auto' return 'auto'
end end
return channel or config.channel() return config.channel()
end end
local function get_htmode(radio) local function get_htmode(radio)
if (radio.hwmode == '11a' or radio.hwmode == '11na') and is_outdoor() then if wireless.preserve_channels(uci) then
return radio.htmode
end
if radio.band == '5g' and is_outdoor() then
local outdoor_htmode = uci:get('gluon', 'wireless', 'outdoor_' .. radio['.name'] .. '_htmode') local outdoor_htmode = uci:get('gluon', 'wireless', 'outdoor_' .. radio['.name'] .. '_htmode')
if outdoor_htmode ~= nil then if outdoor_htmode ~= nil then
return outdoor_htmode return outdoor_htmode
...@@ -74,6 +74,10 @@ local function get_htmode(radio) ...@@ -74,6 +74,10 @@ local function get_htmode(radio)
end end
local phy = wireless.find_phy(radio) local phy = wireless.find_phy(radio)
if iwinfo.nl80211.hwmodelist(phy).ax then
return 'HE20'
end
if iwinfo.nl80211.hwmodelist(phy).ac then if iwinfo.nl80211.hwmodelist(phy).ac then
return 'VHT20' return 'VHT20'
end end
...@@ -82,28 +86,26 @@ local function get_htmode(radio) ...@@ -82,28 +86,26 @@ local function get_htmode(radio)
end end
local function is_disabled(name) local function is_disabled(name)
if uci:get('wireless', name) then if not uci:get('wireless', name) then
return uci:get_bool('wireless', name, 'disabled') return nil
else
return false
end end
return uci:get_bool('wireless', name, 'disabled')
end end
-- Returns the first argument that is not nil; don't call without any non-nil arguments! -- Returns the first argument that is not nil; don't call without any non-nil arguments!
local function first_non_nil(first, ...) local function first_non_nil(first, ...)
if first ~= nil then if first ~= nil then
return first return first
else
return first_non_nil(...)
end end
return first_non_nil(...)
end end
local function delete_ibss(radio_name) local function delete_ibss(radio_name)
local name = 'ibss_' .. radio_name local name = 'ibss_' .. radio_name
uci:delete('network', name)
uci:delete('network', name .. '_vlan')
uci:delete('wireless', name) uci:delete('wireless', name)
end end
...@@ -114,8 +116,6 @@ local function configure_mesh(config, radio, index, suffix, disabled) ...@@ -114,8 +116,6 @@ local function configure_mesh(config, radio, index, suffix, disabled)
local macfilter = uci:get('wireless', name, 'macfilter') local macfilter = uci:get('wireless', name, 'macfilter')
local maclist = uci:get('wireless', name, 'maclist') local maclist = uci:get('wireless', name, 'maclist')
uci:delete('network', name)
uci:delete('network', name .. '_vlan')
uci:delete('wireless', name) uci:delete('wireless', name)
if not config then if not config then
...@@ -138,6 +138,7 @@ local function configure_mesh(config, radio, index, suffix, disabled) ...@@ -138,6 +138,7 @@ local function configure_mesh(config, radio, index, suffix, disabled)
mesh_id = config.id, mesh_id = config.id,
mesh_fwding = false, mesh_fwding = false,
macaddr = macaddr, macaddr = macaddr,
basic_rate = { config.mcast_rate },
mcast_rate = config.mcast_rate, mcast_rate = config.mcast_rate,
ifname = suffix and 'mesh' .. suffix, ifname = suffix and 'mesh' .. suffix,
disabled = disabled, disabled = disabled,
...@@ -162,18 +163,33 @@ local function fixup_wan(radio, index) ...@@ -162,18 +163,33 @@ local function fixup_wan(radio, index)
uci:set('wireless', name, 'macaddr', macaddr) uci:set('wireless', name, 'macaddr', macaddr)
end end
local function configure_mesh_wireless(radio, index, config) local function configure_mesh_wireless(radio, index, config, disabled)
local radio_name = radio['.name'] local radio_name = radio['.name']
local suffix = radio_name:match('^radio(%d+)$') local suffix = radio_name:match('^radio(%d+)$')
configure_mesh(config.mesh(), radio, index, suffix, configure_mesh(config.mesh(), radio, index, suffix,
first_non_nil( first_non_nil(
disabled,
is_disabled('mesh_' .. radio_name), is_disabled('mesh_' .. radio_name),
config.mesh.disabled(false) config.mesh.disabled(false)
) )
) )
end end
local function set_channels(radio, radio_name, config)
if wireless.preserve_channels(uci) then
return
end
local channel = get_channel(radio, config)
uci:set('wireless', radio_name, 'channel', channel)
local chanlist
if radio.band == '5g' and is_outdoor() then
chanlist = config.outdoor_chanlist()
end
uci:set('wireless', radio_name, 'channels', chanlist)
end
wireless.foreach_radio(uci, function(radio, index, config) wireless.foreach_radio(uci, function(radio, index, config)
local radio_name = radio['.name'] local radio_name = radio['.name']
...@@ -189,40 +205,35 @@ wireless.foreach_radio(uci, function(radio, index, config) ...@@ -189,40 +205,35 @@ wireless.foreach_radio(uci, function(radio, index, config)
return return
end end
local channel = get_channel(radio, config)
local htmode = get_htmode(radio) local htmode = get_htmode(radio)
local beacon_interval = config.beacon_interval() local beacon_interval = config.beacon_interval()
uci:delete('wireless', radio_name, 'disabled') uci:delete('wireless', radio_name, 'disabled')
uci:set('wireless', radio_name, 'channel', channel) set_channels(radio, radio_name, config)
uci:set('wireless', radio_name, 'htmode', htmode) uci:set('wireless', radio_name, 'htmode', htmode)
uci:set('wireless', radio_name, 'country', site.regdom()) uci:set('wireless', radio_name, 'country', site.regdom())
uci:delete('wireless', radio_name, 'supported_rates') uci:delete('wireless', radio_name, 'supported_rates')
uci:delete('wireless', radio_name, 'basic_rate') uci:delete('wireless', radio_name, 'basic_rate')
local hwmode = radio.hwmode local band = radio.band
if hwmode == '11g' or hwmode == '11ng' then if band == '2g' then
uci:set('wireless', radio_name, 'legacy_rates', false) uci:set('wireless', radio_name, 'legacy_rates', false)
configure_mesh_wireless(radio, index, config) configure_mesh_wireless(radio, index, config)
elseif (hwmode == '11a' or hwmode == '11na') then elseif (band == '5g') then
if is_outdoor() then -- ToDo: Remove in v2024.x
uci:set('wireless', radio_name, 'channels', config.outdoor_chanlist())
-- enforce outdoor channels by filtering the regdom for outdoor channels
local hostapd_options = uci:get_list('wireless', radio_name, 'hostapd_options')
util.add_to_set(hostapd_options, 'country3=0x4f')
uci:set_list('wireless', radio_name, 'hostapd_options', hostapd_options)
uci:delete('wireless', 'mesh_' .. radio_name)
else
uci:delete('wireless', radio_name, 'channels')
local hostapd_options = uci:get_list('wireless', radio_name, 'hostapd_options') local hostapd_options = uci:get_list('wireless', radio_name, 'hostapd_options')
util.remove_from_set(hostapd_options, 'country3=0x4f') util.remove_from_set(hostapd_options, 'country3=0x4f')
uci:set_list('wireless', radio_name, 'hostapd_options', hostapd_options) uci:set_list('wireless', radio_name, 'hostapd_options', hostapd_options)
if is_outdoor() then
-- enforce outdoor channels by filtering the regdom for outdoor channels
uci:set('wireless', radio_name, 'country3', '0x4f')
configure_mesh_wireless(radio, index, config, true)
else
uci:delete('wireless', radio_name, 'country3')
configure_mesh_wireless(radio, index, config) configure_mesh_wireless(radio, index, config)
end end
end end
...@@ -238,5 +249,10 @@ if uci:get('system', 'rssid_wlan0') then ...@@ -238,5 +249,10 @@ if uci:get('system', 'rssid_wlan0') then
uci:save('system') uci:save('system')
end end
if uci:get('system', 'rssid_wlan1') then
uci:set('system', 'rssid_wlan1', 'dev', 'mesh1')
uci:save('system')
end
uci:save('wireless') uci:save('wireless')
uci:save('network') uci:save('network')
#!/usr/bin/lua
local uci = require('simple-uci').cursor()
local platform = require 'gluon.platform'
-- This is a workaround to result in a configuration where all ports
-- on the DSA switch are connected to the same CPU interface.
--
-- See Gluon issue #3479 for details.
-- https://github.com/freifunk-gluon/gluon/issues/3479
if not platform.match('ipq806x', 'generic', {
'netgear,r7800',
'tplink,c2600',
}) then
return
end
local ports = {
'lan1',
'lan2',
'lan3',
'lan4',
'wan',
}
local cpu_conduit = 'eth0'
for _, port in ipairs(ports) do
local section_name = 'port_' .. port
uci:section('network', 'device', section_name, {
name = port,
conduit = cpu_conduit,
})
end
uci:save('network')
#!/usr/bin/lua
local site = require 'gluon.site'
local uci = require('simple-uci').cursor()
local util = require 'gluon.util'
local mesh_interfaces = util.get_role_interfaces(uci, 'mesh')
local uplink_interfaces = util.get_role_interfaces(uci, 'uplink')
local mesh_interfaces_uplink = {}
local mesh_interfaces_other = {}
for _, iface in ipairs(mesh_interfaces) do
if util.contains(uplink_interfaces, iface) then
table.insert(mesh_interfaces_uplink, iface)
else
table.insert(mesh_interfaces_other, iface)
end
end
if #mesh_interfaces_uplink > 0 then
uci:section('network', 'interface', 'mesh_uplink', {
ifname = 'br-wan',
proto = 'gluon_wired',
index = 0,
vxlan = site.mesh.vxlan(true),
})
end
if #mesh_interfaces_other > 0 then
local iftype, ifname
if #mesh_interfaces_other == 1 then
ifname = mesh_interfaces_other[1]
else
iftype = 'bridge'
ifname = mesh_interfaces_other
for _, iface in ipairs(ifname) do
uci:section('network', 'device', nil, {
name = iface,
isolate = true,
})
end
end
uci:section('network', 'interface', 'mesh_other', {
ifname = ifname,
type = iftype,
igmp_snooping = false,
proto = 'gluon_wired',
index = 4,
vxlan = site.mesh.vxlan(true),
})
end
uci:save('network')
#!/usr/bin/lua
local site = require 'gluon.site'
local uci = require('simple-uci').cursor()
uci:section('network', 'interface', 'mesh_wan', {
ifname = 'br-wan',
proto = 'gluon_wired',
index = 0,
})
local enable = site.mesh_on_wan(false)
local old_auto = uci:get('network', 'mesh_wan', 'auto')
local old_disabled = uci:get('network', 'mesh_wan', 'disabled')
if old_auto ~= nil or old_disabled ~= nil then
enable = old_auto ~= '0' and old_disabled ~= '1'
end
uci:set('network', 'mesh_wan', 'disabled', not enable)
if uci:get('network', 'mesh_wan', 'transitive') == nil then
uci:set('network', 'mesh_wan', 'transitive', true)
end
uci:delete('network', 'mesh_wan', 'auto')
uci:delete('network', 'mesh_wan', 'fixed_mtu')
uci:delete('network', 'mesh_wan', 'legacy')
uci:save('network')
#!/usr/bin/lua
local site = require 'gluon.site'
local util = require 'gluon.util'
local sysconfig = require 'gluon.sysconfig'
local uci = require('simple-uci').cursor()
if not sysconfig.lan_ifname then
os.exit(0)
end
uci:section('network', 'interface', 'mesh_lan', {
ifname = sysconfig.lan_ifname,
igmp_snooping = false,
proto = 'gluon_wired',
index = 4,
})
if sysconfig.lan_ifname:match(' ') then
uci:set('network', 'mesh_lan', 'type', 'bridge')
else
uci:delete('network', 'mesh_lan', 'type')
end
local enable = site.mesh_on_lan(false)
local old_auto = uci:get('network', 'mesh_lan', 'auto')
local old_disabled = uci:get('network', 'mesh_lan', 'disabled')
if old_auto ~= nil or old_disabled ~= nil then
enable = old_auto ~= '0' and old_disabled ~= '1'
end
if enable then
local interfaces = uci:get_list('network', 'client', 'ifname')
if interfaces then
for lanif in sysconfig.lan_ifname:gmatch('%S+') do
if util.contains(interfaces, lanif) then
enable = false
break
end
end
end
end
uci:set('network', 'mesh_lan', 'disabled', not enable)
if uci:get('network', 'mesh_lan', 'transitive') == nil then
uci:set('network', 'mesh_lan', 'transitive', true)
end
uci:delete('network', 'mesh_lan', 'auto')
uci:delete('network', 'mesh_lan', 'fixed_mtu')
uci:delete('network', 'mesh_lan', 'legacy')
uci:save('network')
#!/usr/bin/lua
local uci = require('simple-uci').cursor()
local platform = require 'gluon.platform'
if not platform.is_cellular_device() then
return
end
local function set_or_delete(package, section, option, val)
if val ~= nil and string.len(val) ~= 0 then
uci:set(package, section, option, val)
else
uci:delete(package, section, option)
end
end
local function setup_ncm_qmi(devpath, control_type, delay)
local pdptype = uci:get('gluon', 'cellular', 'pdptype')
local pincode = uci:get('gluon', 'cellular', 'pin')
local username = uci:get('gluon', 'cellular', 'username')
local password = uci:get('gluon', 'cellular', 'password')
local auth = uci:get('gluon', 'cellular', 'auth')
uci:section('network', 'interface', 'cellular', {
proto = control_type,
device = devpath,
disabled = not uci:get_bool('gluon', 'cellular', 'enabled'),
pdptype = pdptype,
peerdns = false,
apn = uci:get('gluon', 'cellular', 'apn'),
})
if pdptype ~= 'IP' then
uci:set('network', 'cellular', 'ipv6', 'auto')
else
uci:delete('network', 'cellular', 'ipv6')
end
set_or_delete('network', 'cellular', 'pincode', pincode)
set_or_delete('network', 'cellular', 'username', username)
set_or_delete('network', 'cellular', 'password', password)
set_or_delete('network', 'cellular', 'auth', auth)
set_or_delete('network', 'cellular', 'delay', delay)
end
if platform.match('ath79', 'nand', {
'glinet,gl-e750',
'glinet,gl-xe300',
}) then
setup_ncm_qmi('/dev/cdc-wdm0', 'qmi', 15)
elseif platform.match('ath79', 'nand', {
'zte,mf281',
}) then
setup_ncm_qmi('/dev/ttyACM0', 'ncm', 15)
elseif platform.match('ipq40xx', 'generic', {
'glinet,gl-ap1300',
'zte,mf289f',
}) then
setup_ncm_qmi('/dev/cdc-wdm0', 'qmi', 15)
elseif platform.match('ramips', 'mt7621', {
'wavlink,ws-wn572hp3-4g',
}) then
setup_ncm_qmi('/dev/ttyUSB2', 'ncm', 15)
elseif platform.match('ramips', 'mt76x8', {
'tplink,tl-mr6400-v5',
}) then
setup_ncm_qmi('/dev/cdc-wdm0', 'qmi', 15)
end
uci:save('network')
#!/usr/bin/lua #!/usr/bin/lua
local uci = require('simple-uci').cursor() local uci = require('simple-uci').cursor()
local platform = require 'gluon.platform'
local defaults = uci:get_first('firewall', 'defaults') local defaults = uci:get_first('firewall', 'defaults')
...@@ -16,9 +17,19 @@ local function reject_input_on_wan(zone) ...@@ -16,9 +17,19 @@ local function reject_input_on_wan(zone)
return true return true
end end
local function add_cellular_wan(zone)
if zone.name == 'wan' then
uci:set('firewall', zone['.name'], 'network', {'wan', 'wan6', 'cellular_4', 'cellular_6'})
end
end
uci:foreach('firewall', 'zone', reject_input_on_wan) uci:foreach('firewall', 'zone', reject_input_on_wan)
for _, zone in ipairs({'mesh', 'local_client', 'wired_mesh'}) do if platform.is_cellular_device() then
uci:foreach('firewall', 'zone', add_cellular_wan)
end
for _, zone in ipairs({'mesh', 'loc_client', 'wired_mesh'}) do
-- Other packages assign interfaces to these zones -- Other packages assign interfaces to these zones
uci:section('firewall', 'zone', zone, { uci:section('firewall', 'zone', zone, {
name = zone, name = zone,
...@@ -52,13 +63,10 @@ for _, zone in ipairs({'mesh', 'local_client', 'wired_mesh'}) do ...@@ -52,13 +63,10 @@ for _, zone in ipairs({'mesh', 'local_client', 'wired_mesh'}) do
family = 'ipv6', family = 'ipv6',
target = 'ACCEPT', target = 'ACCEPT',
}) })
-- Can be removed soon: was never in a release
uci:delete('firewall', zone .. '_ICMPv6_out')
end end
uci:section('firewall', 'rule', 'local_client_ICMPv4_in', { uci:section('firewall', 'rule', 'loc_client_ICMPv4_in', {
src = 'local_client', src = 'loc_client',
proto = 'icmp', proto = 'icmp',
icmp_type = { icmp_type = {
'echo-request', 'echo-request',
...@@ -67,9 +75,8 @@ uci:section('firewall', 'rule', 'local_client_ICMPv4_in', { ...@@ -67,9 +75,8 @@ uci:section('firewall', 'rule', 'local_client_ICMPv4_in', {
target = 'ACCEPT', target = 'ACCEPT',
}) })
-- allow inbound SSH from anywhere -- allow inbound SSH from anywhere
for _, zone in ipairs({ 'wan', 'local_client', 'mesh' }) do for _, zone in ipairs({ 'wan', 'loc_client', 'mesh' }) do
uci:section('firewall', 'rule', zone .. '_ssh', { uci:section('firewall', 'rule', zone .. '_ssh', {
name = zone .. '_ssh', name = zone .. '_ssh',
src = zone, src = zone,
...@@ -84,9 +91,9 @@ local wired_mesh_ifaces = {} ...@@ -84,9 +91,9 @@ local wired_mesh_ifaces = {}
uci:foreach('network', 'interface', uci:foreach('network', 'interface',
function(iface) function(iface)
-- Select all interfaces with proto gluon_wired except for -- Select all interfaces with proto gluon_wired except for
-- mesh_wan into this zone, as mesh_wan is the same -- mesh_uplink into this zone, as mesh_uplink is the same
-- interface as wan, which has its own zone -- interface as wan, which has its own zone
if iface['proto'] == 'gluon_wired' and iface['.name'] ~= 'mesh_wan' then if iface['proto'] == 'gluon_wired' and iface['.name'] ~= 'mesh_uplink' then
table.insert(wired_mesh_ifaces, iface['.name']) table.insert(wired_mesh_ifaces, iface['.name'])
end end
end end
......
#!/usr/bin/lua
local uci = require('simple-uci').cursor()
local function migrate_iface(iface)
if iface.proto ~= 'batadv' or iface.mesh ~= 'bat0' then
return
end
local s = iface['.name']
uci:set('network', s, 'proto', 'gluon_mesh')
uci:set('network', s, 'fixed_mtu', true)
if iface.mesh_no_rebroadcast then
uci:set('network', s, 'transitive', iface.mesh_no_rebroadcast)
end
uci:delete('network', s, 'mesh')
uci:delete('network', s, 'mesh_no_rebroadcast')
end
uci:foreach('network', 'interface', migrate_iface)
uci:save('network')
...@@ -12,13 +12,13 @@ uci:set('dhcp', dnsmasq, 'localise_queries', true) ...@@ -12,13 +12,13 @@ uci:set('dhcp', dnsmasq, 'localise_queries', true)
uci:set('dhcp', dnsmasq, 'localservice', false) uci:set('dhcp', dnsmasq, 'localservice', false)
uci:set('dhcp', dnsmasq, 'server', dns.servers) uci:set('dhcp', dnsmasq, 'server', dns.servers)
uci:delete('dhcp', dnsmasq, 'cachesize') uci:set('dhcp', dnsmasq, 'cachesize', dns.cacheentries)
uci:delete('firewall', 'client_dns') uci:delete('firewall', 'client_dns')
if dns.servers then if dns.servers then
-- allow inbound traffic for dns from client zone -- allow inbound traffic for dns from client zone
uci:section('firewall', 'rule', 'client_dns', { uci:section('firewall', 'rule', 'client_dns', {
src = 'local_client', src = 'loc_client',
dest_port = '53', dest_port = '53',
proto = 'tcpudp', proto = 'tcpudp',
target = 'ACCEPT', target = 'ACCEPT',
......
#!/usr/bin/lua
local uci = require('simple-uci').cursor()
for _, config in ipairs({'system', 'network'}) do
uci:foreach(config .. '_gluon-old', nil, function(s)
if s.gluon_preserve ~= '1' then return end
-- Unnamed sections can't be preserved
if s['.anonymous'] then return end
-- We don't allow overwriting existing sections
if uci:get(config, s['.name']) then return end
uci:section(config, s['.type'], s['.name'], s)
end)
uci:save(config)
end
#!/usr/bin/lua
local info = require 'gluon.info'
local values = info.get_info_pretty()
local padTo = 24
for _, value in ipairs(values) do
local labelLen = string.len(value[1]) + 1
print(value[1] .. ':' .. string.rep(' ', padTo - labelLen), value[2])
end
#!/usr/bin/lua
local unistd = require 'posix.unistd'
local function shift()
table.remove(arg, 1)
end
local reboot = true
if arg[1] == '--no-reboot' then
reboot = false
shift()
end
local setup_mode = unistd.access('/var/gluon/setup-mode') == 0
if #arg ~= 1 then
io.stderr:write('Usage: gluon-switch-domain [--no-reboot] <domain>\n')
os.exit(1)
end
local domain = arg[1]
if not unistd.access('/lib/gluon/domains/') then
io.stderr:write('This Gluon firmware does not support multiple mesh domains.\n')
os.exit(1)
end
local function domain_exists(dom)
return unistd.access('/lib/gluon/domains/' .. dom .. '.json') == 0
end
if not domain_exists(domain) then
io.stderr:write(string.format("Error: invalid mesh domain '%s'\n", domain))
os.exit(1)
end
local uci = require('simple-uci').cursor()
uci:set('gluon', 'core', 'switch_domain', domain)
uci:set('gluon', 'core', 'reconfigure', true)
uci:save('gluon')
local cmd
if setup_mode then
cmd = 'gluon-reconfigure'
elseif reboot then
uci:commit('gluon')
cmd = 'reboot'
else
cmd = 'gluon-reload'
end
unistd.execp(cmd, {[0] = cmd})
local util = require 'gluon.util'
local unistd = require 'posix.unistd'
local dirent = require 'posix.dirent'
local uci = require('simple-uci').cursor()
local M = {}
local function has_devtype(iface_dir, devtype)
return util.file_contains_line(iface_dir..'/uevent', 'DEVTYPE='..devtype)
end
local function is_physical(iface_dir)
return unistd.access(iface_dir .. '/device') == 0
end
local function is_swconfig()
local has = false
uci:foreach("network", "switch", function()
has = true
end)
uci:foreach("network", "switch_vlan", function()
has = true
end)
return has
end
local function interfaces_raw()
local eth_ifaces = {}
local ifaces_dir = '/sys/class/net/'
for iface in dirent.files(ifaces_dir) do
if iface ~= '.' and iface ~= '..' then
local iface_dir = ifaces_dir .. iface
if is_physical(iface_dir) and not has_devtype(iface_dir, 'wlan') then
table.insert(eth_ifaces, iface)
end
end
end
return eth_ifaces
end
-- In comparison to interfaces_raw, this skips non-DSA ports on DSA devices,
-- as for ex. hap ac² has a special eth0 that shouldn't be touched
function M.interfaces()
local intfs = interfaces_raw()
if M.get_switch_type() == 'dsa' then
local new_intfs = {}
for _, intf in ipairs(intfs) do
if has_devtype('/sys/class/net/' .. intf, 'dsa') then
table.insert(new_intfs, intf)
end
end
return new_intfs
end
return intfs
end
function M.is_vlan(intf)
return has_devtype('/sys/class/net/' .. intf, 'vlan')
end
function M.get_switch_type()
if is_swconfig() then
return 'swconfig'
end
for _, intf in ipairs(interfaces_raw()) do
if has_devtype('/sys/class/net/' .. intf, 'dsa') then
return 'dsa'
end
end
return 'none'
end
return M
local uci = require('simple-uci').cursor()
local pretty_hostname = require 'pretty_hostname'
local site = require 'gluon.site'
local sysconfig = require 'gluon.sysconfig'
local platform = require 'gluon.platform'
local util = require 'gluon.util'
local has_vpn, vpn = pcall(require, 'gluon.mesh-vpn')
local ethernet = require 'gluon.ethernet'
local pubkey
if has_vpn and vpn.enabled() then
local _, active_vpn = vpn.get_active_provider()
if active_vpn ~= nil then
pubkey = active_vpn.public_key()
end
end
local M = {}
function M.get_info()
local updater_enabled = uci:get_bool('autoupdater', 'settings', 'enabled')
return {
hostname = pretty_hostname.get(uci),
mac_address = sysconfig.primary_mac,
hardware_model = platform.get_model(),
gluon_version = util.trim(util.readfile('/lib/gluon/gluon-version')),
site_version = util.trim(util.readfile('/lib/gluon/site-version')),
firmware_release = util.trim(util.readfile('/lib/gluon/release')),
site = site.site_name(),
domain = uci:get('gluon', 'core', 'domain'),
public_vpn_key = pubkey,
switch_type = ethernet.get_switch_type(),
updater_branch = updater_enabled and uci:get('autoupdater', 'settings', 'branch'),
}
end
function M.get_info_pretty(i18n)
local _
if i18n then
local pkg_i18n = i18n 'gluon-core'
_ = function(s)
return pkg_i18n.translate(s)
end
else
_ = function(s)
return s
end
end
local data = M.get_info()
return {
{ _('Hostname'), data.hostname },
{ _('MAC address'), data.mac_address },
{ _('Hardware model'), data.hardware_model },
{ _('Gluon version') .. " / " .. _('Site version'), data.gluon_version .. " / " .. data.site_version },
{ _('Firmware release'), data.firmware_release },
{ _('Site'), data.site },
{ _('Domain'), data.domain or 'n/a' },
{ _('Public VPN key'), data.public_vpn_key or _('disabled') },
{ _('Switch type'), data.switch_type },
{ _('Autoupdater branch'), data.updater_branch or _('disabled') },
}
end
return M
local bit = require 'bit' local bit = require 'bit32'
local M = {} local M = {}
......
local platform_info = require 'platform_info' local platform_info = require 'platform_info'
local util = require 'gluon.util' local util = require 'gluon.util'
local wireless = require 'gluon.wireless'
local unistd = require 'posix.unistd'
local M = setmetatable({}, { local M = setmetatable({}, {
...@@ -25,85 +23,90 @@ function M.match(target, subtarget, boards) ...@@ -25,85 +23,90 @@ function M.match(target, subtarget, boards)
end end
function M.is_outdoor_device() function M.is_outdoor_device()
if M.match('ar71xx', 'generic', { if M.match('ath79', 'generic', {
'bullet-m', 'devolo,dvl1750x',
'cpe210', 'librerouter,librerouter-v1',
'cpe510', 'plasmacloud,pa300',
'wbs210', 'plasmacloud,pa300e',
'wbs510', 'tplink,cpe210-v1',
'lbe-m5', 'tplink,cpe210-v2',
'loco-m-xw', 'tplink,cpe210-v3',
'nanostation-m', 'tplink,cpe220-v3',
'nanostation-m-xw', 'tplink,cpe510-v1',
'rocket-m', 'tplink,cpe510-v2',
'rocket-m-ti', 'tplink,cpe510-v3',
'rocket-m-xw', 'tplink,cpe710-v1',
'unifi-outdoor', 'tplink,eap225-outdoor-v1',
'unifi-outdoor-plus', 'tplink,eap225-outdoor-v3',
'tplink,wbs210-v1',
'tplink,wbs210-v2',
'tplink,wbs510-v1',
'ubnt,nanobeam-ac-xc',
'ubnt,nanobeam-m5-xw',
'ubnt,nanostation-loco-m-xw',
'ubnt,nanostation-m-xw',
'ubnt,uk-ultra',
'ubnt,unifi-ap-outdoor-plus',
'ubnt,unifiac-mesh',
'ubnt,unifiac-mesh-pro',
}) then }) then
return true return true
elseif M.match('ar71xx', 'generic', {'unifiac-lite'}) and elseif M.match('ath79', 'mikrotik', {
M.get_model() == 'Ubiquiti UniFi-AC-MESH' then 'mikrotik,routerboard-wapr-2nd',
}) then
return true return true
elseif M.match('ar71xx', 'generic', {'unifiac-pro'}) and elseif M.match('ipq40xx', 'generic', {
M.get_model() == 'Ubiquiti UniFi-AC-MESH-PRO' then 'aruba,ap-365',
'plasmacloud,pa1200',
}) then
return true return true
elseif M.match('ath79', 'generic', { elseif M.match('ipq40xx', 'mikrotik', {
'devolo,dvl1750x', 'mikrotik,sxtsq-5-ac',
'tplink,cpe220-v3',
}) then }) then
return true return true
elseif M.match('ipq40xx', 'generic', {'engenius,ens620ext'}) then elseif M.match('mediatek', 'filogic', {
'cudy,ap3000outdoor-v1',
'wavlink,wl-wn573hx3',
}) then
return true return true
end
return false
end
function M.device_supports_wpa3()
-- rt2x00 crashes when enabling WPA3 personal / OWE VAP
if M.match('ramips', 'rt305x') or M.match('ramips', 'mt7620') then
return false
end
return unistd.access('/lib/gluon/features/wpa3')
end
function M.device_supports_mfp(uci) elseif M.match('ramips', 'mt7621', {
local supports_mfp = true 'wavlink,ws-wn572hp3-4g',
'zyxel,nwa55axe',
if not M.device_supports_wpa3() then }) then
return false return true
end end
uci:foreach('wireless', 'wifi-device', function(radio)
local phy = wireless.find_phy(radio)
local phypath = '/sys/kernel/debug/ieee80211/' .. phy .. '/'
if not util.file_contains_line(phypath .. 'hwflags', 'MFP_CAPABLE') then
supports_mfp = false
return false return false
end end
end)
return supports_mfp function M.is_cellular_device()
if M.match('ath79', 'nand', {
'zte,mf281',
'glinet,gl-e750',
'glinet,gl-xe300',
}) then
return true
elseif M.match('ipq40xx', 'generic', {
'glinet,gl-ap1300',
'zte,mf289f',
}) then
return true
elseif M.match('ramips', 'mt7621', {
'wavlink,ws-wn572hp3-4g',
}) then
return true
elseif M.match('ramips', 'mt76x8', {
'tplink,tl-mr6400-v5',
}) then
return true
end end
function M.device_uses_11a(uci)
local ret = false
uci:foreach('wireless', 'wifi-device', function(radio)
if radio.hwmode == '11a' or radio.hwmode == '11na' then
ret = true
return false return false
end end
end)
return ret
end
return M return M
...@@ -11,6 +11,10 @@ local function get(_, name) ...@@ -11,6 +11,10 @@ local function get(_, name)
end end
local function set(_, name, val) local function set(_, name, val)
if val == get(nil, name) then
return
end
if val then if val then
local f = io.open(sysconfigdir .. name, 'w+') local f = io.open(sysconfigdir .. name, 'w+')
f:write(val, '\n') f:write(val, '\n')
......