summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-firewall/luasrc/view/firewall/cbi_addsnat.htm
blob: ce275111d877b70a8160f308481712434d2f8fdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<%
	local fw = require "luci.model.firewall".init()
	local nw = require "luci.model.network".init()
	local wz = fw:get_zone("wan")
	local lz = fw:get_zone("lan")

	local keys, vals, a, k, v = {}, {}
	for k, v in ipairs(nw:get_interfaces()) do
		for k, a in ipairs(v:ipaddrs()) do
			keys[#keys+1] = a:host():string()
			vals[#vals+1] = '%s (%s)' %{ a:host(), v:shortname() }
		end
	end
%>

<div class="cbi-section-create cbi-tblsection-create">
	<% if wz and lz then %>
		<br />
		<table class="cbi-section-table" style="width:700px; margin-left:5px">
			<tr class="cbi-section-table-titles">
				<th class="cbi-section-table-cell left" colspan="6"><%:New source NAT%>:</th>
			</tr>
			<tr class="cbi-section-table-descr">
				<th class="cbi-section-table-cell"><%:Name%></th>
				<th class="cbi-section-table-cell"><%:Source zone%></th>
				<th class="cbi-section-table-cell"><%:Destination zone%></th>
				<th class="cbi-section-table-cell"><%:To source IP%></th>
				<th class="cbi-section-table-cell"><%:To source port%></th>
				<th class="cbi-section-table-cell"></th>
			</tr>
			<tr class="cbi-section-table-row">
				<td class="cbi-section-table-cell">
					<input type="text" class="cbi-input-text" id="_newsnat.name" name="_newsnat.name" placeholder="<%:New SNAT rule%>" />
				</td>
				<td class="cbi-section-table-cell" style="width:110px">
					<select class="cbi-input-text" id="_newsnat.src" name="_newsnat.src">
						<% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
							<option<%=ifattr(v:name() == "lan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
						<%- end %>
					</select>
				</td>
				<td class="cbi-section-table-cell" style="width:110px">
					<select class="cbi-input-text" id="_newsnat.dest" name="_newsnat.dest">
						<% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
							<option<%=ifattr(v:name() == "wan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
						<%- end %>
					</select>
				</td>
				<td class="cbi-section-table-cell" style="width:110px">
					<input type="text" class="cbi-input-text" id="_newsnat.dip" name="_newsnat.dip" placeholder="<%:Do not rewrite%>" data-type="ip4addr" data-optional="true"<%=
						ifattr(#keys > 0, "data-choices", { keys, vals })
					%> />
				</td>
				<td class="cbi-section-table-cell" style="width:110px">
					<input type="text" class="cbi-input-text" id="_newsnat.dport" name="_newsnat.dport" placeholder="<%:Do not rewrite%>" data-type="portrange" data-optional="true" />
				</td>
				<td class="cbi-section-table-cell">
					<input type="submit" class="cbi-button cbi-button-link" name="_newsnat.submit" value="<%:Add and edit...%>" />
				</td>
			</tr>
		</table>
	<% else %>
		<input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />
	<% end %>
</div>