-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
IPv6 canonical priority implemented differently from BEP-40 #7705
Comments
Another confusing thing is, according to the comments, if the ports are used for generating the CRC32-C checksum, they should be in network byte order. However, the actual code uses the host byte order ( libtorrent/src/torrent_peer.cpp Lines 59 to 60 in 9aada93
libtorrent/src/torrent_peer.cpp Lines 88 to 94 in 9aada93
P.S. None of these detail about endianness are mentioned at all in BEP-40... |
|
Correct me if I'm wrong, but instead of the implementation you linked to, I think the canonical priority code is using this implementation instead, which preserves endianness: libtorrent/include/libtorrent/io.hpp Lines 78 to 99 in 9aada93
libtorrent/include/libtorrent/io.hpp Lines 157 to 159 in 9aada93
You passed a libtorrent/src/torrent_peer.cpp Lines 88 to 91 in 9aada93
Also any comment about the IPv6 masks? Edit: I realise I might be sounding like I just wanted to nitpick. So to clarify, what I want to know is, which version should other implementations be following? IMO if the BEP is going to stay the same, then all implementations, including libtorrent, should be following it. |
I will investigate the logic and get back to you. I agree that libttorrent does not appear to implement the BEP correctly. Regarding the endianness, both the pointer and span versions of write_impl() produces a big endian representation. The both loop over the value, shifting down the most significant byte first. |
Please do, thank you very much for your work.
My bad, turns out I'm wrong after all, so thanks for being patient with me. Embarrassingly, before typing my previous comment, I even copied into the code into godbolt to test, and somehow still thought it outputs little endian... To set records straight, https://godbolt.org/z/d1v7ofvMq proves that |
thanks for the report! It's addressed here #7743 |
Please provide the following information
libtorrent version (or branch):
RC_2_0
platform/architecture: N/A
compiler and compiler version: N/A
libtorrent's current canonical peer priority calculation for IPv6 only uses 3 masks, but according to BEP-40, there should be 10 possible masks to choose from.
I wonder what's the history on this. Was this intentional? Or libtorrent's implemention is simply outdated.
libtorrent/src/torrent_peer.cpp
Lines 98 to 102 in 9aada93
The text was updated successfully, but these errors were encountered: