X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=applications%2Fluci-firewall%2Fluasrc%2Fmodel%2Fcbi%2Ffirewall%2Fforwards.lua;h=5f7a69b255ec38f892d6bdd02ec00ea3fd9bf4e1;hp=714b08e79ce0100b52731a9323542ff447629f2b;hb=a6becaf5b5d12eedb3902e33a61540e757abafde;hpb=0f71faaf340b88f3178301a3063ab50aa39d4e8d diff --git a/applications/luci-firewall/luasrc/model/cbi/firewall/forwards.lua b/applications/luci-firewall/luasrc/model/cbi/firewall/forwards.lua index 714b08e79..5f7a69b25 100644 --- a/applications/luci-firewall/luasrc/model/cbi/firewall/forwards.lua +++ b/applications/luci-firewall/luasrc/model/cbi/firewall/forwards.lua @@ -2,6 +2,7 @@ LuCI - Lua Configuration Interface Copyright 2008 Steven Barth +Copyright 2010-2012 Jo-Philipp Wich Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -9,7 +10,6 @@ You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 -$Id$ ]]-- local ds = require "luci.dispatcher" @@ -35,7 +35,9 @@ s.template_addremove = "firewall/cbi_addforward" function s.create(self, section) local n = m:formvalue("_newfwd.name") local p = m:formvalue("_newfwd.proto") + local E = m:formvalue("_newfwd.extzone") local e = m:formvalue("_newfwd.extport") + local I = m:formvalue("_newfwd.intzone") local a = m:formvalue("_newfwd.intaddr") local i = m:formvalue("_newfwd.intport") @@ -43,8 +45,8 @@ function s.create(self, section) created = TypedSection.create(self, section) self.map:set(created, "target", "DNAT") - self.map:set(created, "src", "wan") - self.map:set(created, "dest", "lan") + self.map:set(created, "src", E or "wan") + self.map:set(created, "dest", I or "lan") self.map:set(created, "proto", (p ~= "other") and p or "all") self.map:set(created, "src_dport", e) self.map:set(created, "dest_ip", a) @@ -75,17 +77,15 @@ end ft.opt_name(s, DummyValue, translate("Name")) -proto = s:option(DummyValue, "proto", translate("Protocol")) -proto.rawhtml = true -function proto.cfgvalue(self, s) - return ft.fmt_proto(self.map:get(s, "proto")) or "Any" +local function forward_proto_txt(self, s) + return "%s-%s" %{ + translate("IPv4"), + ft.fmt_proto(self.map:get(s, "proto"), + self.map:get(s, "icmp_type")) or "TCP+UDP" + } end - -src = s:option(DummyValue, "src", translate("Source")) -src.rawhtml = true -src.width = "20%" -function src.cfgvalue(self, s) +local function forward_src_txt(self, s) local z = ft.fmt_zone(self.map:get(s, "src"), translate("any zone")) local a = ft.fmt_ip(self.map:get(s, "src_ip"), translate("any host")) local p = ft.fmt_port(self.map:get(s, "src_port")) @@ -100,23 +100,32 @@ function src.cfgvalue(self, s) end end -via = s:option(DummyValue, "via", translate("Via")) -via.rawhtml = true -via.width = "20%" -function via.cfgvalue(self, s) +local function forward_via_txt(self, s) local a = ft.fmt_ip(self.map:get(s, "src_dip"), translate("any router IP")) local p = ft.fmt_port(self.map:get(s, "src_dport")) if p then - return translatef("To %s at %s", a, p) + return translatef("Via %s at %s", a, p) else - return translatef("To %s", a) + return translatef("Via %s", a) end end -dest = s:option(DummyValue, "dest", translate("Destination")) +match = s:option(DummyValue, "match", translate("Match")) +match.rawhtml = true +match.width = "50%" +function match.cfgvalue(self, s) + return "%s
%s
%s
" % { + forward_proto_txt(self, s), + forward_src_txt(self, s), + forward_via_txt(self, s) + } +end + + +dest = s:option(DummyValue, "dest", translate("Forward to")) dest.rawhtml = true -dest.width = "30%" +dest.width = "40%" function dest.cfgvalue(self, s) local z = ft.fmt_zone(self.map:get(s, "dest"), translate("any zone")) local a = ft.fmt_ip(self.map:get(s, "dest_ip"), translate("any host")) @@ -124,9 +133,9 @@ function dest.cfgvalue(self, s) ft.fmt_port(self.map:get(s, "src_dport")) if p then - return translatef("Forward to %s, %s in %s", a, p, z) + return translatef("%s, %s in %s", a, p, z) else - return translatef("Forward to %s in %s", a, z) + return translatef("%s in %s", a, z) end end