luci-app-qbittorrent: tidy up code (#8194)

This commit is contained in:
Beginner 2021-11-07 18:51:06 +08:00 committed by GitHub
parent 1d22d226a1
commit f0182383ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 509 additions and 448 deletions

View File

@ -5,12 +5,15 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-qbittorrent
PKG_VERSION=1.0
PKG_RELEASE:=22
PKG_RELEASE:=23
include $(INCLUDE_DIR)/package.mk
LUCI_TITLE:=LuCI support for qBittorrent
LUCI_PKGARCH:=all
LUCI_DEPENDS:= \
+PACKAGE_luci-app-qbittorrent_static:qBittorrent-static \
+PACKAGE_luci-app-qbittorrent_dynamic:qbittorrent
define Package/$(PKG_NAME)/config
choice
@ -28,10 +31,6 @@ define Package/$(PKG_NAME)/config
endchoice
endef
LUCI_TITLE:=LuCI support for qBittorrent
LUCI_DEPENDS:=+PACKAGE_luci-app-qbittorrent_static:qBittorrent-static +PACKAGE_luci-app-qbittorrent_dynamic:qbittorrent
LUCI_PKGARCH:=all
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -5,13 +5,19 @@ function index()
return
end
entry({"admin", "nas", "qBittorrent"}, cbi("qbittorrent"), _("qBittorrent"))
entry({"admin", "nas", "qBittorrent"}, alias("admin", "nas", "qBittorrent", "basic"), _("qBittorrent"), 30).dependent = true
entry({"admin", "nas", "qBittorrent", "basic"}, cbi("qbittorrent/basic"), _("Basic Settings"), 1).leaf = true
entry({"admin", "nas", "qBittorrent", "connection"}, cbi("qbittorrent/connection"), _("Connection Settings"), 2).leaf = true
entry({"admin", "nas", "qBittorrent", "downloads"}, cbi("qbittorrent/downloads"), _("Download Settings"), 3).leaf = true
entry({"admin", "nas", "qBittorrent", "bittorrent"}, cbi("qbittorrent/bittorrent"), _("Bittorrent Settings"), 4).leaf = true
entry({"admin", "nas", "qBittorrent", "webgui"}, cbi("qbittorrent/webgui"), _("WebUI Settings"), 5).leaf = true
entry({"admin", "nas", "qBittorrent", "advanced"}, cbi("qbittorrent/advanced"), _("Advance Settings"), 6).leaf = true
entry({"admin", "nas", "qBittorrent", "status"}, call("act_status")).leaf = true
end
function act_status()
local e={}
e.running=luci.sys.call("pgrep qbittorrent-nox >/dev/null")==0
local e = {}
e.running = luci.sys.call("pgrep qbittorrent-nox >/dev/null") == 0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end

View File

@ -1,371 +0,0 @@
local o=luci.sys.exec("uci get qbittorrent.main.Port | xargs echo -n") or 8080
local a=(luci.sys.call("pidof qbittorrent-nox > /dev/null")==0)
local t=""
if a then
t="<br /><br /><input class=\"cbi-button cbi-button-apply\" type=\"button\" value=\" "..translate("Open Web Interface").." \" onclick=\"window.open('//'+window.location.hostname+':"..o.."')\"/>"
end
function titlesplit(Value)
return "<p style=\"font-size:20px;font-weight:bold;color: DodgerBlue\">" .. translate(Value) .. "</p>"
end
m = Map("qbittorrent", translate("qBittorrent"), translate("qBittorrent is a cross-platform free and open-source BitTorrent client")..t)
s = m:section(NamedSection, "main", "qbittorrent")
s:tab("basic", translate("Basic Settings"))
o = s:taboption("basic", Flag, "enabled", translate("Enabled"))
o.default = "1"
o = s:taboption("basic", ListValue, "user", translate("Run daemon as user"))
local u
for u in luci.util.execi("cat /etc/passwd | cut -d ':' -f1") do
o:value(u)
end
o = s:taboption("basic", Value, "profile", translate("Store configuration files in the Path"))
o.default = '/tmp'
o = s:taboption("basic", Value, "SavePath", translate("Store download files in the Path"))
o.placeholder = "/tmp/download"
o = s:taboption("basic", Value, "Port", translate("WEBUI listening port"))
o.datatype = "port"
o.placeholder = "8080"
o = s:taboption("basic", Flag, "UseRandomPort", translate("Use Random Port"), translate("Randomly assigns a different port every time qBittorrent starts up"))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:taboption("basic", Value, "PortRangeMin", translate("Connection Port"), translate("Incoming connection port"))
o:depends("UseRandomPort", false)
o.datatype = "range(1024,65535)"
s:tab("connection", translate("Connection Settings"))
o = s:taboption("connection", Flag, "UPnP", translate("Use UPnP for Connections"), translate("Use UPnP/ NAT-PMP port forwarding from my router. Refer to the "
.. "<a href='https://en.wikipedia.org/wiki/Port_forwarding' target='_blank'>wiki</a>."))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:taboption("connection", Value, "GlobalDLLimit", translate("Global Download Speed"), translate("Global Download Speed Limit(KiB/s)."))
o.datatype = "float"
o.placeholder = "0"
o = s:taboption("connection", Value, "GlobalUPLimit", translate("Global Upload Speed"), translate("Global Upload Speed Limit(KiB/s)."))
o.datatype = "float"
o.placeholder = "0"
o = s:taboption("connection", Value, "GlobalDLLimitAlt", translate("Alternative Download Speed"), translate("Alternative Download Speed Limit(KiB/s)."))
o.datatype = "float"
o.placeholder = "10"
o = s:taboption("connection", Value, "GlobalUPLimitAlt", translate("Alternative Upload Speed"), translate("Alternative Upload Speed Limit(KiB/s)."))
o.datatype = "float"
o.placeholder = "10"
o = s:taboption("connection", ListValue, "BTProtocol", translate("Enabled protocol"), translate("The protocol that was enabled."))
o:value("Both", translate("TCP and UTP"))
o:value("TCP", translate("TCP"))
o:value("UTP", translate("UTP"))
o.default = "Both"
o = s:taboption("connection", Value, "InetAddress", translate("Inet Address"), translate("The address that respond to the trackers."))
s:tab("downloads", translate("Download Settings"))
o = s:taboption("downloads", Flag, "CreateTorrentSubfolder", translate("Create Subfolder"), translate("Create subfolder for torrents with multiple files."))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:taboption("downloads", Flag, "StartInPause", translate("Start In Pause"), translate("Do not start the download automatically."))
o.enabled = "true"
o.disabled = "false"
o.default = o.disabled
o = s:taboption("downloads", Flag, "AutoDeleteAddedTorrentFile", translate("Auto Delete Torrent File"), translate("The .torrent files will be deleted afterwards."))
o.enabled = "IfAdded"
o.disabled = "Never"
o.default = o.disabled
o = s:taboption("downloads", Flag, "PreAllocation", translate("Pre Allocation"), translate("Pre-allocate disk space for all files."))
o.enabled = "true"
o.disabled = "false"
o.default = o.disabled
o = s:taboption("downloads", Flag, "UseIncompleteExtension", translate("Use Incomplete Extension"), translate("The incomplete task will be added the extension of !qB."))
o.enabled = "true"
o.disabled = "false"
o.default = o.disabled
o = s:taboption("downloads", Flag, "TempPathEnabled", translate("Temp Path Enabled"))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:taboption("downloads", Value, "TempPath", translate("Temp Path"), translate("The absolute and relative path can be set."))
o:depends("TempPathEnabled", "true")
o.placeholder = "temp/"
o = s:taboption("downloads", Value, "DiskWriteCacheSize", translate("Disk Cache Size (MiB)"), translate("The value -1 is auto and 0 is disable. In default, it is set to 64MiB."))
o.datatype = "integer"
o.placeholder = "64"
o = s:taboption("downloads", Value, "DiskWriteCacheTTL", translate("Disk Cache TTL (s)"), translate("In default, it is set to 60s."))
o.datatype = "integer"
o.placeholder = "60"
o = s:taboption("downloads", DummyValue, "Saving Management", titlesplit("Saving Management"))
o = s:taboption("downloads", ListValue, "DisableAutoTMMByDefault", translate("Default Torrent Management Mode"))
o:value("true", translate("Manual"))
o:value("false", translate("Automaic"))
o.default = "true"
o = s:taboption("downloads", ListValue, "CategoryChanged", translate("Torrent Category Changed"), translate("Choose the action when torrent category changed."))
o:value("true", translate("Switch torrent to Manual Mode"))
o:value("false", translate("Relocate torrent"))
o.default = "false"
o = s:taboption("downloads", ListValue, "DefaultSavePathChanged", translate("Default Save Path Changed"), translate("Choose the action when default save path changed."))
o:value("true", translate("Switch affected torrent to Manual Mode"))
o:value("false", translate("Relocate affected torrent"))
o.default = "true"
o = s:taboption("downloads", ListValue, "CategorySavePathChanged", translate("Category Save Path Changed"), translate("Choose the action when category save path changed."))
o:value("true", translate("Switch affected torrent to Manual Mode"))
o:value("false", translate("Relocate affected torrent"))
o.default = "true"
o = s:taboption("downloads", Value, "TorrentExportDir", translate("Torrent Export Dir"), translate("The .torrent files will be copied to the target directory."))
o = s:taboption("downloads", Value, "FinishedTorrentExportDir", translate("Finished Torrent Export Dir"), translate("The .torrent files for finished downloads will be copied to the target directory."))
s:tab("bittorrent", translate("Bittorrent Settings"))
o = s:taboption("bittorrent", Flag, "DHT", translate("Enable DHT"), translate("Enable DHT (decentralized network) to find more peers"))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:taboption("bittorrent", Flag, "PeX", translate("Enable PeX"), translate("Enable Peer Exchange (PeX) to find more peers"))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:taboption("bittorrent", Flag, "LSD", translate("Enable LSD"), translate("Enable Local Peer Discovery to find more peers"))
o.enabled = "true"
o.disabled = "false"
o.default = o.disabled
o = s:taboption("bittorrent", Flag, "uTP_rate_limited", translate("uTP Rate Limit"), translate("Apply rate limit to μTP protocol."))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:taboption("bittorrent", ListValue, "Encryption", translate("Encryption Mode"), translate("Enable DHT (decentralized network) to find more peers"))
o:value("0", translate("Prefer Encryption"))
o:value("1", translate("Require Encryption"))
o:value("2", translate("Disable Encryption"))
o.default = "0"
o = s:taboption("bittorrent", Value, "MaxConnecs", translate("Max Connections"), translate("The max number of connections."))
o.datatype = "integer"
o.placeholder = "500"
o = s:taboption("bittorrent", Value, "MaxConnecsPerTorrent", translate("Max Connections Per Torrent"), translate("The max number of connections per torrent."))
o.datatype = "integer"
o.placeholder = "100"
o = s:taboption("bittorrent", Value, "MaxUploads", translate("Max Uploads"), translate("The max number of connected peers."))
o.datatype = "integer"
o.placeholder = "8"
o = s:taboption("bittorrent", Value, "MaxUploadsPerTorrent", translate("Max Uploads Per Torrent"), translate("The max number of connected peers per torrent."))
o.datatype = "integer"
o.placeholder = "4"
o = s:taboption("bittorrent", Value, "MaxRatio", translate("Max Ratio"), translate("The max ratio for seeding. -1 is to disable the seeding."))
o.datatype = "float"
o.placeholder = "-1"
o = s:taboption("bittorrent", ListValue, "MaxRatioAction", translate("Max Ratio Action"), translate("The action when reach the max seeding ratio."))
o:value("0", translate("Pause them"))
o:value("1", translate("Remove them"))
o.defaule = "0"
o = s:taboption("bittorrent", Value, "GlobalMaxSeedingMinutes", translate("Max Seeding Minutes"), translate("Units: minutes"))
o.datatype = "integer"
o = s:taboption("bittorrent", DummyValue, "Queueing Setting", titlesplit("Queueing Setting"))
o = s:taboption("bittorrent", Flag, "QueueingEnabled", translate("Enable Torrent Queueing"))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:taboption("bittorrent", Value, "MaxActiveDownloads", translate("Maximum Active Downloads"))
o.datatype = "integer"
o.placeholder = "3"
o = s:taboption("bittorrent", Value, "MaxActiveUploads", translate("Max Active Uploads"))
o.datatype = "integer"
o.placeholder = "3"
o = s:taboption("bittorrent", Value, "MaxActiveTorrents", translate("Max Active Torrents"))
o.datatype = "integer"
o.placeholder = "5"
o = s:taboption("bittorrent", Flag, "IgnoreSlowTorrents", translate("Ignore Slow Torrents"), translate("Do not count slow torrents in these limits."))
o.enabled = "true"
o.disabled = "false"
o.default = o.disabled
o = s:taboption("bittorrent", Value, "SlowTorrentsDownloadRate", translate("Download rate threshold"), translate("Units: KiB/s"))
o.datatype = "integer"
o.placeholder = "2"
o = s:taboption("bittorrent", Value, "SlowTorrentsUploadRate", translate("Upload rate threshold"), translate("Units: KiB/s"))
o.datatype = "integer"
o.placeholder = "2"
o = s:taboption("bittorrent", Value, "SlowTorrentsInactivityTimer", translate("Torrent inactivity timer"), translate("Units: seconds"))
o.datatype = "integer"
o.placeholder = "60"
s:tab("webgui", translate("WebUI Settings"))
o = s:taboption("webgui", Flag, "UseUPnP", translate("Use UPnP for WebUI"), translate("Using the UPnP / NAT-PMP port of the router for connecting to WebUI."))
o.enabled = "true"
o.disabled = "false"
o.default = o.disabled
--o = s:taboption("webgui", Value, "Username", translate("Username"), translate("The login name for WebUI."))
--o.placeholder = "admin"
--o = s:taboption("webgui", Value, "Password", translate("Password"), translate("The login password for WebUI."))
--o.password = true
o = s:taboption("webgui", Value, "Locale", translate("Locale Language"))
o:value("en", translate("English"))
o:value("zh", translate("Chinese"))
o.default = "en"
o = s:taboption("webgui", Flag, "CSRFProtection", translate("CSRF Protection"), translate("Enable Cross-Site Request Forgery (CSRF) protection."))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:taboption("webgui", Flag, "ClickjackingProtection", translate("Clickjacking Protection"), translate("Enable clickjacking protection."))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:taboption("webgui", Flag, "HostHeaderValidation", translate("Host Header Validation"), translate("Validate the host header."))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:taboption("webgui", Flag, "LocalHostAuth", translate("Local Host Authentication"), translate("Force authentication for clients on localhost."))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:taboption("webgui", Flag, "AuthSubnetWhitelistEnabled", translate("Enable Subnet Whitelist"))
o.enabled = "true"
o.disabled = "false"
o.default = o.disabled
o = s:taboption("webgui", DynamicList, "AuthSubnetWhitelist", translate("Subnet Whitelist"))
o:depends("AuthSubnetWhitelistEnabled", "true")
s:tab("advanced", translate("Advance Settings"))
o = s:taboption("advanced", Flag, "AnonymousMode", translate("Anonymous Mode"), translate("When enabled, qBittorrent will take certain measures to try"
.. " to mask its identity. Refer to the <a href='https://github.com/qbittorrent/qBittorrent/wiki/Anonymous-Mode' target='_blank'>wiki</a>"))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:taboption("advanced", Flag, "SuperSeeding", translate("Super Seeding"), translate("The super seeding mode."))
o.enabled = "true"
o.disabled = "false"
o.default = o.disabled
o = s:taboption("advanced", Value, "configuration", translate("Profile Folder Suffix"), translate("Suffix for profile folder"))
o = s:taboption("advanced", Flag, "IncludeOverhead", translate("Limit Overhead Usage"), translate("The overhead usage is been limitted."))
o.enabled = "true"
o.disabled = "false"
o.default = o.disabled
o = s:taboption("advanced", Flag, "IgnoreLimitsLAN", translate("Ignore LAN Limit"), translate("Ignore the speed limit to LAN."))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:taboption("advanced", Flag, "osCache", translate("Use os Cache"))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:taboption("advanced", Value, "OutgoingPortsMax", translate("Max Outgoing Port"), translate("The max outgoing port."))
o.datatype = "port"
o = s:taboption("advanced", Value, "OutgoingPortsMin", translate("Min Outgoing Port"), translate("The min outgoing port."))
o.datatype = "port"
o = s:taboption("advanced", ListValue, "SeedChokingAlgorithm", translate("Choking Algorithm"), translate("The strategy of choking algorithm."))
o:value("RoundRobin", translate("Round Robin"))
o:value("FastestUpload", translate("Fastest Upload"))
o:value("AntiLeech", translate("Anti-Leech"))
o.default = "FastestUpload"
o = s:taboption("advanced", Flag, "AnnounceToAllTrackers", translate("Announce To All Trackers"))
o.enabled = "true"
o.disabled = "false"
o.default = o.disabled
o = s:taboption("advanced", Flag, "AnnounceToAllTiers", translate("Announce To All Tiers"))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:taboption("advanced", Flag, "Enabled", translate("Enable Log"), translate("Enable logger to log file."))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:taboption("advanced", Value, "Path", translate("Log Path"), translate("The path for qbittorrent log."))
o:depends("Enabled", "true")
o = s:taboption("advanced", Flag, "Backup", translate("Enable Backup"), translate("Backup log file when oversize the given size."))
o:depends("Enabled", "true")
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:taboption("advanced", Flag, "DeleteOld", translate("Delete Old Backup"), translate("Delete the old log file."))
o:depends("Enabled", "true")
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:taboption("advanced", Value, "MaxSizeBytes", translate("Log Max Size"), translate("The max size for qbittorrent log (Unit: Bytes)."))
o:depends("Enabled", "true")
o.placeholder = "66560"
o = s:taboption("advanced", Value, "SaveTime", translate("Log Saving Period"), translate("The log file will be deteted after given time. 1d -- 1 day, 1m -- 1 month, 1y -- 1 year"))
o:depends("Enabled", "true")
o.datatype = "string"
return m

View File

@ -0,0 +1,96 @@
m = Map("qbittorrent")
s = m:section(NamedSection, "main", "qbittorrent")
o = s:option(Flag, "AnonymousMode", translate("Anonymous Mode"))
o.description = translate("When enabled, qBittorrent will take certain measures to try to mask its identity. Refer to the <a href=\"https://github.com/qbittorrent/qBittorrent/wiki/Anonymous-Mode\" target=\"_blank\">wiki</a>")
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:option(Flag, "SuperSeeding", translate("Super Seeding"))
o.description = translate("The super seeding mode.")
o.enabled = "true"
o.disabled = "false"
o.default = o.disabled
o = s:option(Value, "configuration", translate("Profile Folder Suffix"))
o.description = translate("Suffix for profile folder, for example, <b>qBittorrent_[NAME]</b>.")
o = s:option(Flag, "IncludeOverhead", translate("Limit Overhead Usage"))
o.description = translate("The overhead usage is been limitted.")
o.enabled = "true"
o.disabled = "false"
o.default = o.disabled
o = s:option(Flag, "IgnoreLimitsLAN", translate("Ignore LAN Limit"))
o.description = translate("Ignore the speed limit to LAN.")
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:option(Flag, "osCache", translate("Use os Cache"))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:option(Value, "OutgoingPortsMax", translate("Max Outgoing Port"))
o.description = translate("The max outgoing port.")
o.datatype = "port"
o = s:option(Value, "OutgoingPortsMin", translate("Min Outgoing Port"))
o.description = translate("The min outgoing port.")
o.datatype = "port"
o = s:option(ListValue, "SeedChokingAlgorithm", translate("Choking Algorithm"))
o.description = translate("The strategy of choking algorithm.")
o:value("RoundRobin", translate("Round Robin"))
o:value("FastestUpload", translate("Fastest Upload"))
o:value("AntiLeech", translate("Anti-Leech"))
o.default = "FastestUpload"
o = s:option(Flag, "AnnounceToAllTrackers", translate("Announce To All Trackers"))
o.enabled = "true"
o.disabled = "false"
o.default = o.disabled
o = s:option(Flag, "AnnounceToAllTiers", translate("Announce To All Tiers"))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:option(Flag, "Enabled", translate("Enable Log"))
o.description = translate("Enable logger to log file.")
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:option(Value, "Path", translate("Log Path"))
o.description = translate("The path for qbittorrent log.")
o:depends("Enabled", "true")
o = s:option(Flag, "Backup", translate("Enable Backup"))
o.description = translate("Backup log file when oversize the given size.")
o:depends("Enabled", "true")
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:option(Flag, "DeleteOld", translate("Delete Old Backup"))
o.description = translate("Delete the old log file.")
o:depends("Enabled", "true")
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:option(Value, "MaxSizeBytes", translate("Log Max Size"))
o.description = translate("The max size for qbittorrent log (Unit: Bytes).")
o:depends("Enabled", "true")
o.placeholder = "66560"
o = s:option(Value, "SaveTime", translate("Log Saving Period"))
o.description = translate("The log file will be deteted after given time. 1d -- 1 day, 1m -- 1 month, 1y -- 1 year.")
o:depends("Enabled", "true")
o.datatype = "string"
return m

View File

@ -0,0 +1,39 @@
m = Map("qbittorrent")
m.title = translate("qBittorrent")
m.description = translate("qBittorrent is a cross-platform free and open-source BitTorrent client")
m:section(SimpleSection).template = "qbittorrent/qbittorrent_status"
s = m:section(NamedSection, "main", "qbittorrent")
o = s:option(Flag, "enabled", translate("Enabled"))
o.default = "1"
o = s:option(ListValue, "user", translate("Run daemon as user"))
local u
for u in luci.util.execi("cat /etc/passwd | cut -d ':' -f1") do
o:value(u)
end
o = s:option(Value, "profile", translate("Store configuration files in the Path"))
o.default = '/tmp'
o = s:option(Value, "SavePath", translate("Store download files in the Path"))
o.placeholder = "/tmp/download"
o = s:option(Value, "Port", translate("WEBUI listening port"))
o.datatype = "port"
o.placeholder = "8080"
o = s:option(Flag, "UseRandomPort", translate("Use Random Port"))
o.description = translate("Randomly assigns a different port every time qBittorrent starts up.")
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:option(Value, "PortRangeMin", translate("Connection Port"))
o.description = translate("Incoming connection port.")
o:depends("UseRandomPort", false)
o.datatype = "range(1024,65535)"
return m

View File

@ -0,0 +1,112 @@
m = Map("qbittorrent")
s = m:section(NamedSection, "main", "qbittorrent")
o = s:option(Flag, "DHT", translate("Enable DHT"))
o.description = translate("Enable DHT (decentralized network) to find more peers.")
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:option(Flag, "PeX", translate("Enable PeX"))
o.description = translate("Enable Peer Exchange (PeX) to find more peers.")
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:option(Flag, "LSD", translate("Enable LSD"))
o.description = translate("Enable Local Peer Discovery to find more peers.")
o.enabled = "true"
o.disabled = "false"
o.default = o.disabled
o = s:option(Flag, "uTP_rate_limited", translate("uTP Rate Limit"))
o.description = translate("Apply rate limit to uTP protocol.")
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:option(ListValue, "Encryption", translate("Encryption Mode"))
o.description = translate("Enable DHT (decentralized network) to find more peers.")
o:value("0", translate("Prefer Encryption"))
o:value("1", translate("Require Encryption"))
o:value("2", translate("Disable Encryption"))
o.default = "0"
o = s:option(Value, "MaxConnecs", translate("Max Connections"))
o.description = translate("The max number of connections.")
o.datatype = "integer"
o.placeholder = "500"
o = s:option(Value, "MaxConnecsPerTorrent", translate("Max Connections Per Torrent"))
o.description = translate("The max number of connections per torrent.")
o.datatype = "integer"
o.placeholder = "100"
o = s:option(Value, "MaxUploads", translate("Max Uploads"))
o.description = translate("The max number of connected peers.")
o.datatype = "integer"
o.placeholder = "8"
o = s:option(Value, "MaxUploadsPerTorrent", translate("Max Uploads Per Torrent"))
o.description = translate("The max number of connected peers per torrent.")
o.datatype = "integer"
o.placeholder = "4"
o = s:option(Value, "MaxRatio", translate("Max Ratio"))
o.description = translate("The max ratio for seeding. -1 is to disable the seeding.")
o.datatype = "float"
o.placeholder = "-1"
o = s:option(ListValue, "MaxRatioAction", translate("Max Ratio Action"))
o.description = translate("The action when reach the max seeding ratio.")
o:value("0", translate("Pause them"))
o:value("1", translate("Remove them"))
o.defaule = "0"
o = s:option(Value, "GlobalMaxSeedingMinutes", translate("Max Seeding Minutes"))
o.description = translate("Units: minutes")
o.datatype = "integer"
s = m:section(NamedSection, "main", "qbittorrent")
s.title = translate("Queueing Setting")
o = s:option(Flag, "QueueingEnabled", translate("Enable Torrent Queueing"))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:option(Value, "MaxActiveDownloads", translate("Maximum Active Downloads"))
o.datatype = "integer"
o.placeholder = "3"
o = s:option(Value, "MaxActiveUploads", translate("Max Active Uploads"))
o.datatype = "integer"
o.placeholder = "3"
o = s:option(Value, "MaxActiveTorrents", translate("Max Active Torrents"))
o.datatype = "integer"
o.placeholder = "5"
o = s:option(Flag, "IgnoreSlowTorrents", translate("Ignore Slow Torrents"))
o.description = translate("Do not count slow torrents in these limits.")
o.enabled = "true"
o.disabled = "false"
o.default = o.disabled
o = s:option(Value, "SlowTorrentsDownloadRate", translate("Download rate threshold"))
o.description = translate("Units: KiB/s")
o.datatype = "integer"
o.placeholder = "2"
o = s:option(Value, "SlowTorrentsUploadRate", translate("Upload rate threshold"))
o.description = translate("Units: KiB/s")
o.datatype = "integer"
o.placeholder = "2"
o = s:option(Value, "SlowTorrentsInactivityTimer", translate("Torrent inactivity timer"))
o.description = translate("Units: seconds")
o.datatype = "integer"
o.placeholder = "60"
return m

View File

@ -0,0 +1,41 @@
m = Map("qbittorrent")
s = m:section(NamedSection, "main", "qbittorrent")
o = s:option(Flag, "UPnP", translate("Use UPnP for Connections"))
o.description = translate("Use UPnP/ NAT-PMP port forwarding from my router. Refer to the <a href=\"https://en.wikipedia.org/wiki/Port_forwarding\" target=\"_blank\">wiki</a>")
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:option(Value, "GlobalDLLimit", translate("Global Download Speed"))
o.description = translate("Global Download Speed Limit(KiB/s).")
o.datatype = "float"
o.placeholder = "0"
o = s:option(Value, "GlobalUPLimit", translate("Global Upload Speed"))
o.description = translate("Global Upload Speed Limit(KiB/s).")
o.datatype = "float"
o.placeholder = "0"
o = s:option(Value, "GlobalDLLimitAlt", translate("Alternative Download Speed"))
o.description = translate("Alternative Download Speed Limit(KiB/s).")
o.datatype = "float"
o.placeholder = "10"
o = s:option(Value, "GlobalUPLimitAlt", translate("Alternative Upload Speed"))
o.description = translate("Alternative Upload Speed Limit(KiB/s).")
o.datatype = "float"
o.placeholder = "10"
o = s:option(ListValue, "BTProtocol", translate("Enabled protocol"))
o.description = translate("The protocol that was enabled.")
o:value("Both", translate("TCP and UTP"))
o:value("TCP", translate("TCP"))
o:value("UTP", translate("UTP"))
o.default = "Both"
o = s:option(Value, "InetAddress", translate("Inet Address"))
o.description = translate("The address that respond to the trackers.")
return m

View File

@ -0,0 +1,87 @@
m = Map("qbittorrent")
s = m:section(NamedSection, "main", "qbittorrent")
o = s:option(Flag, "CreateTorrentSubfolder", translate("Create Subfolder"))
o.description = translate("Create subfolder for torrents with multiple files.")
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:option(Flag, "StartInPause", translate("Start In Pause"))
o.description = translate("Do not start the download automatically.")
o.enabled = "true"
o.disabled = "false"
o.default = o.disabled
o = s:option(Flag, "AutoDeleteAddedTorrentFile", translate("Auto Delete Torrent File"))
o.description = translate("The .torrent files will be deleted afterwards.")
o.enabled = "IfAdded"
o.disabled = "Never"
o.default = o.disabled
o = s:option(Flag, "PreAllocation", translate("Pre Allocation"))
o.description = translate("Pre-allocate disk space for all files.")
o.enabled = "true"
o.disabled = "false"
o.default = o.disabled
o = s:option(Flag, "UseIncompleteExtension", translate("Use Incomplete Extension"))
o.description = translate("The incomplete task will be added the extension of !qB.")
o.enabled = "true"
o.disabled = "false"
o.default = o.disabled
o = s:option(Flag, "TempPathEnabled", translate("Temp Path Enabled"))
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:option(Value, "TempPath", translate("Temp Path"))
o.description = translate("The absolute and relative path can be set.")
o:depends("TempPathEnabled", "true")
o.placeholder = "temp/"
o = s:option(Value, "DiskWriteCacheSize", translate("Disk Cache Size (MiB)"))
o.description = translate("The value -1 is auto and 0 is disable. In default, it is set to 64MiB.")
o.datatype = "integer"
o.placeholder = "64"
o = s:option(Value, "DiskWriteCacheTTL", translate("Disk Cache TTL (s)"))
o.description = translate("In default, it is set to 60s.")
o.datatype = "integer"
o.placeholder = "60"
s = m:section(NamedSection, "main", "qbittorrent")
s.title = translate("Saving Management")
o = s:option(ListValue, "DisableAutoTMMByDefault", translate("Default Torrent Management Mode"))
o:value("true", translate("Manual"))
o:value("false", translate("Automaic"))
o.default = "true"
o = s:option(ListValue, "CategoryChanged", translate("Torrent Category Changed"))
o.description = translate("Choose the action when torrent category changed.")
o:value("true", translate("Switch torrent to Manual Mode"))
o:value("false", translate("Relocate torrent"))
o.default = "false"
o = s:option(ListValue, "DefaultSavePathChanged", translate("Default Save Path Changed"))
o.description = translate("Choose the action when default save path changed.")
o:value("true", translate("Switch affected torrent to Manual Mode"))
o:value("false", translate("Relocate affected torrent"))
o.default = "true"
o = s:option(ListValue, "CategorySavePathChanged", translate("Category Save Path Changed"))
o.description = translate("Choose the action when category save path changed.")
o:value("true", translate("Switch affected torrent to Manual Mode"))
o:value("false", translate("Relocate affected torrent"))
o.default = "true"
o = s:option(Value, "TorrentExportDir", translate("Torrent Export Dir"))
o.description = translate("The .torrent files will be copied to the target directory.")
o = s:option(Value, "FinishedTorrentExportDir", translate("Finished Torrent Export Dir"))
o.description = translate("The .torrent files for finished downloads will be copied to the target directory.")
return m

View File

@ -0,0 +1,56 @@
m = Map("qbittorrent")
s = m:section(NamedSection, "main", "qbittorrent")
o = s:option(Flag, "UseUPnP", translate("Use UPnP for WebUI"))
o.description = translate("Using the UPnP / NAT-PMP port of the router for connecting to WebUI.")
o.enabled = "true"
o.disabled = "false"
o.default = o.disabled
--o = s:option(Value, "Username", translate("Username"))
--o.description = translate("The login name for WebUI.")
--o.placeholder = "admin"
--o = s:option(Value, "Password", translate("Password"))
--o.description = translate("The login password for WebUI.")
--o.password = true
o = s:option(Value, "Locale", translate("Locale Language"))
o:value("en", translate("English"))
o:value("zh", translate("Chinese"))
o.default = "en"
o = s:option(Flag, "CSRFProtection", translate("CSRF Protection"))
o.description = translate("Enable Cross-Site Request Forgery (CSRF) protection.")
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:option(Flag, "ClickjackingProtection", translate("Clickjacking Protection"))
o.description = translate("Enable clickjacking protection.")
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:option(Flag, "HostHeaderValidation", translate("Host Header Validation"))
o.description = translate("Validate the host header.")
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:option(Flag, "LocalHostAuth", translate("Local Host Authentication"))
o.description = translate("Force authentication for clients on localhost.")
o.enabled = "true"
o.disabled = "false"
o.default = o.enabled
o = s:option(Flag, "AuthSubnetWhitelistEnabled", translate("Enable Subnet Whitelist"))
o.enabled = "true"
o.disabled = "false"
o.default = o.disabled
o = s:option(DynamicList, "AuthSubnetWhitelist", translate("Subnet Whitelist"))
o:depends("AuthSubnetWhitelistEnabled", "true")
return m

View File

@ -4,7 +4,7 @@ XHR.poll(3, '<%=url([[admin]], [[nas]], [[qBittorrent]], [[status]])%>', null,
var tb = document.getElementById('qBittorrent_status');
if (data && tb) {
if (data.running) {
var links = '<em><b><font color=green>qBittorrent <%:RUNNING%></font></b></em>';
var links = '<em><b><font color=green>qBittorrent <%:RUNNING%></font></b></em><input class="cbi-button-reload mar-10" type="button" value="<%:Open Web Interface%>" onclick="openwebui();" />';
tb.innerHTML = links;
} else {
tb.innerHTML = '<em><b><font color=red>qBittorrent <%:NOT RUNNING%></font></b></em>';
@ -12,6 +12,11 @@ XHR.poll(3, '<%=url([[admin]], [[nas]], [[qBittorrent]], [[status]])%>', null,
}
}
);
function openwebui(){
var url = window.location.host+":<%=luci.sys.exec("uci -q get qbittorrent.main.Port"):gsub("^%s*(.-)%s*$", "%1")%>";
window.open('http://'+url,'target','');
}
//]]>
</script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>

View File

@ -14,15 +14,12 @@ msgstr ""
msgid "qbittorrent"
msgstr "qbittorrent"
msgid "Running"
msgid "RUNNING"
msgstr "运行中"
msgid "Not running"
msgid "NOT RUNNING"
msgstr "未运行"
msgid "qbittorrent Run Status"
msgstr "qbittorrent运行状态"
msgid "Basic Settings"
msgstr "基本设置"
@ -30,7 +27,7 @@ msgid "Enable"
msgstr "启用"
msgid "qBittorrent is a cross-platform free and open-source BitTorrent client"
msgstr "qBittorrent是一个基于 QT 的跨平台的开源 BitTorrent 客户端"
msgstr "qBittorrent 是一个基于 QT 的跨平台的开源 BitTorrent 客户端"
msgid "profile_dir"
msgstr "配置文件目录"
@ -60,7 +57,7 @@ msgid "Store download files in the Path"
msgstr "下载文件存放目录"
msgid "WEBUI Settings"
msgstr "WEBUI设置"
msgstr "WEBUI 设置"
msgid "WEBUI listening port"
msgstr "WebUI 监听端口"
@ -68,15 +65,14 @@ msgstr "WebUI 监听端口"
msgid "Use Random Port"
msgstr "使用随机端口"
msgid "Randomly assigns a different port every time qBittorrent starts up"
msgstr "在每次启动时使用不同的传入连接端口"
msgid "Randomly assigns a different port every time qBittorrent starts up."
msgstr "在每次启动时使用不同的传入连接端口"
msgid "Connection Port"
msgstr "连接端口"
msgid "Incoming connection port"
msgstr ""
"推荐在防火墙 -> 流量规则 中,打开这个端口获得更好的下载速度( TCP+UDP "
msgid "Incoming connection port."
msgstr "推荐在防火墙 -> 流量规则 中,打开这个端口获得更好的下载速度( TCP+UDP )。"
msgid "Bittorrent Settings"
msgstr "Bittorrent 设置"
@ -93,12 +89,8 @@ msgstr "用户组"
msgid "Parent Path for Profile Folder"
msgstr "配置保存路径"
msgid ""
"The path for storing profile folder using by command: <b>--profile [PATH]</"
"b>."
msgstr ""
"配置文件的保存路径,默认的配置文件夹在/tmp下。例如<code>/etc/config</"
"code>。"
msgid "The path for storing profile folder using by command: <b>--profile [PATH]</b>."
msgstr "配置文件的保存路径,默认的配置文件夹在/tmp下。例如<code>/etc/config</code>。"
msgid "Profile Folder Suffix"
msgstr "配置目录后缀"
@ -107,7 +99,7 @@ msgid "Suffix for profile folder, for example, <b>qBittorrent_[NAME]</b>."
msgstr "配置文件文件夹的后缀。例如: <b>qBittorrent_[NAME]</b>。"
msgid "Locale Language"
msgstr "WebUI语言"
msgstr "WebUI 语言"
msgid "English"
msgstr "英文"
@ -148,9 +140,7 @@ msgstr "日志保存期限"
msgid "The max size for qbittorrent log (Unit: Bytes)."
msgstr "设定日志文件的大小(单位:字节)"
msgid ""
"The log file will be deteted after given time. 1d -- 1 day, 1m -- 1 month, "
"1y -- 1 year"
msgid "The log file will be deteted after given time. 1d -- 1 day, 1m -- 1 month, 1y -- 1 year."
msgstr "设定日志文件的时间1d-1天,1m-1个月,1y-1年"
msgid "Connection Settings"
@ -160,7 +150,7 @@ msgid "Use UPnP for Connections"
msgstr "端口自动转发"
msgid "Use UPnP/ NAT-PMP port forwarding from my router."
msgstr "使用路由器的UPnP/NAT-PMP端口自动转发。"
msgstr "使用路由器的 UPnP/NAT-PMP 端口自动转发。"
msgid "Use different port on each startup voids the first"
msgstr "在每次启动时使用随机的端口,可能会使第一个启动无效"
@ -199,7 +189,7 @@ msgid "The protocol that was enabled."
msgstr "当前已启用的协议。"
msgid "TCP and UTP"
msgstr "TCP和UTP"
msgstr "TCP UTP"
msgid "Inet Address"
msgstr "输入地址"
@ -241,14 +231,12 @@ msgid "Use Incomplete Extension"
msgstr "使用扩展名"
msgid "The incomplete task will be added the extension of !qB."
msgstr "为不完整的文件添加后缀名<code>!qB</code>。"
msgstr "为不完整的文件添加后缀名 !qB"
msgid "Save Path"
msgstr "文件保存路径"
msgid ""
"The path to save the download file. For example:<code>/mnt/sda1/download</"
"code>"
msgid "The path to save the download file. For example:<code>/mnt/sda1/download</code>"
msgstr "下载文件的保存路径。例如:<code>/mnt/sda1/download</code>"
msgid "Temp Path Enabled"
@ -267,7 +255,7 @@ msgid "The value -1 is auto and 0 is disable. In default, it is set to 64MiB."
msgstr "数值1是自动的0是禁用的。默认设置为64MiB。"
msgid "Disk Cache TTL (s)"
msgstr "磁盘缓存TTL"
msgstr "磁盘缓存 TTL"
msgid "In default, it is set to 60s."
msgstr "默认设置为60秒。"
@ -318,40 +306,37 @@ msgid "Torrent Export Dir"
msgstr "种子导出目录"
msgid "The .torrent files will be copied to the target directory."
msgstr "种子文件将被复制到目标目录。例如:<code>/etc/config</code>。"
msgstr "种子文件将被复制到目标目录。例如:/etc/config"
msgid "Finished Torrent Export Dir"
msgstr "复制种子文件"
msgid ""
"The .torrent files for finished downloads will be copied to the target "
"directory."
msgstr ""
"将已下载完成的种子文件复制到目标目录,例如:<code>/etc/config</code>。"
msgid "The .torrent files for finished downloads will be copied to the target directory."
msgstr "将已下载完成的种子文件复制到目标目录,例如:/etc/config"
msgid "Enable DHT"
msgstr "启用DHT"
msgstr "启用 DHT"
msgid "Enable DHT (decentralized network) to find more peers"
msgstr "启用DHT(去中心化网络) 使DHT分散网络能够找到更多的对等点"
msgid "Enable DHT (decentralized network) to find more peers."
msgstr "启用 DHT(去中心化网络) 使 DHT分散网络能够找到更多的对等点"
msgid "Enable PeX"
msgstr "启用PeX"
msgstr "启用 PeX"
msgid "Enable Peer Exchange (PeX) to find more peers"
msgstr "启用用户交换(PeX)以找到更多用户"
msgid "Enable Peer Exchange (PeX) to find more peers."
msgstr "启用用户交换(PeX)以找到更多用户"
msgid "Enable LSD"
msgstr "启用LSD"
msgstr "启用 LSD"
msgid "Enable Local Peer Discovery to find more peers"
msgstr "启用本地用户发现以找到更多用户"
msgid "Enable Local Peer Discovery to find more peers."
msgstr "启用本地用户发现以找到更多用户"
msgid "uTP Rate Limit"
msgstr "uTP速度限制"
msgstr "uTP 速度限制"
msgid "Apply rate limit to µTP protocol."
msgstr "针对µTP协议进行速度限制。"
msgid "Apply rate limit to uTP protocol."
msgstr "针对 uTP 协议进行速度限制。"
msgid "Encryption Mode"
msgstr "加密模式"
@ -459,25 +444,25 @@ msgid "Password"
msgstr "密码"
msgid "Use UPnP for WebUI"
msgstr "WebUI端口转发"
msgstr "WebUI 端口转发"
msgid "Using the UPnP / NAT-PMP port of the router for connecting to WebUI."
msgstr "使用路由器的UPnP/NAT-PMP端口转发到WebUI。"
msgstr "使用路由器的 UPnP/NAT-PMP 端口转发到 WebUI。"
msgid "The login name for WebUI."
msgstr "WebUI的登录用户名设置。"
msgstr "WebUI 的登录用户名设置。"
msgid "The login password for WebUI."
msgstr "WebUI用户的登录密码设置。"
msgstr "WebUI 用户的登录密码设置。"
msgid "The listening port for WebUI."
msgstr "WebUI的登录端口设置默认端口8080。"
msgstr "WebUI 的登录端口设置默认端口8080。"
msgid "CSRF Protection"
msgstr "CSRF保护"
msgstr "CSRF 保护"
msgid "Enable Cross-Site Request Forgery (CSRF) protection."
msgstr "启用跨站点请求伪造(CSRF)保护。"
msgstr "启用跨站点请求伪造 (CSRF) 保护。"
msgid "Clickjacking Protection"
msgstr "劫持保护"
@ -525,13 +510,13 @@ msgid "The overhead usage is been limitted."
msgstr "对传送总开销进行速度限制。"
msgid "Ignore LAN Limit"
msgstr "LAN限制"
msgstr "LAN 限制"
msgid "Ignore the speed limit to LAN."
msgstr "忽略对LAN的速度限制。"
msgstr "忽略对 LAN 的速度限制。"
msgid "Use os Cache"
msgstr "使用OS操作系统缓存管理"
msgstr "使用 OS 操作系统缓存管理"
msgid "Max Outgoing Port"
msgstr "端口设置"
@ -539,6 +524,9 @@ msgstr "端口设置"
msgid "Min Outgoing Port"
msgstr "端口设置"
msgid "The max outgoing port."
msgstr "最大输出端口。"
msgid "The min outgoing port."
msgstr "最小输出端口。"
@ -558,10 +546,10 @@ msgid "Anti-Leech"
msgstr "反吸血"
msgid "Announce To All Trackers"
msgstr "对所有Trackers宣告"
msgstr "对所有 Trackers 宣告"
msgid "Announce To All Tiers"
msgstr "对所有Tiers宣告"
msgstr "对所有 Tiers 宣告"
msgid "configuration file"
msgstr "配置文件"
@ -570,12 +558,16 @@ msgid "Operation log"
msgstr "运行日志"
msgid "This page is the log document content of qbittorrent."
msgstr "本页是qBittorrent的日志文档内容。"
msgstr "本页是 qBittorrent 的日志文档内容。"
msgid ""
"This page is the content of the configuration document under /etc/config/"
"qbittorrent."
msgid "This page is the content of the configuration document under /etc/config/qbittorrent."
msgstr "本页是/etc/config/qbittorrent下的配置文档内容。"
msgid "Open Web Interface"
msgstr "打开管理页面"
msgid "Use UPnP/ NAT-PMP port forwarding from my router. Refer to the <a href=\"https://en.wikipedia.org/wiki/Port_forwarding\" target=\"_blank\">wiki</a>"
msgstr "使用路由器的 UPnP/NAT-PMP 端口转发,参考 <a href=\"https://en.wikipedia.org/wiki/Port_forwarding\" target=\"_blank\">wiki</a>"
msgid "When enabled, qBittorrent will take certain measures to try to mask its identity. Refer to the <a href=\"https://github.com/qbittorrent/qBittorrent/wiki/Anonymous-Mode\" target=\"_blank\">wiki</a>"
msgstr "启用后 qBittorrent 将采取某些措施来尝试掩盖其身份,参考<a href=\"https://github.com/qbittorrent/qBittorrent/wiki/Anonymous-Mode\" target=\"_blank\">wiki</a>"

View File

@ -17,4 +17,3 @@ config qbittorrent 'main'
option UseRandomPort 'false'
option PortRangeMin '55555'
option enabled '0'