-
Notifications
You must be signed in to change notification settings - Fork 50
/
advanced-access.asp
220 lines (189 loc) · 6.79 KB
/
advanced-access.asp
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<!--
Tomato GUI
Copyright (C) 2006-2007 Jonathan Zarate
http://www.polarcloud.com/tomato/
For use with Tomato Firmware only.
No part of this file may be used without permission.
LAN Access admin module by Augusto Bott
--><title>LAN Access</title>
<content>
<script type="text/javascript" src="js/wireless.jsx?_http_id=<% nv(http_id); %>"></script>
<script type="text/javascript">
//<% nvram ("at_update,tomatoanon_answer,lan_ifname,lan1_ifname,lan2_ifname,lan3_ifname,lan_access");%>
var MAX_BRIDGE_ID = 3;
var la = new TomatoGrid();
la.setup = function() {
this.init('la-grid', 'sort', 50, [
{ type: 'checkbox', prefix: '<div class="centered">', suffix: '</div>', class: 'input-medium' },
{ type: 'select', options: [[0, 'LAN (br0)'],[1, 'LAN1 (br1)'],[2, 'LAN2 (br2)'],[3, 'LAN3 (br3)']], prefix: '<div class="centered">', suffix: '</div>', class: 'input-medium' },
{ type: 'text', maxlen: 32, class: 'input-medium' },
{ type: 'select', options: [[0, 'LAN (br0)'],[1, 'LAN1 (br1)'],[2, 'LAN2 (br2)'],[3, 'LAN3 (br3)']], prefix: '<div class="centered">', suffix: '</div>', class: 'input-medium' },
{ type: 'text', maxlen: 32, class: 'input-medium' },
{ type: 'text', maxlen: 32, class: 'input-medium' }]);
this.headerSet(['On', 'Src', 'Src Address', 'Dst', 'Dst Address', 'Description']);
var r = nvram.lan_access.split('>');
for (var i = 0; i < r.length; ++i) {
if(r[i].length) {
var l = r[i].split('<');
l[0] *= 1;
l[1] *= 1;
l[3] *= 1;
la.insertData(-1, [ l[0], l[1], l[2], l[3], l[4], l[5] ] );
}
}
la.recolor();
la.showNewEditor();
la.resetNewEditor();
}
la.sortCompare = function(a, b) {
var col = this.sortColumn;
var da = a.getRowData();
var db = b.getRowData();
var r;
switch (col) {
case 2: // src
case 4: // dst
r = cmpIP(da[col], db[col]);
break;
case 0: // on
case 1: // src br
case 3: // dst br
r = cmpInt(da[col], db[col]);
break;
default:
r = cmpText(da[col], db[col]);
break;
}
return this.sortAscending ? r : -r;
}
la.resetNewEditor = function() {
var f = fields.getAll(this.newEditor);
f[0].checked=true;
f[2].value='';
f[4].value='';
f[5].value='';
var total=0;
for (var i=0; i<= MAX_BRIDGE_ID; i++) {
var j = (i == 0) ? '' : i.toString();
if (nvram['lan' + j + '_ifname'].length < 1) {
f[1].options[i].disabled=true;
f[3].options[i].disabled=true;
} else {
++total;
}
}
if((f[1].selectedIndex == f[3].selectedIndex) && (total > 1)) {
while (f[1].selectedIndex == f[3].selectedIndex) {
f[3].selectedIndex = (f[3].selectedIndex%(MAX_BRIDGE_ID+1)+1);
}
}
ferror.clearAll(fields.getAll(this.newEditor));
}
la.verifyFields = function(row, quiet) {
var f = fields.getAll(row);
for (var i=0; i<= MAX_BRIDGE_ID; i++) {
var j = (i == 0) ? '' : i.toString();
if (nvram['lan' + j + '_ifname'].length < 1) {
f[1].options[i].disabled=true;
f[3].options[i].disabled=true;
}
}
if(f[1].selectedIndex == f[3].selectedIndex) {
var m = 'Source and Destination interfaces must be different';
ferror.set(f[1], m, quiet);
ferror.set(f[3], m, quiet);
return 0;
}
ferror.clear(f[1]);
ferror.clear(f[3]);
f[2].value = f[2].value.trim();
f[4].value = f[4].value.trim();
if ((f[2].value.length) && (!v_iptaddr(f[2], quiet))) return 0;
if ((f[4].value.length) && (!v_iptaddr(f[4], quiet))) return 0;
ferror.clear(f[2]);
ferror.clear(f[4]);
f[5].value = f[5].value.replace(/>/g, '_');
if (!v_nodelim(f[5], quiet, 'Description')) return 0;
return 1;
}
la.dataToView = function(data) {
return [(data[0] != 0) ? 'On' : '',
['LAN', 'LAN1', 'LAN2', 'LAN3'][data[1]],
data[2],
['LAN', 'LAN1', 'LAN2', 'LAN3'][data[3]],
data[4],
data[5] ];
}
la.dataToFieldValues = function (data) {
return [(data[0] != 0) ? 'checked' : '',
data[1],
data[2],
data[3],
data[4],
data[5] ];
}
la.fieldValuesToData = function(row) {
var f = fields.getAll(row);
return [f[0].checked ? 1 : 0,
f[1].selectedIndex,
f[2].value,
f[3].selectedIndex,
f[4].value,
f[5].value ];
}
function save()
{
if (la.isEditing()) return;
la.resetNewEditor();
var fom = E('_fom');
var ladata = la.getAllData();
var s = '';
for (var i = 0; i < ladata.length; ++i) {
s += ladata[i].join('<') + '>';
}
fom.lan_access.value = s;
form.submit(fom, 0);
}
function init() {
la.setup();
var c;
if (((c = cookie.get('advanced_access_notes_vis')) != null) && (c == '1')) toggleVisibility("notes");
}
function toggleVisibility(whichone) {
if (E('sesdiv_' + whichone).style.display == '') {
E('sesdiv_' + whichone).style.display = 'none';
E('sesdiv_' + whichone + '_showhide').innerHTML = '<i class="icon-chevron-up"></i>';
cookie.set('advanced_access_' + whichone + '_vis', 0);
} else {
E('sesdiv_' + whichone).style.display='';
E('sesdiv_' + whichone + '_showhide').innerHTML = '<i class="icon-chevron-down"></i>';
cookie.set('advanced_access_' + whichone + '_vis', 1);
}
}
</script>
<form id="_fom" method="post" action="tomato.cgi">
<input type="hidden" name="_nextpage" value="/#advanced-access.asp">
<input type="hidden" name="_nextwait" value="10">
<input type="hidden" name="_service" value="firewall-restart">
<input type="hidden" name="lan_access">
<div class="box">
<div class="heading">LAN Access Settings</div>
<div class="content">
<table class="line-table" id="la-grid"></table><br /><hr>
<h4><a href="javascript:toggleVisibility('notes');">Notes <span id="sesdiv_notes_showhide"><i class="icon-chevron-up"></i></span></a></h4>
<div class="section" id="sesdiv_notes" style="display:none">
<ul>
<li><b>Src</b> - Source LAN bridge.</li>
<li><b>Src Address</b> <i>(optional)</i> - Source address allowed. Ex: "1.2.3.4", "1.2.3.4 - 2.3.4.5", "1.2.3.0/24".</li>
<li><b>Dst</b> - Destination LAN bridge.</li>
<li><b>Dst Address</b> <i>(optional)</i> - Destination address inside the LAN.</li>
</ul>
</div>
</div>
</div>
<button type="button" value="Save" id="save-button" onclick="save()" class="btn btn-primary">Save <i class="icon-check"></i></button>
<button type="button" value="Cancel" id="cancel-button" onclick="javascript:reloadPage();" class="btn">Cancel <i class="icon-cancel"></i></button>
<span id="footer-msg" class="alert alert-warning" style="visibility: hidden;"></span>
<script type="text/javascript">init();</script>
</form>
</content>