Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A private torrent suddently becomes a public torrent #20743

Open
yegle opened this issue Apr 21, 2024 · 7 comments
Open

A private torrent suddently becomes a public torrent #20743

yegle opened this issue Apr 21, 2024 · 7 comments

Comments

@yegle
Copy link

yegle commented Apr 21, 2024

qBittorrent & operating system versions

qBittorrent: 4.6.4 x64
OS: Synology DSM 7 (run qBittorrent in Docker)
Qt: 6.6.2
Libtorrent: 2.0.10.0

What is the problem?

Sorry if the title is a bit confusing.

I use qBittorrent to download content from private trackers exclusively, all my torrent files should be private torrents.

I've seen at least 3 times when a torrent finishes 99% and suddenly it stuck at "Fetching Metadata" (or something similar, sorry I forgot the exact words). For some PT site, I even got a tracker error message "Banned client".

I've been confused by this behavior for a long time and finally noticed one of the PT site showed the user agent I used was curl/7.81.0, which led me to https://github.com/arvidn/libtorrent/blob/8a7aa8311387b8d530a2ec2a3eb5974fec5edb64/src/http_tracker_connection.cpp#L247-L249.

Reading the libtorrent code around it, it seems like the curl/7.81.0 user-agent is only used when anonymous mode is enabled (I did enable it), and the torrent is a public torrent (this should NOT be the case!). And when I check the torrent, sure enough I don't see DHT/PeX/LSD disabled with a "this torrent is private" message!

Since I was able to download the torrent to 99% w/o get banned message, the torrent must initially a private torrent when added to qBittorrent, and suddenly becomes a public torrent at a later time.

I grabbed the $HASH.fastresume file and it indeed show disable_{dht,lsd,pex}: 0:

{
   "active_time": 218803,
   "added_time": 1713467502,
   "allocation": "allocate",
   "apply_ip_filter": 1,
   "auto_managed": 1,
   "banned_peers": "<hex>xxxx</hex>",
   "banned_peers6": "<hex>xxxx</hex>",
   "completed_time": 1713511697,
   "disable_dht": 0,
   "disable_lsd": 0,
   "disable_pex": 0,
   "download_rate_limit": -1,
   "file-format": "libtorrent resume file",
   "file-version": 1,
   "file_priority": [
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1
   ],
   "finished_time": 171117,
   "httpseeds": [],
   "i2p": 0,
   "info-hash": "<hex>xxxx</hex>",
   "info-hash2": "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000",
   "last_download": 1713511697,
   "last_seen_complete": 1713680617,
   "last_upload": 1713680616,
   "libtorrent-version": "2.0.10.0",
   "max_connections": 100,
   "max_uploads": 10,
   "name": "xxxx",
   "num_complete": 6,
   "num_downloaded": 16777215,
   "num_incomplete": 1,
   "paused": 0,
   "peers": "<hex>xxxx</hex>",
   "peers6": "",
   "pieces": "",
   "qBt-category": "cccc",
   "qBt-contentLayout": "Original",
   "qBt-firstLastPiecePriority": 0,
   "qBt-inactiveSeedingTimeLimit": -2,
   "qBt-name": "",
   "qBt-ratioLimit": -2000,
   "qBt-seedStatus": 1,
   "qBt-seedingTimeLimit": -2,
   "qBt-stopCondition": "None",
   "qBt-tags": [],
   "save_path": "xxxx",
   "seed_mode": 0,
   "seeding_time": 171117,
   "sequential_download": 0,
   "share_mode": 0,
   "stop_when_ready": 0,
   "super_seeding": 0,
   "total_downloaded": 9323709715,
   "total_uploaded": 5644609077,
   "trackers": [
      [
         "https://xxxx",
         "https://xxxx",
         "https://xxxx"
      ]
   ],
   "upload_mode": 0,
   "upload_rate_limit": -1,
   "url-list": []
}

Steps to reproduce

I don't know how to reproduce this issue, this seem to happen spontaneously when a torrent is almost finished download.

Additional context

No response

Log(s) & preferences file(s)

No response

@stalkerok
Copy link
Contributor

Are you sure you are describing the issue correctly? One and the same torrent cannot be private and public, only if it is two different torrents (with different hash).

@yegle
Copy link
Author

yegle commented Apr 21, 2024

The workaround I used was to download the torrent file again and add it to qBittorent.

Despite getting an error in the log:

Detected an attempt to add a duplicate torrent. Merging of trackers is disabled. Torrent: xxx

The torrent magically becomes private torrent again (DHT/PeX/LSD disabled with a "this torrent is private" message).

@yegle
Copy link
Author

yegle commented Apr 21, 2024

Are you sure you are describing the issue correctly? One and the same torrent cannot be private and public, only if it is two different torrents (with different hash).

It suddenly became public from what I can tell (using the DHT/PeX/LSD message). Unfortunately due to #14771 I can't be 100% sure.

And the libtorrent code doesn't lie, it indeed uses the special curl/7.81.0 user agent when anonymous mode is enabled and the torrent is considered "public".

@yegle
Copy link
Author

yegle commented Apr 21, 2024

And given the workaround I tried (used the workaround twice and fairly certain it does work), the "public" torrent in the queue and the private torrent file I downloaded again should have the same hash (or I won't see the log line).

@stalkerok
Copy link
Contributor

Perhaps the torrent is hybrid and that plays a role too.

@yegle
Copy link
Author

yegle commented Apr 21, 2024

Oh there's another symptom that I suspect is relevant.

When this happened to one of my torrents today, I was trying to confirm if the torrent file contains the "private" bit. But looking at the BT_backup folder, I can only find $HASH.fastresume file (the bencode decoded content is in the first comment) and there was no $HASH.torrent file.

After I tried the workaround of downloading and importing the torrent file, I now can find the $HASH.torrent file in BT_backup folder.

This is potentially relevant because tracker_req().private_torrent is set to false around https://github.com/arvidn/libtorrent/blob/8a7aa8311387b8d530a2ec2a3eb5974fec5edb64/src/http_tracker_connection.cpp#L247-L249, and the .private_torrent field seem to be set from m_torrent_file.priv() (e.g. https://github.com/arvidn/libtorrent/blob/8a7aa8311387b8d530a2ec2a3eb5974fec5edb64/src/torrent.cpp#L3011).

@stalkerok
Copy link
Contributor

stalkerok commented Apr 21, 2024

A .torrent file cannot disappear by itself. In any case, need steps to reproduce the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants