MiniDLNA update: 1.0.19.1 to 1.0.20
[tomato.git] / release / src / router / www / nas-bittorrent.asp
blob26c18b7c464ee6ef1910d2e573c69793e6246147
1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN'>
2 <!--
3 Tomato RAF Transmission GUI
4 Copyright (C) 2007-2011 Shibby
5 http://openlinksys.info
6 For use with Tomato RAF Firmware only.
7 No part of this file may be used without permission.
8 -->
9 <html>
10 <head>
11 <meta http-equiv='content-type' content='text/html;charset=utf-8'>
12 <meta name='robots' content='noindex,nofollow'>
13 <title>[<% ident(); %>] Nas: BitTorrent Client</title>
14 <link rel='stylesheet' type='text/css' href='tomato.css'>
15 <link rel='stylesheet' type='text/css' href='<% nv('web_css'); %>.css'>
16 <script type='text/javascript' src='tomato.js'></script>
17 <style type='text/css'>
18 textarea {
19 width: 98%;
20 height: 15em;
22 </style>
23 <script type='text/javascript'>
24 // <% nvram("bt_enable,bt_binary,bt_binary_custom,bt_custom,bt_port,bt_dir,bt_settings,bt_settings_custom,bt_incomplete,bt_rpc_enable,bt_rpc_wan,bt_auth,bt_login,bt_password,bt_port_gui,bt_dl_enable,bt_dl,bt_ul_enable,bt_ul,bt_peer_limit_global,bt_peer_limit_per_torrent,bt_ul_slot_per_torrent,bt_ratio_enable,bt_ratio,bt_dht,bt_pex,bt_blocklist,bt_blocklist_url,bt_sleep,bt_check,bt_queue,bt_maxdown,bt_maxactive"); %>
26 var btgui_link = '&nbsp;&nbsp;<a href="http://' + location.hostname +':<% nv('bt_port_gui'); %>" target="_blank"><i>[Click here to open Transmission GUI]</i></a>';
28 function verifyFields(focused, quiet)
30 var ok = 1;
31 var s;
33 var a = E('_f_bt_enable').checked;
34 var c = E('_f_bt_rpc_enable').checked;
35 var d = E('_f_bt_dl_enable').checked;
36 var e = E('_f_bt_ul_enable').checked;
37 var g = E('_f_bt_ratio_enable').checked;
38 var h = E('_f_bt_auth').checked;
39 var i = E('_f_bt_blocklist').checked;
40 var j = E('_f_bt_queue').checked;
42 E('_bt_custom').disabled = !a;
43 E('_bt_binary').disabled = !a;
44 E('_bt_dir').disabled = !a;
45 E('_bt_port').disabled = !a;
46 E('_bt_sleep').disabled = !a;
47 E('_f_bt_incomplete').disabled = !a;
48 E('_f_bt_check').disabled = !a;
49 E('_bt_settings').disabled = !a;
50 E('_f_bt_rpc_enable').disabled = !a;
51 E('_bt_port_gui').disabled = !a || !c;
52 E('_f_bt_auth').disabled = !a || !c;
53 E('_bt_login').disabled = !a || !c || !h;
54 E('_bt_password').disabled = !a || !c | !h;
55 E('_f_bt_rpc_wan').disabled = !a || !c || !h;
56 E('_f_bt_dl_enable').disabled = !a;
57 E('_bt_dl').disabled = !a || !d;
58 E('_f_bt_ul_enable').disabled = !a;
59 E('_bt_ul').disabled = !a || !e;
60 E('_bt_peer_limit_global').disabled = !a;
61 E('_bt_peer_limit_per_torrent').disabled = !a;
62 E('_bt_ul_slot_per_torrent').disabled = !a;
63 E('_f_bt_ratio_enable').disabled = !a;
64 E('_bt_ratio').disabled = !a || !g;
65 E('_f_bt_dht').disabled = !a;
66 E('_f_bt_pex').disabled = !a;
67 E('_f_bt_blocklist').disabled = !a;
68 E('_bt_blocklist_url').disabled = !a || !i;
69 E('_f_bt_queue').disabled = !a;
70 E('_bt_maxdown').disabled = !a || !j;
71 E('_bt_maxactive').disabled = !a || !j;
73 var k = (E('_bt_settings').value == 'custom');
74 elem.display('_bt_settings_custom', k && a);
76 var l = (E('_bt_binary').value == 'custom');
77 elem.display('_bt_binary_custom', l && a);
79 if (!v_length('_bt_custom', quiet, 0, 2048)) ok = 0;
81 s = E('_bt_custom');
82 if (s.value.search(/"rpc-enable":/) == 0) {
83 ferror.set(s, 'Cannot set "rpc-enable" option here. You can set it in Tomato GUI', quiet);
84 ok = 0; }
86 if (s.value.search(/"peer-port":/) == 0) {
87 ferror.set(s, 'Cannot set "peer-port" option here. You can set it in Tomato GUI', quiet);
88 ok = 0; }
90 if (s.value.search(/"speed-limit-down-enabled":/) == 0) {
91 ferror.set(s, 'Cannot set "speed-limit-down-enabled" option here. You can set it in Tomato GUI', quiet);
92 ok = 0; }
94 if (s.value.search(/"speed-limit-up-enabled":/) == 0) {
95 ferror.set(s, 'Cannot set "speed-limit-up-enabled" option here. You can set it in Tomato GUI', quiet);
96 ok = 0; }
98 if (s.value.search(/"speed-limit-down":/) == 0) {
99 ferror.set(s, 'Cannot set "speed-limit-down" option here. You can set it in Tomato GUI', quiet);
100 ok = 0; }
102 if (s.value.search(/"speed-limit-up":/) == 0) {
103 ferror.set(s, 'Cannot set "speed-limit-up" option here. You can set it in Tomato GUI', quiet);
104 ok = 0; }
106 if (s.value.search(/"rpc-port":/) == 0) {
107 ferror.set(s, 'Cannot set "rpc-port" option here. You can set it in Tomato GUI', quiet);
108 ok = 0; }
110 if (s.value.search(/"rpc-whitelist-enabled":/) == 0) {
111 ferror.set(s, 'Cannot set "rpc-whitelist-enabled" option here. Whitelist is always disabled', quiet);
112 ok = 0; }
114 if (s.value.search(/"rpc-username":/) == 0) {
115 ferror.set(s, 'Cannot set "rpc-username" option here. You can set it in Tomato GUI', quiet);
116 ok = 0; }
118 if (s.value.search(/"rpc-password":/) == 0) {
119 ferror.set(s, 'Cannot set "rpc-password" option here. You can set it in Tomato GUI', quiet);
120 ok = 0; }
122 if (s.value.search(/"download-dir":/) == 0) {
123 ferror.set(s, 'Cannot set "download-dir" option here. You can set it in Tomato GUI', quiet);
124 ok = 0; }
126 if (s.value.search(/"incomplete-dir-enabled":/) == 0) {
127 ferror.set(s, 'Cannot set "incomplete-dir-enabled" option here. You can set it in Tomato GUI', quiet);
128 ok = 0; }
130 if (s.value.search(/"incomplete-dir":/) == 0) {
131 ferror.set(s, 'Cannot set "incomplete-dir" option here. If incomplete dir is enabled, all incomplete files will be downloaded to "/download_dir/.incomplete" directory.', quiet);
132 ok = 0; }
134 if (s.value.search(/"peer-limit-global":/) == 0) {
135 ferror.set(s, 'Cannot set "peer-limit-global" option here. You can set it in Tomato GUI', quiet);
136 ok = 0; }
138 if (s.value.search(/"peer-limit-per-torrent":/) == 0) {
139 ferror.set(s, 'Cannot set "peer-limit-per-torrent" option here. You can set it in Tomato GUI', quiet);
140 ok = 0; }
142 if (s.value.search(/"upload-slots-per-torrent":/) == 0) {
143 ferror.set(s, 'Cannot set "upload-slots-per-torrent" option here. You can set it in Tomato GUI', quiet);
144 ok = 0; }
146 if (s.value.search(/"dht-enabled":/) == 0) {
147 ferror.set(s, 'Cannot set "dht-enabled" option here. You can set it in Tomato GUI', quiet);
148 ok = 0; }
150 if (s.value.search(/"pex-enabled":/) == 0) {
151 ferror.set(s, 'Cannot set "pex-enabled" option here. You can set it in Tomato GUI', quiet);
152 ok = 0; }
154 if (s.value.search(/"ratio-limit-enabled":/) == 0) {
155 ferror.set(s, 'Cannot set "ratio-limit-enabled" option here. You can set it in Tomato GUI', quiet);
156 ok = 0; }
158 if (s.value.search(/"ratio-limit":/) == 0) {
159 ferror.set(s, 'Cannot set "ratio-limit" option here. You can set it in Tomato GUI', quiet);
160 ok = 0; }
162 if (s.value.search(/"rpc-authentication-required":/) == 0) {
163 ferror.set(s, 'Cannot set "rpc-authentication-required" option here. You can set it in Tomato GUI', quiet);
164 ok = 0; }
166 if (s.value.search(/"blocklist-enabled":/) == 0) {
167 ferror.set(s, 'Cannot set "blocklist-enabled" option here. You can set it in Tomato GUI', quiet);
168 ok = 0; }
170 if (s.value.search(/"blocklist-url":/) == 0) {
171 ferror.set(s, 'Cannot set "blocklist-url" option here. You can set it in Tomato GUI', quiet);
172 ok = 0; }
174 return ok;
177 function save()
179 if (verifyFields(null, 0)==0) return;
180 var fom = E('_fom');
181 fom.bt_enable.value = E('_f_bt_enable').checked ? 1 : 0;
182 fom.bt_incomplete.value = E('_f_bt_incomplete').checked ? 1 : 0;
183 fom.bt_check.value = E('_f_bt_check').checked ? 1 : 0;
184 fom.bt_rpc_enable.value = E('_f_bt_rpc_enable').checked ? 1 : 0;
185 fom.bt_auth.value = E('_f_bt_auth').checked ? 1 : 0;
186 fom.bt_rpc_wan.value = E('_f_bt_rpc_wan').checked ? 1 : 0;
187 fom.bt_dl_enable.value = E('_f_bt_dl_enable').checked ? 1 : 0;
188 fom.bt_ul_enable.value = E('_f_bt_ul_enable').checked ? 1 : 0;
189 fom.bt_ratio_enable.value = E('_f_bt_ratio_enable').checked ? 1 : 0;
190 fom.bt_dht.value = E('_f_bt_dht').checked ? 1 : 0;
191 fom.bt_pex.value = E('_f_bt_pex').checked ? 1 : 0;
192 fom.bt_blocklist.value = E('_f_bt_blocklist').checked ? 1 : 0;
193 fom.bt_queue.value = E('_f_bt_queue').checked ? 1 : 0;
195 if (fom.bt_enable.value == 0) {
196 fom._service.value = 'bittorrent-stop';
198 else {
199 fom._service.value = 'bittorrent-restart';
201 form.submit('_fom', 1);
204 function init()
207 </script>
208 </head>
210 <body onLoad="init()">
211 <table id='container' cellspacing=0>
212 <tr><td colspan=2 id='header'>
213 <div class='title'>Tomato</div>
214 <div class='version'>Version <% version(); %></div>
215 </td></tr>
216 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
217 <td id='content'>
218 <div id='ident'><% ident(); %></div>
219 <div class='section-title'>Basic Settings</div>
220 <div class='section' id='config-section'>
221 <form id='_fom' method='post' action='tomato.cgi'>
222 <input type='hidden' name='_nextpage' value='nas-bittorrent.asp'>
223 <input type='hidden' name='_service' value='bittorrent-restart'>
224 <input type='hidden' name='bt_enable'>
225 <input type='hidden' name='bt_incomplete'>
226 <input type='hidden' name='bt_check'>
227 <input type='hidden' name='bt_rpc_enable'>
228 <input type='hidden' name='bt_auth'>
229 <input type='hidden' name='bt_rpc_wan'>
230 <input type='hidden' name='bt_dl_enable'>
231 <input type='hidden' name='bt_ul_enable'>
232 <input type='hidden' name='bt_blocklist'>
233 <input type='hidden' name='bt_ratio_enable'>
234 <input type='hidden' name='bt_dht'>
235 <input type='hidden' name='bt_pex'>
236 <input type='hidden' name='bt_queue'>
238 <script type='text/javascript'>
239 createFieldTable('', [
240 { title: 'Enable torrent client', name: 'f_bt_enable', type: 'checkbox', value: nvram.bt_enable == '1', suffix: ' <small>*</small>' },
241 { title: 'Transmission binary path', multi: [
242 { name: 'bt_binary', type: 'select', options: [
243 /* BBT-BEGIN */
244 ['internal','Internal (/usr/bin)'],
245 /* BBT-END */
246 ['optware','Optware (/opt/bin)'],
247 ['custom','Custom'] ], value: nvram.bt_binary, suffix: ' <small>*</small> ' },
248 { name: 'bt_binary_custom', type: 'text', maxlen: 40, size: 40, value: nvram.bt_binary_custom }
249 ] },
250 { title: 'Keep alive', indent: 2, name: 'f_bt_check', type: 'checkbox', value: nvram.bt_check == '1', suffix: ' <small>*</small>' },
251 { title: 'Delay at startup', indent: 2, name: 'bt_sleep', type: 'text', maxlen: 5, size: 7, value: nvram.bt_sleep, suffix: ' <small>(range: 1 - 60; default: 10 seconds)</small>' },
252 { title: 'Listening port', name: 'bt_port', type: 'text', maxlen: 5, size: 7, value: nvram.bt_port, suffix: ' <small>*</small>' },
253 { title: 'Download directory', name: 'bt_dir', type: 'text', maxlen: 40, size: 40, value: nvram.bt_dir },
254 { title: 'Use .incomplete/', indent: 2, name: 'f_bt_incomplete', type: 'checkbox', value: nvram.bt_incomplete == '1' }
256 </script>
257 </div>
258 <div>
259 <ul>
260 <li><b>Enable torrent client</b> - Attention! - If your router has only 32MB RAM, you have to use swap.
261 <li><b>Transmission binary path</b> Path to directory with transmission-daemon etc.
262 <li><b>Keep alive</b> - If enabled, transmission daemon will be checked every 5min and run after crash.
263 <li><b>Listening port</b> - Port for torrent client. Make sure port is not in use.
264 </ul>
265 <br><br>
266 </div>
267 <div class='section-title'>Remote Access<script>W(btgui_link);</script></div>
268 <div class='section'>
269 <script type='text/javascript'>
270 createFieldTable('', [
271 { title: 'Enable GUI', name: 'f_bt_rpc_enable', type: 'checkbox', value: nvram.bt_rpc_enable == '1' },
272 { title: 'Listening GUI port', indent: 2, name: 'bt_port_gui', type: 'text', maxlen: 32, size: 5, value: nvram.bt_port_gui, suffix: ' <small>*</small>' },
273 { title: 'Authentication required', name: 'f_bt_auth', type: 'checkbox', value: nvram.bt_auth == '1', suffix: ' <small>*</small>' },
274 { title: 'Username', indent: 2, name: 'bt_login', type: 'text', maxlen: 32, size: 15, value: nvram.bt_login },
275 { title: 'Password', indent: 2, name: 'bt_password', type: 'password', maxlen: 32, size: 15, value: nvram.bt_password },
276 { title: 'Allow remote access', name: 'f_bt_rpc_wan', type: 'checkbox', value: nvram.bt_rpc_wan == '1', suffix: ' <small>*</small>' }
278 </script>
279 </div>
280 <div>
281 <ul>
282 <li><b>Listening GUI port</b> - Port for Transmission GUI. Make sure port is not in use.
283 <li><b>Authentication required</b> - Authentication is <b><i>highly recomended</i></b>.
284 <li><b>Allow remote access</b> - This option will open Transmission GUI port from WAN site and allow use GUI from the internet.
285 </ul>
286 <br><br>
287 </div>
288 <div class='section-title'>Limits</div>
289 <div class='section'>
290 <script type='text/javascript'>
291 createFieldTable('', [
292 { title: 'Download limit', multi: [
293 { name: 'f_bt_dl_enable', type: 'checkbox', value: nvram.bt_dl_enable == '1', suffix: ' ' },
294 { name: 'bt_dl', type: 'text', maxlen: 10, size: 7, value: nvram.bt_dl, suffix: ' <small>kB/s</small>' } ] },
295 { title: 'Upload limit', multi: [
296 { name: 'f_bt_ul_enable', type: 'checkbox', value: nvram.bt_ul_enable == '1', suffix: ' ' },
297 { name: 'bt_ul', type: 'text', maxlen: 10, size: 7, value: nvram.bt_ul, suffix: ' <small>kB/s</small>' } ] },
298 { title: 'Ratio limit', multi: [
299 { name: 'f_bt_ratio_enable', type: 'checkbox', value: nvram.bt_ratio_enable == '1', suffix: ' ' },
300 { name: 'bt_ratio', type: 'select', options: [['0.2000','0.2'],['0.5000','0.5'],['1.0000','1.0'],['1.5000','1.5'],['2.0000','2.0'],['3.0000','3.0']], value: nvram.bt_ratio } ] },
301 { title: 'Global peer limit', name: 'bt_peer_limit_global', type: 'text', maxlen: 10, size: 7, value: nvram.bt_peer_limit_global, suffix: ' <small>(range: 10 - 500; default: 150)</small>' },
302 { title: 'Peer limit per torrent', name: 'bt_peer_limit_per_torrent', type: 'text', maxlen: 10, size: 7, value: nvram.bt_peer_limit_per_torrent, suffix: ' <small>(range: 1 - 100; default: 30)</small>' },
303 { title: 'Upload slots per torrent', name: 'bt_ul_slot_per_torrent', type: 'text', maxlen: 10, size: 7, value: nvram.bt_ul_slot_per_torrent, suffix: ' <small>(range: 1 - 50; default: 10)</small>' }
305 </script>
306 </div>
307 <div class='section-title'>Queue torrents</div>
308 <div class='section'>
309 <script type='text/javascript'>
310 createFieldTable('', [
311 { title: 'Enable queuing', name: 'f_bt_queue', type: 'checkbox', value: nvram.bt_queue == '1' },
312 { title: 'Max downloads', indent: 2, name: 'bt_maxdown', type: 'text', maxlen: 32, size: 5, value: nvram.bt_maxdown, suffix: ' <small>(range: 1 - 20; default: 2)</small>' },
313 { title: 'Max active torrents', indent: 2, name: 'bt_maxactive', type: 'text', maxlen: 32, size: 5, value: nvram.bt_maxactive, suffix: ' <small>(range: 1 - 30; default: 5)</small>' }
315 </script>
316 </div>
317 <div>
318 <ul>
319 <li><b>Max downloads</b> - This is the maximum number of torrents that you would like to have in queue for downloading.
320 <li><b>Max active torrents</b> - This is the maximum number of active torrents in your list.
321 </ul>
322 <br><br>
323 </div>
324 <div class='section-title'>Advanced Settings</div>
325 <div class='section'>
326 <script type='text/javascript'>
327 createFieldTable('', [
328 { title: 'Save settings location', multi: [
329 { name: 'bt_settings', type: 'select', options: [
330 ['down_dir','In the Download directory (Recommended)'],
331 /* JFFS2-BEGIN */
332 ['/jffs','JFFS2'],
333 /* JFFS2-END */
334 /* CIFS-BEGIN */
335 ['/cifs1','CIFS 1'],['/cifs2','CIFS 2'],
336 /* CIFS-END */
337 ['/tmp','RAM (Temporary)'], ['custom','Custom'] ], value: nvram.bt_settings, suffix: ' ' },
338 { name: 'bt_settings_custom', type: 'text', maxlen: 40, size: 40, value: nvram.bt_settings_custom }
339 ] },
340 { title: 'DHT enable', name: 'f_bt_dht', type: 'checkbox', value: nvram.bt_dht == '1' },
341 { title: 'PEX enable', name: 'f_bt_pex', type: 'checkbox', value: nvram.bt_pex == '1' },
342 { title: 'Blocklist', multi: [
343 { name: 'f_bt_blocklist', type: 'checkbox', value: nvram.bt_blocklist == '1', suffix: ' ' },
344 { name: 'bt_blocklist_url', type: 'text', maxlen: 80, size: 80, value: nvram.bt_blocklist_url }
345 ] },
346 null,
347 { title: '<a href="https://trac.transmissionbt.com/wiki/EditConfigFiles" target="_new">Transmission</a><br>Custom configuration', name: 'bt_custom', type: 'textarea', value: nvram.bt_custom }
349 </script>
350 </div>
351 </form>
352 </div>
353 </td></tr>
354 <tr><td id='footer' colspan=2>
355 <form>
356 <span id='footer-msg'></span>
357 <input type='button' value='Save' id='save-button' onclick='save()'>
358 <input type='button' value='Cancel' id='cancel-button' onclick='javascript:reloadPage();'>
359 </form>
360 </div>
361 </td></tr>
362 </table>
363 <script type='text/javascript'>verifyFields(null, 1);</script>
364 </body>
365 </html>