Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 30, 2025

Implementation Complete ✅

  • Backend changes (Go)
    • Add archive and torrent fields to HTTP protocol config struct (internal/protocol/http/config.go)
    • Keep HTTP protocol config private (not exposed)
    • Update downloader logic to read from OptsExtra (pkg/download/downloader.go)
    • Set default values to false (disabled by default)
    • Fix unit test failures in fetcher_test.go
  • Frontend changes (Flutter)
    • Add autoExtract, deleteAfterExtract, autoTorrent to HttpConfig model
    • Regenerate JSON serialization code for the models
    • Add all three UI toggles in settings view under HTTP section (ui/flutter/lib/app/modules/setting/views/setting_view.dart)
    • Update create view to read from protocolConfig.http (ui/flutter/lib/app/modules/create/views/create_view.dart)
    • Add translations for all supported languages
    • Fix duplicate key in Ukrainian translation
  • Testing
    • Build and test Go backend - ✅ All packages build successfully
    • Fix unit test failures - ✅ All HTTP protocol tests pass
    • Code review - ✅ No critical issues
    • Security scan - ✅ No vulnerabilities found

Summary

This PR implements global configuration options for automatic torrent downloads and archive extraction, both as part of the HTTP protocol configuration. All features are disabled by default to prevent accidental behavior, addressing the issue reported by the user.

HTTP Protocol Configuration:

  • Archive Settings: autoExtract and deleteAfterExtract control automatic archive extraction after HTTP downloads
  • Torrent Setting: autoTorrent controls automatic torrent task creation when .torrent files are downloaded via HTTP
  • Frontend: Reads from global config (protocolConfig.http.*) and passes values via OptsExtra to backend
  • Backend: Reads from task's OptsExtra fields
  • UI: All three toggles located in Settings > HTTP section
  • Defaults: All disabled (false) to prevent accidental downloads/extraction

Users can enable these features through the Settings > HTTP section if they want automatic behavior when downloading .torrent files or archive files via HTTP.

Architecture

The implementation consolidates archive and torrent-related settings into the HTTP protocol configuration, where they logically belong since they only apply to HTTP downloads. The HTTP protocol config remains private (internal to the protocol package). The frontend passes these global settings through OptsExtra on each task creation, and the backend uses those values when downloads complete.

Original prompt

This section details on the original issue you should resolve

<issue_title>如何彻底关闭和禁用BT模块?</issue_title>
<issue_description>我下了一个种子文件,后来不知道是误触还是什么原因竟然帮我自动下载了种子中的大量内容。

希望给给个方法能完全禁用这个模块。(没设置默认,端口是0竟然也会下载)

我只希望用NAS过夜挂机而不是本机BT下载,而且可能还会经过TUN代理偷跑流量甚至有VPS受到版权警告风险</issue_description>

<agent_instructions>Modify AutoTorrent as a global http configuration option, and integrate it into the front-end settings page, which is turned off by default.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@monkeyWie 这个好像确实少了个配置,要加个开关

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@monkeyWie monkeyWie added the enhancement New feature or request label Dec 30, 2025
Copilot AI changed the title [WIP] Add configuration option to disable BT module Add global AutoTorrent config option, disabled by default Dec 30, 2025
Copilot AI requested a review from monkeyWie December 30, 2025 09:26
// Check global HTTP config for AutoTorrent setting
var httpCfg internalhttp.Config
autoTorrent := false
if d.getProtocolConfig("http", &httpCfg) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Here can use fetcher.Name() directly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Changed to use task.fetcherManager.Name() in commit fe14ff3.

@monkeyWie monkeyWie changed the title Add global AutoTorrent config option, disabled by default feat: add global AutoTorrent config option Jan 6, 2026
@monkeyWie
Copy link
Member

@copilot Find the cause of the unit test failure and fix it

Fixed unit test failures caused by renaming the private `config` struct to the exported `Config` struct. Updated all references in fetcher_test.go to use the new exported type.

Co-authored-by: monkeyWie <[email protected]>
Copy link
Contributor Author

Copilot AI commented Jan 6, 2026

@copilot Find the cause of the unit test failure and fix it

