尧图精选

qBittorrent 分享率限制模式 share_limits_mode 怎么设置?

🕒 发布时间:2026/9/10 8:21:49 📁 来源:尧图网络
qBittorrent 分享率限制模式 share_limits_mode 怎么设置【免费下载链接】qBittorrentqBittorrent BitTorrent client项目地址: https://gitcode.com/GitHub_Trending/qb/qBittorrentqBittorrent 的分享率限制支持三个独立的限制项最大分享率max ratio、种子时长seeding time、无活动种子时长inactive seeding time。当同时启用多项限制时share_limits_mode决定这些限制之间是任意一项达标就触发还是全部达标才触发后续动作停止、删除、超级做种等。这篇文章说明三种设置入口GUI 选项对话框、单个种子的属性对话框以及 Web API2.15.3 起支持。share_limits_mode 的取值与含义模式定义在 sharelimits.h 中enum class ShareLimitsMode { Default -1, // special value MatchAny 0, MatchAll 1 };Default-1特殊值表示跟随上一层设置主要用于单个种子的覆盖值。MatchAny0任一已启用的限制条件达成即触发动作。MatchAll1所有已启用的限制条件都达成才触发动作。这个语义可以从种子剩余时间ETA的计算逻辑得到印证见 torrentimpl.cppif (etaList.isEmpty()) return MAX_ETA; return (shareLimits.mode ShareLimitsMode::MatchAny) ? std::ranges::min(etaList) : std::ranges::max(etaList);即MatchAny取各限制 ETA 的最小值最先达标的那项决定触发时间MatchAll取最大值所有项都达标才触发。限制项的具体数值约定同样来自 sharelimits.h常量值含义DEFAULT_RATIO_LIMIT-2分享率未单独设置跟随默认值NO_RATIO_LIMIT-1不启用分享率限制DEFAULT_SEEDING_TIME_LIMIT-2种子时长未单独设置NO_SEEDING_TIME_LIMIT-1不启用种子时长限制种子时长以分钟为单位GUI 输入框后缀为minETA 计算中用seedingTimeLimit * 60换算为秒。触发的动作由另一个字段max_ratio_act指定见 appcontroller.cpp0停止、1删除、2启用超级做种、3删除并删除内容。在 GUI 选项对话框中设置全局模式全局的分享率限制在选项对话框的BitTorrent页的Share Ratio Limiting区块设置界面定义见 optionsdialog.ui勾选要启用的限制项最大分享率、种子时长达到分钟、无活动种子时长达到分钟。在区块底部选择匹配模式两个单选按钮Any of the above对应MatchAny默认选中上述任一限制达成即触发动作All the above对应MatchAll上述所有限制都达成才触发动作。保存设置。保存逻辑见 optionsdialog.cpp.mode (m_ui-radioButtonShareLimitsModeAll-isChecked() ? BitTorrent::ShareLimitsMode::MatchAll : BitTorrent::ShareLimitsMode::MatchAny),即选中 All 单选框就是MatchAll否则一律按MatchAny处理。在单个种子上覆盖模式每个种子可以在自己的选项对话框分享限制部件见 torrentsharelimitswidget.cpp中单独设置分享率、种子时长和无活动种子时长并选择该种子的匹配模式下拉框两项文案为 Match any limit / Match all the limits。种子的取值可以显式指定也可以继承上层设置界面上显示为 Default默认模式名 和 From category跟随分类 两种继承选项见 torrentsharelimitswidget.cpp。单个种子设置的模式会写入恢复数据重启后保留见 dbresumedatastorage.cpp 对share_limits_mode的持久化处理。通过 Web API 设置qBittorrent 2.15.3 及以上WebAPI_Changelog.md 的 2.15.3 一节记录了三个与share_limits_mode相关的端点变更PR #24043sync/maindata端点包含种子的share_limits_mode字段app/preferences端点包含share_limits_mode选项app/setPreferences端点允许设置share_limits_mode选项。读取当前模式请求GET /api/v2/app/preferences响应中的share_limits_mode是枚举键名字符串序列化方式见 appcontroller.cppconst BitTorrent::ShareLimits shareLimits session-shareLimits(); data[umax_ratio_enabled_s] (shareLimits.ratioLimit 0.); data[umax_ratio_s] shareLimits.ratioLimit; data[umax_seeding_time_enabled_s] (shareLimits.seedingTimeLimit 0); data[umax_seeding_time_s] shareLimits.seedingTimeLimit; data[umax_inactive_seeding_time_enabled_s] (shareLimits.inactiveSeedingTimeLimit 0); data[umax_inactive_seeding_time_s] shareLimits.inactiveSeedingTimeLimit; data[ushare_limits_mode_s] Utils::String::fromEnum(shareLimits.mode); data[umax_ratio_act_s] static_castint(shareLimits.action);fromEnum通过QMetaEnum输出键名见 string.h所以取值是Default、MatchAny或MatchAll。设置模式POST /api/v2/app/setPreferences请求体是 JSON 对象可以只传share_limits_modecurl -X POST http://WebUI地址/api/v2/app/setPreferences \ --cookie SID登录后的会话 \ -H Content-Type: application/json \ -d {share_limits_mode:MatchAll}将WebUI地址替换为你实际的 Web UI 地址会话凭证来自 Web UI 的登录认证。服务端处理见 appcontroller.cppBitTorrent::ShareLimits shareLimits session-shareLimits(); if (hasKey(umax_ratio_enabled_s) !it.value().toBool()) shareLimits.ratioLimit BitTorrent::NO_RATIO_LIMIT; else if (hasKey(umax_ratio_s)) shareLimits.ratioLimit it.value().toReal(); // ... seeding time 项同理 if (hasKey(ushare_limits_mode_s)) shareLimits.mode Utils::String::toEnum(it.value().toString(), BitTorrent::ShareLimitsMode::MatchAny);两点需要注意模式值按字符串解析枚举键名传入无法识别的值时toEnum回退到默认参数MatchAny见 string.h不会报错但也不会按你写的值生效。setPreferences是增量设置只提交要改的键即可限制项的启用/禁用通过max_ratio_enabled、max_seeding_time_enabled、max_inactive_seeding_time_enabled控制取消启用时服务端会把对应限制置为-1不限制。单个种子的模式则用POST /api/v2/torrents/setShareLimits端点设置路由注册见 webapplication.h。设置后可通过sync/maindata响应中的种子share_limits_mode字段核对每个种子的当前模式。验证设置是否生效读回核对再请求一次GET /api/v2/app/preferences确认share_limits_mode返回MatchAll或MatchAnyGUI 中则检查选项对话框里对应单选按钮的选中状态。行为核对等待种子达到限制条件观察是否执行了max_ratio_act对应的动作停止/删除/超级做种/删除并删内容。用MatchAny时最先达标的那项限制就触发动作用MatchAll时必须所有已启用限制都达标才触发。边界与限制Default-1是特殊值表示继承上层设置不要把它当作第三种匹配模式传给setPreferences——全局设置只有MatchAny/MatchAll两种有效选择。枚举值注释明确说明新增枚举项时不允许改动已有数值以避免破坏现有用户设置见 sharelimits.h升级版本时已保存的模式值保持兼容。Web API 的share_limits_mode支持从 2.15.3 开始旧版本只能通过 GUI 设置。【免费下载链接】qBittorrentqBittorrent BitTorrent client项目地址: https://gitcode.com/GitHub_Trending/qb/qBittorrent创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
上一篇/下一篇内容由系统自动关联 返回资讯列表 →