diff --git a/files/app/main/status/e/network.ut b/files/app/main/status/e/network.ut index 83ec33d5..211e350a 100755 --- a/files/app/main/status/e/network.ut +++ b/files/app/main/status/e/network.ut @@ -63,7 +63,6 @@ if (request.env.REQUEST_METHOD === "PUT") { configuration.setSetting("dmz_lan_mask", dmz_lan_mask); configuration.setSetting("dmz_dhcp_start", dmz_dhcp_start); configuration.setSetting("dmz_dhcp_end", dmz_dhcp_end); - configuration.setSetting("dmz_dhcp_limit", dmz_dhcp_end - dmz_dhcp_start + 1); const dhcp = configuration.getDHCP(); let f = fs.open(dhcp.aliases); if (f) { @@ -95,19 +94,31 @@ if (request.env.REQUEST_METHOD === "PUT") { } if ("lan_dhcp_netmask" in request.args) { if (match(request.args.lan_dhcp_netmask, constants.reNetmask)) { - configuration.setSetting("lan_mask", request.args.lan_dhcp_mask); + configuration.setSetting("lan_mask", request.args.lan_dhcp_netmask); } } if ("lan_dhcp_start" in request.args) { - if (match(request.args.lan_dhcp_start, /^([2-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-4])$/)) { - configuration.setSetting("dhcp_start", request.args.lan_dhcp_start); - } + configuration.setSetting("dhcp_start", request.args.lan_dhcp_start); } if ("lan_dhcp_end" in request.args) { - if (match(request.args.lan_dhcp_end, /^([2-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-4])$/)) { - configuration.setSetting("dhcp_end", request.args.lan_dhcp_end); + configuration.setSetting("dhcp_end", request.args.lan_dhcp_end); + } + if ("lan44_dhcp_ip" in request.args) { + if (match(request.args.lan44_dhcp_ip, constants.reIP)) { + configuration.setSetting("lan_ip", request.args.lan44_dhcp_ip); } } + if ("lan44_dhcp_netmask" in request.args) { + if (match(request.args.lan44_dhcp_netmask, constants.reNetmask)) { + configuration.setSetting("lan_mask", request.args.lan44_dhcp_netmask); + } + } + if ("lan44_dhcp_start" in request.args) { + configuration.setSetting("dhcp_start", request.args.lan44_dhcp_start); + } + if ("lan44_dhcp_end" in request.args) { + configuration.setSetting("dhcp_end", request.args.lan44_dhcp_end); + } if ("wan_mode" in request.args) { if (request.args.wan_mode === "0") { configuration.setSetting("wan_proto", "disabled"); @@ -175,6 +186,10 @@ if (request.env.REQUEST_METHOD === "DELETE") { } const dmz_mode = configuration.getSettingAsInt("dmz_mode", 3); const dhcp = configuration.getDHCP("nat"); +const ds = split(dhcp.start, "."); +const de = split(dhcp.end, "."); +const dhcp_start = int(ds[3]); +const dhcp_end = int(de[3]) + 256 * (de[2] - ds[2]); const wan_proto = configuration.getSettingAsString("wan_proto", "disabled"); const wan_iface = split(configuration.getSettingAsString("wan_intf", ""), "."); const wan_vlan = wan_iface[1] ? wan_iface[1] : ""; @@ -206,6 +221,7 @@ const gateway_altnet = dmz_mode === 1 ? dhcp.gateway : ""; +
DHCP Start
-
Start of the DHCP range for addresses allocate
+
Start offset from base for allocating DHCP addresses
- +
DHCP End
-
Last address of the DHCP range for addresses allocated
+
End offset from base for allocating DHCP addresses
- +
-
AltNET IP A‌ddress
-
Gateway IP a‌ddress for AltNET LAN network
+
44Net IP A‌ddress
+
Gateway IP a‌ddress for 44Net LAN network
- +
Netmask
-
Netmask for AltNET LAN network
+
Netmask for 44Net LAN network
- +
DHCP Start
-
Start of the DHCP range for addresses allocate
+
Start offset from base for allocating DHCP addresses
- +
DHCP End
-
Last address of the DHCP range for addresses allocated
+
End offset from base for allocating DHCP addresses
- +
@@ -407,7 +423,116 @@ const gateway_altnet = dmz_mode === 1 ? dhcp.gateway : ""; {{_R("dialog-footer")}} diff --git a/files/etc/config.mesh/_setup.default b/files/etc/config.mesh/_setup.default index df4691a9..26bb723b 100644 --- a/files/etc/config.mesh/_setup.default +++ b/files/etc/config.mesh/_setup.default @@ -26,12 +26,10 @@ lan_mask = 255.255.255.0 lan_dhcp = 1 dhcp_start = 5 dhcp_end = 25 -dhcp_limit = 20 dmz_mode = dmz_lan_ip = dmz_dhcp_start = dmz_dhcp_end = -dmz_dhcp_limit = dmz_lan_mask = olsrd_bridge = 0 wan_proto = dhcp diff --git a/files/usr/local/bin/aredn_init b/files/usr/local/bin/aredn_init index 5e9041c2..9bb313e4 100755 --- a/files/usr/local/bin/aredn_init +++ b/files/usr/local/bin/aredn_init @@ -202,15 +202,10 @@ end if cfg.dmz_mode == "" then local dmz_dhcp_base, net = ("1" .. decimal_to_ip((ip_to_decimal("10." .. mac2) * 8) % 0x1000000)):match("(%d+%.%d+%.%d+%.)(%d+)") net = tonumber(net) - local dmz_lan_ip = dmz_dhcp_base .. (net + 1) - local dmz_dhcp_start = net + 2 - local dmz_dhcp_limit = 5 -- dmz_mode == 3 - local dmz_dhcp_end = dmz_dhcp_start + dmz_dhcp_limit - 1 cfg.dmz_mode = 3 - cfg.dmz_dhcp_end = dmz_dhcp_end - cfg.dmz_dhcp_limit = dmz_dhcp_limit - cfg.dmz_dhcp_start = dmz_dhcp_start cfg.dmz_lan_ip = dmz_dhcp_base .. (net + 1) + cfg.dmz_dhcp_start = net + 2 + cfg.dmz_dhcp_end = net + 6 cfg.dmz_lan_mask = "255.255.255.248" end diff --git a/files/usr/local/bin/node-setup b/files/usr/local/bin/node-setup index bae12a92..2ee85a97 100755 --- a/files/usr/local/bin/node-setup +++ b/files/usr/local/bin/node-setup @@ -266,6 +266,20 @@ else deleteme.remote_log_proto = true end +-- sensible dmz_mode default +if is_null(cfg.dmz_mode) then + cfg.dmz_mode = "0" +end + +-- switch to dmz values if needed +if is_dmz_mode() then + cfg.lan_ip = cfg.dmz_lan_ip + cfg.lan_mask = cfg.dmz_lan_mask + cfg.dhcp_start = cfg.dmz_dhcp_start + cfg.dhcp_end = cfg.dmz_dhcp_end +end +cfg.dhcp_limit = cfg.dhcp_end - cfg.dhcp_start + 1 + -- verify that we have all the variables we need for file in nixio.fs.glob("/etc/config.mesh/*") do @@ -291,20 +305,6 @@ do end end --- sensible dmz_mode default -if is_null(cfg.dmz_mode) then - cfg.dmz_mode = "0" -end - --- switch to dmz values if needed -if is_dmz_mode() then - cfg.lan_ip = cfg.dmz_lan_ip - cfg.lan_mask = cfg.dmz_lan_mask - cfg.dhcp_start = cfg.dmz_dhcp_start - cfg.dhcp_end = cfg.dmz_dhcp_end - cfg.dhcp_limit = cfg.dmz_dhcp_limit -end - -- select ports and dhcp files based on mode local portfile = "/etc/config.mesh/_setup.ports" local dhcpfile = "/etc/config.mesh/_setup.dhcp" @@ -1161,10 +1161,10 @@ if nixio.fs.access("/etc/config.mesh/olsrd", "r") then if is_supernode then of:write("config Hna4\n\toption netaddr 10.0.0.0\n\toption netmask 255.0.0.0\n\n") - local altnetwork = nc:get("aredn", "@supernode[0]", "altnetwork") - local altnetmask = nc:get("aredn", "@supernode[0]", "altnetmask") - if altnetwork and altnetmask then - of:write("config Hna4\n\toption netaddr " .. altnetwork .. "\n\toption netmask " .. altnetmask .. "\n\n") + local is_44net = nc:get("aredn", "@supernode[0]", "44net") + if is_44net == "1" then + of:write("config Hna4\n\toption netaddr 44.0.0.0\n\toption netmask 255.128.0.0\n\n") + of:write("config Hna4\n\toption netaddr 44.128.0.0\n\toption netmask 255.192.0.0\n\n") end end