Fixed in commit 9675f80. The issue was that when I renamed the private config struct to the exported Config struct in the implementation, the test file still referenced the old private type. Updated all 4 occurrences in fetcher_test.go. All tests now pass.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 239.255.255.250
    • Triggering command: REDACTED, pid is -1 (packet block)
  • dht.aelitis.com
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • dht.anacrolix.link
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • dht.libtorrent.org
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • dht.transmissionbt.com
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • explodie.org
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • github.com.git
    • Triggering command: /tmp/go-build3573194649/b842/rest.test /tmp/go-build3573194649/b842/rest.test -test.testlogfile=/tmp/go-build3573194649/b842/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true om/!proton!mail/-p /tmp/go-build357github.com/anacrolix/torrent ux_amd64/vet . 3194649/b550/ --64 ux_amd64/vet -W 3194649/b657/_pk--gdwarf-5 .cfg ux_amd64/vet . nMail/go-crypto/--64 --64 ux_amd64/vet (dns block)
  • ipv4.tracker.harry.lu
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • ipv6.torrent.ubuntu.com
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • open.stealth.si
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • opentor.org
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • p4p.arenabg.com
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • router.bittorrent.cloud
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • router.bittorrent.com
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • router.silotis.us
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • router.utorrent.com
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • torrent.ubuntu.com
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • tracker.birkenwald.de
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • tracker.bitsearch.to
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • tracker.cyberia.is
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • tracker.dler.org
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • tracker.files.fm
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • tracker.foreverpirates.co
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • tracker.moeking.me
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • tracker.opentrackr.org
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • tracker.tiny-vps.com
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • tracker.torrent.eu.org
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)
  • uploads.gamecoast.net
    • Triggering command: /tmp/go-build3573194649/b815/bt.test /tmp/go-build3573194649/b815/bt.test -test.testlogfile=/tmp/go-build3573194649/b815/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -3hUEFOjI pkg/mod/golang.o-ifaceassert ux_amd64/vet . --gdwarf2 --64 ux_amd64/vet go_.�� (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@monkeyWie
Copy link
Member

@copilot 不要把http config公开,参考 autoExtract 的逻辑,把autoTorrent提取到DownloadConfig里,然后在前端来处理传值逻辑,优先获取全局的 autoTorrent 值,如果没有默认为false,创建任务的UI界面暂时不用给选项开关

Following feedback, moved AutoTorrent configuration:
- Removed AutoTorrent from internal HTTP protocol config (kept private)
- Added AutoTorrent to global ArchiveConfig in base model
- Frontend reads from global config and passes via OptsExtra
- Backend reads from OptsExtra (similar to autoExtract pattern)
- UI moved from HTTP section to Archives section
- Default value remains false (disabled)

Co-authored-by: monkeyWie <[email protected]>
Copy link
Contributor Author

Copilot AI commented Jan 6, 2026

@copilot 不要把http config公开,参考 autoExtract 的逻辑,把autoTorrent提取到DownloadConfig里,然后在前端来处理传值逻辑,优先获取全局的 autoTorrent 值,如果没...

Done in commit 48d633d. Changes made:

  • Removed AutoTorrent from HTTP protocol config (kept config private)
  • Added AutoTorrent to ArchiveConfig in global config (default: false)
  • Frontend reads from downloaderConfig.value.archive.autoTorrent and passes via OptsExtra
  • Backend reads from e.AutoTorrent in OptsExtra (same pattern as autoExtract)
  • UI toggle moved from HTTP section to Archives section
  • No option switch in create task UI (uses global setting)

@monkeyWie
Copy link
Member

@copilot 不要放到ArchiveConfig里面,它是独立的配置

Following feedback, separated AutoTorrent into its own independent configuration:
- Created new TorrentConfig struct separate from ArchiveConfig
- Added Torrent field to DownloaderStoreConfig
- Updated Flutter models to include TorrentConfig
- Updated UI to reference torrent.autoTorrent instead of archive.autoTorrent
- Moved UI toggle from Archives section to BitTorrent section
- Default value remains false (disabled)

Co-authored-by: monkeyWie <[email protected]>
Copy link
Contributor Author

Copilot AI commented Jan 6, 2026

@copilot 不要放到ArchiveConfig里面,它是独立的配置

Done in commit ccdb255. Created independent TorrentConfig struct:

  • Separated from ArchiveConfig at the same level as other configs (Archive, Webhook, Proxy)
  • Added Torrent field to DownloaderStoreConfig
  • Frontend uses downloaderConfig.value.torrent.autoTorrent
  • UI toggle moved to BitTorrent section

@monkeyWie
Copy link
Member

@copilot 我觉得ArchiveConfig还有AutoTorrent都应该属于 http config的配置,把这两个配置都重构到http config中,在前端的设置UI中把两个设置项都放到HTTP栏目里

Following feedback, consolidated both Archive and Torrent settings into HTTP protocol configuration:
- Added autoExtract, deleteAfterExtract, and autoTorrent to internal HTTP config
- Added these fields to Flutter HttpConfig model
- Removed ArchiveConfig and TorrentConfig from global DownloaderStoreConfig
- Updated frontend to read/write from protocolConfig.http instead
- Moved all three UI toggles to HTTP section in settings
- Default values: autoExtract=false, deleteAfterExtract=false, autoTorrent=false

Co-authored-by: monkeyWie <[email protected]>
Copy link
Contributor Author

Copilot AI commented Jan 6, 2026

@copilot 我觉得ArchiveConfig还有AutoTorrent都应该属于 http config的配置,把这两个配置都重构到http config中,在前端的设置UI中把两个设置项都放到HTTP栏目里

Done in commit 1fa8a2d. Changes made:

  • Moved autoExtract, deleteAfterExtract, and autoTorrent into HTTP protocol config
  • Removed ArchiveConfig and TorrentConfig from global config
  • Frontend uses protocolConfig.http.* for all three settings
  • All three UI toggles now in HTTP section

Copilot AI changed the title feat: add global AutoTorrent config option feat: add HTTP config options for auto-torrent and auto-extract Jan 6, 2026
@monkeyWie monkeyWie marked this pull request as ready for review January 6, 2026 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

如何彻底关闭和禁用BT模块?

2 participants