transmission.lua 13 KB

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