fa036fb0f9e303a9f8a8c7fb8f92f7ec760415b8
[project/luci.git] / applications / luci-transmission / luasrc / model / cbi / transmission.lua
1 --[[
2 LuCI - Lua Configuration Interface - Transmission support
3
4 Copyright 2012 Gabor Varga <vargagab@gmail.com>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14
15 require("luci.sys")
16 require("luci.util")
17 require("luci.model.ipkg")
18
19 local uci = require "luci.model.uci".cursor()
20 local trport = uci:get_first("transmission", "transmission", "rpc_port")
21 local running = (luci.sys.call("pidof transmission-daemon > /dev/null") == 0)
22 local webinstalled = luci.model.ipkg.installed("transmission-web")
23 local button = ""
24 if running and webinstalled then
25 button = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"button\" value=\" " .. translate("Open Web Interface") .. " \" onclick=\"window.open('http://'+window.location.host+':" .. trport .. "')\"/>"
26 end
27
28 m = Map("transmission", "Transmission", translate("Transmission daemon is a simple bittorrent client, here you can configure the settings.") .. button)
29
30 s=m:section(TypedSection, "transmission", translate("Global settings"))
31 s.addremove=false
32 s.anonymous=true
33
34 enable=s:option(Flag, "enabled", translate("Enabled"))
35 enable.rmempty=false
36 config_dir=s:option(Value, "config_dir", translate("Config file directory"))
37 user=s:option(ListValue, "user", translate("Run daemon as user"))
38 local p_user
39 for _, p_user in luci.util.vspairs(luci.util.split(luci.sys.exec("cat /etc/passwd | cut -f 1 -d :"))) do
40 user:value(p_user)
41 end
42 cache_size_mb=s:option(Value, "cache_size_mb", translate("Cache size in MB"))
43
44 bandwidth=m:section(TypedSection, "transmission", translate("Bandwidth settings"))
45 bandwidth.anonymous=true
46 alt_speed_enabled=bandwidth:option(Flag, "alt_speed_enabled", translate("Alternative speed enabled"))
47 alt_speed_enabled.enabled="true"
48 alt_speed_enabled.disabled="false"
49 alt_speed_down=bandwidth:option(Value, "alt_speed_down", translate("Alternative download speed"), "KB/s")
50 alt_speed_down:depends("alt_speed_enabled", "true")
51 alt_speed_up=bandwidth:option(Value, "alt_speed_up", translate("Alternative upload speed"), "KB/s")
52 alt_speed_up:depends("alt_speed_enabled", "true")
53 speed_limit_down_enabled=bandwidth:option(Flag, "speed_limit_down_enabled", translate("Speed limit down enabled"))
54 speed_limit_down_enabled.enabled="true"
55 speed_limit_down_enabled.disabled="false"
56 speed_limit_down=bandwidth:option(Value, "speed_limit_down", translate("Speed limit down"), "KB/s")
57 speed_limit_down:depends("speed_limit_down_enabled", "true")
58 speed_limit_up_enabled=bandwidth:option(Flag, "speed_limit_up_enabled", translate("Speed limit up enabled"))
59 speed_limit_up_enabled.enabled="true"
60 speed_limit_up_enabled.disabled="false"
61 speed_limit_up=bandwidth:option(Value, "speed_limit_up", translate("Speed limit up"), "KB/s")
62 speed_limit_up:depends("speed_limit_up_enabled", "true")
63 upload_slots_per_torrent=bandwidth:option(Value, "upload_slots_per_torrent", translate("Upload slots per torrent"))
64
65 blocklists=m:section(TypedSection, "transmission", translate("Blocklists"))
66 blocklists.anonymous=true
67 blocklist_enabled=blocklists:option(Flag, "blocklist_enabled", translate("Block list enabled"))
68 blocklist_enabled.enabled="true"
69 blocklist_enabled.disabled="false"
70 blocklist_url=blocklists:option(Value, "blocklist_url", translate("Blocklist URL"))
71 blocklist_url:depends("blocklist_enabled", "true")
72
73 fileslocations=m:section(TypedSection, "transmission", translate("Files and Locations"))
74 fileslocations.anonymous=true
75 download_dir=fileslocations:option(Value, "download_dir", translate("Download directory"))
76 incomplete_dir_enabled=fileslocations:option(Flag, "incomplete_dir_enabled", translate("Incomplete directory enabled"))
77 incomplete_dir_enabled.enabled="true"
78 incomplete_dir_enabled.disabled="false"
79 incomplete_dir=fileslocations:option(Value, "incomplete_dir", translate("Incomplete directory"))
80 incomplete_dir:depends("incomplete_dir_enabled", "true")
81 preallocation=fileslocations:option(ListValue, "preallocation", translate("preallocation"))
82 preallocation:value("0", translate("Off"))
83 preallocation:value("1", translate("Fast"))
84 preallocation:value("2", translate("Full"))
85 prefetch_enabled=fileslocations:option(Flag, "prefetch_enabled", translate("Prefetch enabled"))
86 rename_partial_files=fileslocations:option(Flag, "rename_partial_files", translate("Rename partial files"))
87 rename_partial_files.enableid="true"
88 rename_partial_files.disabled="false"
89 start_added_torrents=fileslocations:option(Flag, "start_added_torrents", translate("Automatically start added torrents"))
90 start_added_torrents.enabled="true"
91 start_added_torrents.disabled="false"
92 trash_original_torrent_files=fileslocations:option(Flag, "trash_original_torrent_files", translate("Trash original torrent files"))
93 trash_original_torrent_files.enabled="true"
94 trash_original_torrent_files.disabled="false"
95 umask=fileslocations:option(Value, "umask", "umask")
96 watch_dir_enabled=fileslocations:option(Flag, "watch_dir_enabled", translate("Enable watch directory"))
97 watch_dir_enabled.enabled="true"
98 watch_dir_enabled.disabled="false"
99 watch_dir=fileslocations:option(Value, "watch_dir", translate("Watch directory"))
100 watch_dir:depends("watch_dir_enabled", "true")
101
102 misc=m:section(TypedSection, "transmission", translate("Miscellaneous"))
103 misc.anonymous=true
104 dht_enabled=misc:option(Flag, "dht_enabled", translate("DHT enabled"))
105 dht_enabled.enabled="true"
106 dht_enabled.disabled="false"
107 encryption=misc:option(ListValue, "encryption", translate("Encryption"))
108 encryption:value("0", translate("Off"))
109 encryption:value("1", translate("Preferred"))
110 encryption:value("2", translate("Forced"))
111 lazy_bitfield_enabled=misc:option(Flag, "lazy_bitfield_enabled", translate("Lazy bitfield enabled"))
112 lazy_bitfield_enabled.enabled="true"
113 lazy_bitfield_enabled.disabled="false"
114 lpd_enabled=misc:option(Flag, "lpd_enabled", translate("LPD enabled"))
115 lpd_enabled.enabled="true"
116 lpd_enabled.disabled="false"
117 message_level=misc:option(ListValue, "message_level", translate("Message level"))
118 message_level:value("0", translate("None"))
119 message_level:value("1", translate("Error"))
120 message_level:value("2", translate("Info"))
121 message_level:value("3", translate("Debug"))
122 pex_enabled=misc:option(Flag, "pex_enabled", translate("PEX enabled"))
123 pex_enabled.enabled="true"
124 pex_enabled.disabled="false"
125 script_torrent_done_enabled=misc:option(Flag, "script_torrent_done_enabled", translate("Script torrent done enabled"))
126 script_torrent_done_enabled.enabled="true"
127 script_torrent_done_enabled.disabled="false"
128 script_torrent_done_filename=misc:option(Value, "script_torrent_done_filename", translate("Script torrent done filename"))
129 script_torrent_done_filename:depends("script_torrent_done_enabled", "true")
130 idle_seeding_limit_enabled=misc:option(Flag, "idle_seeding_limit_enabled", translate("Idle seeding limit enabled"))
131 idle_seeding_limit_enabled.enabled="true"
132 idle_seeding_limit_enabled.disabled="false"
133 idle_seeding_limit=misc:option(Value, "idle_seeding_limit", translate("Idle seeding limit"))
134 idle_seeding_limit:depends("idle_seeding_limit_enabled", "true")
135 utp_enabled=misc:option(Flag, "utp_enabled", translate("uTP enabled"))
136 utp_enabled.enabled="true"
137 utp_enabled.disabled="false"
138
139 peers=m:section(TypedSection, "transmission", translate("Peer settings"))
140 peers.anonymous=true
141 bind_address_ipv4=peers:option(Value, "bind_address_ipv4", translate("Binding address IPv4"))
142 bind_address_ipv4.default="0.0.0.0"
143 bind_address_ipv6=peers:option(Value, "bind_address_ipv6", translate("Binding address IPv6"))
144 bind_address_ipv6.default="::"
145 peer_congestion_algorithm=peers:option(Value, "peer_congestion_algorithm", translate("Peer congestion algorithm"))
146 peer_limit_global=peers:option(Value, "peer_limit_global", translate("Global peer limit"))
147 peer_limit_per_torrent=peers:option(Value, "peer_limit_per_torrent", translate("Peer limit per torrent"))
148 peer_socket_tos=peers:option(Value, "peer_socket_tos", translate("Peer socket tos"))
149
150 peerport=m:section(TypedSection, "transmission", translate("Peer Port settings"))
151 peerport.anonymous=true
152 peer_port=peerport:option(Value, "peer_port", translate("Peer port"))
153 peer_port_random_on_start=peerport:option(Flag, "peer_port_random_on_start", translate("Peer port random on start"))
154 peer_port_random_on_start.enabled="true"
155 peer_port_random_on_start.disabled="false"
156 peer_port_random_high=peerport:option(Value, "peer_port_random_high", translate("Peer port random high"))
157 peer_port_random_high:depends("peer_port_random_on_start", "true")
158 peer_port_random_low=peerport:option(Value, "peer_port_random_low", translate("Peer port random low"))
159 peer_port_random_low:depends("peer_port_random_on_start", "true")
160 port_forwarding_enabled=peerport:option(Flag, "port_forwarding_enabled", translate("Port forwarding enabled"))
161 port_forwarding_enabled.enabled="true"
162 port_forwarding_enabled.disabled="false"
163
164 rpc=m:section(TypedSection, "transmission", translate("RPC settings"))
165 rpc.anonymous=true
166 rpc_enabled=rpc:option(Flag, "rpc_enabled", translate("RPC enabled"))
167 rpc_enabled.enabled="true"
168 rpc_enabled.disabled="false"
169 rpc_port=rpc:option(Value, "rpc_port", translate("RPC port"))
170 rpc_port:depends("rpc_enabled", "true")
171 rpc_bind_address=rpc:option(Value, "rpc_bind_address", translate("RPC bind address"))
172 rpc_bind_address:depends("rpc_enabled", "true")
173 rpc_url=rpc:option(Value, "rpc_url", translate("RPC URL"))
174 rpc_url:depends("rpc_enabled", "true")
175 rpc_whitelist_enabled=rpc:option(Flag, "rpc_whitelist_enabled", translate("RPC whitelist enabled"))
176 rpc_whitelist_enabled.enabled="true"
177 rpc_whitelist_enabled.disabled="false"
178 rpc_whitelist_enabled:depends("rpc_enabled", "true")
179 rpc_whitelist=rpc:option(Value, "rpc_whitelist", translate("RPC whitelist"))
180 rpc_whitelist:depends("rpc_whitelist_enabled", "true")
181 rpc_authentication_required=rpc:option(Flag, "rpc_authentication_required", translate("RPC authentication required"))
182 rpc_authentication_required.enabled="true"
183 rpc_authentication_required.disabled="false"
184 rpc_authentication_required:depends("rpc_enabled", "true")
185 rpc_username=rpc:option(Value, "rpc_username", translate("RPC username"))
186 rpc_username:depends("rpc_authentication_required", "true")
187 rpc_password=rpc:option(Value, "rpc_password", translate("RPC password"))
188 rpc_password:depends("rpc_authentication_required", "true")
189 rpc_password.password = true
190
191 scheduling=m:section(TypedSection, "transmission", translate("Scheduling"))
192 scheduling.anonymous=true
193 alt_speed_time_enabled=scheduling:option(Flag, "alt_speed_time_enabled", translate("Alternative speed timing enabled"))
194 alt_speed_time_enabled.enabled="true"
195 alt_speed_time_enabled.disabled="false"
196 alt_speed_time_enabled.default="false"
197 alt_speed_time_enabled:depends("alt_speed_enabled", "true")
198 alt_speed_time_day=scheduling:option(Value, "alt_speed_time_day", translate("Alternative speed time day"), translate("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"))
199 alt_speed_time_day:depends("alt_speed_time_enabled", "true")
200 alt_speed_time_begin=scheduling:option(Value, "alt_speed_time_begin", translate("Alternative speed time begin"), translate("in minutes from midnight"))
201 alt_speed_time_begin:depends("alt_speed_time_enabled", "true")
202 alt_speed_time_end=scheduling:option(Value, "alt_speed_time_end", translate("Alternative speed time end"), translate("in minutes from midnight"))
203 alt_speed_time_end:depends("alt_speed_time_enabled", "true")
204 ratio_limit_enabled=scheduling:option(Flag, "ratio_limit_enabled", translate("Ratio limit enabled"))
205 ratio_limit_enabled.enabled="true"
206 ratio_limit_enabled.disabled="false"
207 ratio_limit=scheduling:option(Value, "ratio_limit", translate("Ratio limit"))
208 ratio_limit:depends("ratio_limit_enabled", "true")
209
210 queueing=m:section(TypedSection, "transmission", translate("Queueing"))
211 queueing.anonymous=true
212 download_queue_enabled=queueing:option(Flag, "download_queue_enabled", translate("Download queue enabled"))
213 download_queue_enabled.enabled="true"
214 download_queue_enabled.disabled="false"
215 download_queue_size=queueing:option(Value, "download_queue_size", translate("Download queue size"))
216 download_queue_size:depends("download_queue_enabled", "true")
217 queue_stalled_enabled=queueing:option(Flag, "queue_stalled_enabled", translate("Queue stalled enabled"))
218 queue_stalled_enabled.enabled="true"
219 queue_stalled_enabled.disabled="false"
220 queue_stalled_minutes=queueing:option(Value, "queue_stalled_minutes", translate("Queue stalled minutes"))
221 queue_stalled_minutes:depends("queue_stalled_enabled", "true")
222 seed_queue_enabled=queueing:option(Flag, "seed_queue_enabled", translate("Seed queue enabled"))
223 seed_queue_enabled.enabled="true"
224 seed_queue_enabled.disabled="false"
225 seed_queue_size=queueing:option(Value, "seed_queue_size", translate("Seed queue size"))
226 seed_queue_size:depends("seed_queue_enabled", "true")
227 scrape_paused_torrents_enabled=queueing:option(Flag, "scrape_paused_torrents_enabled", translate("Scrape paused torrents enabled"))
228 scrape_paused_torrents_enabled.enabled="true"
229 scrape_paused_torrents_enabled.disabled="false"
230
231 return m