From c56307acc36a03966b45c55e6857d978bbac7f8c Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Tue, 27 Jan 2009 20:49:04 +0000 Subject: Add MSS Clamping option for Essentials (closes #45) Rename "MSS correction" to the correct term "MSS Clamping" in Firewall Automatically set "defaultroute" and "peerdns" when PPP is selected in Essentials --- .../admin-mini/luasrc/model/cbi/mini/network.lua | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'modules/admin-mini/luasrc') diff --git a/modules/admin-mini/luasrc/model/cbi/mini/network.lua b/modules/admin-mini/luasrc/model/cbi/mini/network.lua index d03e6a777..508bac155 100644 --- a/modules/admin-mini/luasrc/model/cbi/mini/network.lua +++ b/modules/admin-mini/luasrc/model/cbi/mini/network.lua @@ -109,6 +109,16 @@ p:value("dhcp", translate("automatic", "automatic")) if has_pppoe then p:value("pppoe", "PPPoE") end if has_pptp then p:value("pptp", "PPTP") end +function p.write(self, section, value) + -- Always set defaultroute to PPP and use remote dns + -- Overwrite a bad variable behaviour in OpenWrt + if value == "pptp" or value == "pppoe" then + self.map:set(section, "peerdns", "1") + self.map:set(section, "defaultroute", "1") + end + return ListValue.write(self, section, value) +end + if not ( has_pppoe and has_pptp ) then p.description = translate("network_interface_prereq_mini") end @@ -137,6 +147,34 @@ pwd.password = true pwd:depends("proto", "pppoe") pwd:depends("proto", "pptp") + +-- Allow user to set MSS correction here if the UCI firewall is installed +-- This cures some cancer for providers with pre-war routers +if luci.fs.access("/etc/config/firewall") then + mssfix = s:option(Flag, "_mssfix", + translate("m_n_mssfix"), translate("m_n_mssfix_desc")) + mssfix.rmempty = false + + function mssfix.cfgvalue(self) + local value + m.uci:foreach("firewall", "forwarding", function(s) + if s.src == "lan" and s.dest == "wan" then + value = s.mtu_fix + end + end) + return value + end + + function mssfix.write(self, section, value) + m.uci:foreach("firewall", "forwarding", function(s) + if s.src == "lan" and s.dest == "wan" then + m.uci:set("firewall", s[".name"], "mtu_fix", value) + m:chain("firewall") + end + end) + end +end + kea = s:option(Flag, "keepalive", translate("m_n_keepalive")) kea:depends("proto", "pppoe") kea:depends("proto", "pptp") -- cgit v1.2.3