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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
'use strict';
'require view';
'require fs';
'require uci';
'require rpc';
'require form';
'require tools.widgets as widgets';
var callServiceList = rpc.declare({
object: 'service',
method: 'list',
params: [ 'name' ],
expect: { 'transmission': {} }
});
function setFlagBool(o) {
o.enabled = 'true';
o.disabled = 'false';
}
return view.extend({
load: function() {
return Promise.all([
L.resolveDefault(callServiceList('transmission')),
L.resolveDefault(fs.stat('/usr/share/transmission/web/index.html')),
uci.load('transmission')
]);
},
render: function(res) {
var port = uci.get_first('transmission', 'transmission', 'rpc_port') || '9091';
var running = Object.keys(res[0].instances || {}).length > 0;
var webinstalled = res[1] || !!uci.get_first('transmission', 'transmission', 'web_home');
var button = '';
if (running && webinstalled)
button = ' <a class="btn" href="http://' + window.location.hostname + ':' + port + '" target="_blank" rel="noreferrer noopener">' + _('Open Web Interface') + '</a>';
var m, s, o;
m = new form.Map('transmission', 'Transmission', _('Transmission daemon is a simple bittorrent client, here you can configure the settings.') + button);
s = m.section(form.TypedSection, 'transmission', _('Global settings'));
s.anonymous = true;
o = s.option(form.Flag, 'enabled', _('Enabled'));
o.rmempty = false;
o = s.option(form.Value, 'config_dir', _('Config file directory'));
o = s.option(widgets.UserSelect, 'user', _('Run daemon as user'));
o = s.option(widgets.GroupSelect, 'group', _('Run daemon as group'));
o = s.option(form.Value, 'web_home', _('Custom Web UI directory'));
s = m.section(form.TypedSection, 'transmission', _('Bandwidth settings'));
s.anonymous = true;
o = s.option(form.Flag, 'alt_speed_enabled', _('Alternative speed enabled'));
setFlagBool(o);
o = s.option(form.Value, 'alt_speed_up', _('Alternative upload speed'), 'KB/s');
o.depends('alt_speed_enabled', 'true');
o = s.option(form.Value, 'alt_speed_down', _('Alternative download speed'), 'KB/s');
o.depends('alt_speed_enabled', 'true');
o = s.option(form.Flag, 'speed_limit_down_enabled', _('Speed limit down enabled'));
setFlagBool(o);
o = s.option(form.Value, 'speed_limit_down', _('Speed limit down'), 'KB/s');
o.depends('speed_limit_down_enabled', 'true');
o = s.option(form.Flag, 'speed_limit_up_enabled', _('Speed limit up enabled'));
setFlagBool(o);
o = s.option(form.Value, 'speed_limit_up', _('Speed limit up'), 'KB/s');
o.depends('speed_limit_up_enabled', 'true');
o = s.option(form.Value, 'upload_slots_per_torrent', _('Upload slots per torrent'));
s = m.section(form.TypedSection, 'transmission', _('Blocklists'));
s.anonymous = true;
o = s.option(form.Flag, 'blocklist_enabled', _('Block list enabled'));
setFlagBool(o);
o = s.option(form.Value, 'blocklist_url', _('Blocklist URL'));
o.depends('blocklist_enabled', 'true');
o.placeholder = 'http://www.example.com/blocklist';
s = m.section(form.TypedSection, 'transmission', _('Files and Locations'));
s.anonymous = true;
s.option(form.Value, 'download_dir', _('Download directory'));
o = s.option(form.Flag, 'incomplete_dir_enabled', _('Incomplete directory enabled'));
setFlagBool(o);
o = s.option(form.Value, 'incomplete_dir', _('Incomplete directory'));
o.depends('incomplete_dir_enabled', 'true');
o = s.option(form.ListValue, 'preallocation', _('Preallocation'));
o.value('0', _('Off'));
o.value('1', _('Fast'));
o.value('2', _('Full'));
o = s.option(form.Flag, 'rename_partial_files', _('Rename partial files'));
setFlagBool(o);
o = s.option(form.Flag, 'start_added_torrents', _('Automatically start added torrents'));
setFlagBool(o);
o = s.option(form.Flag, 'trash_original_torrent_files', _('Trash original torrent files'));
setFlagBool(o);
o = s.option(form.Value, 'umask', 'umask');
o = s.option(form.Flag, 'watch_dir_enabled', _('Enable watch directory'));
setFlagBool(o);
o = s.option(form.Value, 'watch_dir', _('Watch directory'));
o.depends('watch_dir_enabled', 'true');
s = m.section(form.TypedSection, 'transmission', _('Miscellaneous'));
s.anonymous = true;
o = s.option(form.Value, 'cache_size_mb', _('Cache size in MB'));
o = s.option(form.Flag, 'dht_enabled', _('DHT enabled'));
setFlagBool(o);
o = s.option(form.ListValue, 'encryption', _('Encryption'));
o.value('0', _('Prefer unencrypted'));
o.value('1', _('Prefer encrypted'));
o.value('2', _('Require encrypted'));
o = s.option(form.Flag, 'lazy_bitfield_enabled', _('Lazy bitfield enabled'));
setFlagBool(o);
o = s.option(form.Flag, 'lpd_enabled', _('LPD enabled'));
setFlagBool(o);
o = s.option(form.ListValue, 'message_level', _('Message level'));
o.value('0', _('None'));
o.value('1', _('Error'));
o.value('2', _('Info'));
o.value('3', _('Debug'));
o = s.option(form.Flag, 'pex_enabled', _('PEX enabled'));
setFlagBool(o);
o = s.option(form.Flag, 'prefetch_enabled', _('Prefetch enabled'));
o = s.option(form.Flag, 'scrape_paused_torrents_enabled', _('Scrape paused torrents enabled'));
setFlagBool(o);
o = s.option(form.Flag, 'script_torrent_done_enabled', _('Script torrent done enabled'));
setFlagBool(o);
o = s.option(form.Value, 'script_torrent_done_filename', _('Script torrent done filename'));
o.depends('script_torrent_done_enabled', 'true');
o = s.option(form.Flag, 'utp_enabled', _('uTP enabled'));
setFlagBool(o);
s = m.section(form.TypedSection, 'transmission', _('Peer settings'));
s.anonymous = true;
o = s.option(form.Value, 'bind_address_ipv4', _('Binding address IPv4'));
o = s.option(form.Value, 'bind_address_ipv6', _('Binding address IPv6'));
o = s.option(form.Value, 'peer_congestion_algorithm', _('Peer congestion algorithm'),
_('This is documented on <a href="https://www.irif.fr/~jch/software/bittorrent/tcp-congestion-control.html" target="_blank" rel="noreferrer noopener">tcp-congestion-control</a>.'));
o = s.option(form.Value, 'peer_id_ttl_hours', _('Recycle peer id after'), _('hours'));
o = s.option(form.Value, 'peer_limit_global', _('Global peer limit'));
o = s.option(form.Value, 'peer_limit_per_torrent', _('Peer limit per torrent'));
o = s.option(form.Value, 'peer_socket_tos', _('Peer socket <abbr title="Type of Service">TOS</abbr>'));
s = m.section(form.TypedSection, 'transmission', _('Peer Port settings'));
s.anonymous = true;
o = s.option(form.Value, 'peer_port', _('Peer port'));
o = s.option(form.Flag, 'peer_port_random_on_start', _('Peer port random on start'));
setFlagBool(o);
o = s.option(form.Value, 'peer_port_random_high', _('Peer port random high'));
o.depends('peer_port_random_on_start', 'true');
o = s.option(form.Value, 'peer_port_random_low', _('Peer port random low'));
o.depends('peer_port_random_on_start', 'true');
o = s.option(form.Flag, 'port_forwarding_enabled', _('Port forwarding enabled'));
setFlagBool(o);
s = m.section(form.TypedSection, 'transmission', _('Queueing'));
s.anonymous = true;
o = s.option(form.Flag, 'download_queue_enabled', _('Download queue enabled'));
setFlagBool(o);
o = s.option(form.Flag, 'queue_stalled_enabled', _('Queue stalled enabled'));
setFlagBool(o);
o = s.option(form.Value, 'download_queue_size', _('Download queue size'));
o.depends('download_queue_enabled', 'true');
o = s.option(form.Flag, 'seed_queue_enabled', _('Seed queue enabled'));
setFlagBool(o);
o = s.option(form.Value, 'queue_stalled_minutes', _('Queue stalled minutes'));
o.depends('queue_stalled_enabled', 'true');
o = s.option(form.Value, 'seed_queue_size', _('Seed queue size'));
o.depends('seed_queue_enabled', 'true');
s = m.section(form.TypedSection, 'transmission', _('RPC settings'));
s.anonymous = true;
o = s.option(form.Flag, 'rpc_enabled', _('RPC enabled'));
setFlagBool(o);
o = s.option(form.Value, 'rpc_bind_address', _('RPC bind address'));
o.depends('rpc_enabled', 'true');
o = s.option(form.Value, 'rpc_port', _('RPC port'));
o.depends('rpc_enabled', 'true');
o = s.option(form.Value, 'rpc_url', _('RPC URL'));
o.depends('rpc_enabled', 'true');
o = s.option(form.Flag, 'rpc_host_whitelist_enabled', _('RPC host whitelist enabled'));
setFlagBool(o);
o.depends('rpc_enabled', 'true');
o = s.option(form.Value, 'rpc_host_whitelist', _('RPC host whitelist'));
o.depends('rpc_host_whitelist_enabled', 'true');
o = s.option(form.Flag, 'rpc_whitelist_enabled', _('RPC whitelist enabled'));
setFlagBool(o);
o.depends('rpc_enabled', 'true');
o = s.option(form.Value, 'rpc_whitelist', _('RPC whitelist'));
o.depends('rpc_whitelist_enabled', 'true');
o = s.option(form.Flag, 'rpc_authentication_required', _('RPC authentication required'));
setFlagBool(o);
o.depends('rpc_enabled', 'true');
o = s.option(form.Value, 'rpc_username', _('RPC username'));
o.depends('rpc_authentication_required', 'true');
o = s.option(form.Value, 'rpc_password', _('RPC password'));
o.depends('rpc_authentication_required', 'true');
o.password = true;
s = m.section(form.TypedSection, 'transmission', _('Scheduling'));
s.anonymous = true;
o = s.option(form.Flag, 'alt_speed_time_enabled', _('Alternative speed timing enabled'), _('When enabled, this will toggle the <b>alt-speed-enabled</b> setting'));
setFlagBool(o);
o = s.option(form.Value, 'alt_speed_time_begin', _('Alternative speed time begin'), _('in minutes from midnight'));
o.depends('alt_speed_time_enabled', 'true');
o = s.option(form.Value, 'alt_speed_time_end', _('Alternative speed time end'), _('in minutes from midnight'));
o.depends('alt_speed_time_enabled', 'true');
o = s.option(form.Value, 'alt_speed_time_day', _('Alternative speed time day'), _('Number/bitfield. Start with 0, then for each day you want the scheduler enabled, add a value. For Sunday - 1, Monday - 2, Tuesday - 4, Wednesday - 8, Thursday - 16, Friday - 32, Saturday - 64'));
o.depends('alt_speed_time_enabled', 'true');
o = s.option(form.Flag, 'idle_seeding_limit_enabled', _('Idle seeding limit enabled'));
setFlagBool(o);
o = s.option(form.Value, 'idle_seeding_limit', _('Idle seeding limit'));
o.depends('idle_seeding_limit_enabled', 'true');
o = s.option(form.Flag, 'ratio_limit_enabled', _('Ratio limit enabled'));
setFlagBool(o);
o = s.option(form.Value, 'ratio_limit', _('Ratio limit'));
o.depends('ratio_limit_enabled', 'true');
return m.render();
}
});
|