applications/luci-firewall: offer zone selection in redirect quickadd (#483)
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 11 Sep 2012 18:35:40 +0000 (18:35 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 11 Sep 2012 18:35:40 +0000 (18:35 +0000)
applications/luci-firewall/luasrc/model/cbi/firewall/forwards.lua
applications/luci-firewall/luasrc/view/firewall/cbi_addforward.htm

index 660848cee6392b54deb955180a5a06aa427aa174..5f7a69b255ec38f892d6bdd02ec00ea3fd9bf4e1 100644 (file)
@@ -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)
index 9b17d52e7f45093198936811cc3b03e411fd54fa..3726f643dfbd3177f40b99d15252ce9e690d95e2 100644 (file)
@@ -1,13 +1,28 @@
+<%-
+       local fw = require "luci.model.firewall".init()
+       local izl = { }
+       local ezl = { }
+       local _, z
+       for _, z in ipairs(fw:get_zones()) do
+               if z:name() ~= "wan" then
+                       izl[#izl+1] = z
+               elseif z:name() ~= "lan" then
+                       ezl[#ezl+1] = z
+               end
+       end
+-%>
 <div class="cbi-section-create cbi-tblsection-create">
        <br />
-       <table class="cbi-section-table" style="width:700px; margin-left:5px">
+       <table class="cbi-section-table" style="width:810px; margin-left:5px">
                <tr class="cbi-section-table-titles">
-                       <th class="cbi-section-table-cell" colspan="6"><%:New port forward%>:</th>
+                       <th class="cbi-section-table-cell" colspan="8"><%:New port forward%>:</th>
                </tr>
                <tr class="cbi-section-table-descr">
                        <th class="cbi-section-table-cell"><%:Name%></th>
                        <th class="cbi-section-table-cell"><%:Protocol%></th>
+                       <th class="cbi-section-table-cell"><%:External zone%></th>
                        <th class="cbi-section-table-cell"><%:External port%></th>
+                       <th class="cbi-section-table-cell"><%:Internal zone%></th>
                        <th class="cbi-section-table-cell"><%:Internal IP address%></th>
                        <th class="cbi-section-table-cell"><%:Internal port%></th>
                        <th class="cbi-section-table-cell"></th>
                                        <option value="other"><%:Other...%></option>
                                </select>
                        </td>
+                       <td class="cbi-section-table-cell" style="width:55px">
+                               <select class="cbi-input-select" id="_newfwd.extzone" name="_newfwd.extzone">
+                                       <% for _, z in ipairs(ezl) do -%><option value="<%=z:name()%>"><%=z:name()%></option><%- end %>
+                               </select>
+                       </td>
                        <td class="cbi-section-table-cell" style="width:110px">
                                <input type="text" class="cbi-input-text" id="_newfwd.extport" name="_newfwd.extport" />
                        </td>
+                       <td class="cbi-section-table-cell" style="width:55px">
+                               <select class="cbi-input-select" id="_newfwd.intzone" name="_newfwd.intzone">
+                                       <% for _, z in ipairs(izl) do -%><option value="<%=z:name()%>"><%=z:name()%></option><%- end %>
+                               </select>
+                       </td>
                        <td class="cbi-section-table-cell" style="width:110px">
                                <input type="text" class="cbi-input-text" id="_newfwd.intaddr" name="_newfwd.intaddr" />
                        </td>