forked from Jackysi/advancedtomato-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadvanced-tor.asp
175 lines (149 loc) · 6.57 KB
/
advanced-tor.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
<!--
Tomato GUI
Copyright (C) 2007-2011 Shibby
http://openlinksys.info
For use with Tomato Firmware only.
No part of this file may be used without permission.
--><title>TOR Project</title>
<content>
<style type="text/css">
textarea {
width: 98%;
height: 15em;
}
</style>
<script type="text/javascript">
//<% nvram("tor_enable,tor_socksport,tor_transport,tor_dnsport,tor_datadir,tor_users,tor_ports,tor_ports_custom,tor_custom,tor_iface,lan_ifname,lan1_ifname,lan2_ifname,lan3_ifname"); %>
function verifyFields( focused, quiet ) {
var ok = 1;
var a = E( '_f_tor_enable' ).checked;
var o = (E( '_tor_iface' ).value == 'custom');
var p = (E( '_tor_ports' ).value == 'custom');
E( '_tor_socksport' ).disabled = !a;
E( '_tor_transport' ).disabled = !a;
E( '_tor_dnsport' ).disabled = !a;
E( '_tor_datadir' ).disabled = !a;
E( '_tor_iface' ).disabled = !a;
E( '_tor_ports' ).disabled = !a;
E( '_tor_custom' ).disabled = !a;
elem.display( '_tor_users', o && a );
elem.display( '_tor_ports_custom', p && a );
var bridge = E( '_tor_iface' );
if ( nvram.lan_ifname.length < 1 )
bridge.options[ 0 ].disabled = true;
if ( nvram.lan1_ifname.length < 1 )
bridge.options[ 1 ].disabled = true;
if ( nvram.lan2_ifname.length < 1 )
bridge.options[ 2 ].disabled = true;
if ( nvram.lan3_ifname.length < 1 )
bridge.options[ 3 ].disabled = true;
var s = E( '_tor_custom' );
if ( s.value.search( /SocksPort/ ) == 0 ) {
ferror.set( s, 'Cannot set "SocksPort" option here. You can set it in Tomato GUI', quiet );
ok = 0;
}
if ( s.value.search( /SocksBindAddress/ ) == 0 ) {
ferror.set( s, 'Cannot set "SocksBindAddress" option here.', quiet );
ok = 0;
}
if ( s.value.search( /AllowUnverifiedNodes/ ) == 0 ) {
ferror.set( s, 'Cannot set "AllowUnverifiedNodes" option here.', quiet );
ok = 0;
}
if ( s.value.search( /Log/ ) == 0 ) {
ferror.set( s, 'Cannot set "Log" option here.', quiet );
ok = 0;
}
if ( s.value.search( /DataDirectory/ ) == 0 ) {
ferror.set( s, 'Cannot set "DataDirectory" option here. You can set it in Tomato GUI', quiet );
ok = 0;
}
if ( s.value.search( /TransPort/ ) == 0 ) {
ferror.set( s, 'Cannot set "TransPort" option here. You can set it in Tomato GUI', quiet );
ok = 0;
}
if ( s.value.search( /TransListenAddress/ ) == 0 ) {
ferror.set( s, 'Cannot set "TransListenAddress" option here.', quiet );
ok = 0;
}
if ( s.value.search( /DNSPort/ ) == 0 ) {
ferror.set( s, 'Cannot set "DNSPort" option here. You can set it in Tomato GUI', quiet );
ok = 0;
}
if ( s.value.search( /DNSListenAddress/ ) == 0 ) {
ferror.set( s, 'Cannot set "DNSListenAddress" option here.', quiet );
ok = 0;
}
if ( s.value.search( /User/ ) == 0 ) {
ferror.set( s, 'Cannot set "User" option here.', quiet );
ok = 0;
}
return ok;
}
function save() {
if ( verifyFields( null, 0 ) == 0 ) return;
var fom = E( '_fom' );
fom.tor_enable.value = E( '_f_tor_enable' ).checked ? 1 : 0;
if ( fom.tor_enable.value == 0 ) {
fom._service.value = 'tor-stop';
}
else {
fom._service.value = 'tor-restart,firewall-restart';
}
form.submit( '_fom', 1 );
}
</script>
<form id="_fom" method="post" action="tomato.cgi">
<input type="hidden" name="_nextpage" value="/#advanced-tor.asp">
<input type="hidden" name="_service" value="tor-restart">
<input type='hidden' name='tor_enable'>
<div class="box">
<div class="heading">Tor Project Settings</div>
<div class="content">
<div id="tor-settings"></div><hr>
<script type="text/javascript">
$('#tor-settings').forms([
{ title: 'Enable Tor', name: 'f_tor_enable', type: 'checkbox', value: nvram.tor_enable == '1' },
null,
{ title: 'Socks Port', name: 'tor_socksport', type: 'text', maxlen: 5, size: 7, value: fixPort(nvram.tor_socksport, 9050) },
{ title: 'Trans Port', name: 'tor_transport', type: 'text', maxlen: 5, size: 7, value: fixPort(nvram.tor_transport, 9040) },
{ title: 'DNS Port', name: 'tor_dnsport', type: 'text', maxlen: 5, size: 7, value: fixPort(nvram.tor_dnsport, 9053) },
{ title: 'Data Directory', name: 'tor_datadir', type: 'text', maxlen: 24, size: 28, value: nvram.tor_datadir },
null,
{ title: 'Redirect all users from', multi: [
{ name: 'tor_iface', type: 'select', options: [
['br0','LAN (br0)'],
['br1','LAN1 (br1)'],
['br2','LAN2 (br2)'],
['br3','LAN3 (br3)'],
['custom','Selected IP`s']
], value: nvram.tor_iface },
{ name: 'tor_users', type: 'text', maxlen: 512, size: 64, value: nvram.tor_users } ] },
{ title: 'Redirect TCP Ports', multi: [
{ name: 'tor_ports', type: 'select', options: [
['80','HTTP only (TCP 80)'],
['80,443','HTTP/HTTPS (TCP 80,443)'],
['custom','Selected Ports']
], value: nvram.tor_ports },
{ name: 'tor_ports_custom', type: 'text', maxlen: 512, size: 64, value: nvram.tor_ports_custom } ] },
null,
{ title: 'Custom Configuration', name: 'tor_custom', type: 'textarea', value: nvram.tor_custom }
]);
</script>
<h4>Notes</h4>
<div class="section">
<ul>
<li><b>Enable TOR</b> - Be patient. Starting the TOR client can take from several seconds to several minutes.
<li><b>Selected IP`s</b> - ex: 1.2.3.4,1.1.0/24,1.2.3.1-1.2.3.4
<li><b>Selected Ports</b> - ex: one port (80), few ports (80,443,8888), range of ports (80:88), mix (80,8000:9000,9999)
<li><span class="text-danger">Caution!</span> If your router has only 32MB of RAM, you'll have to use swap.
</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>
</form>
<script type='text/javascript'>verifyFields(null,1);</script>
</content>