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

implement i2p_pex, peer exchange support for i2p torrents #7831

Merged
merged 1 commit into from
Jan 30, 2025
Merged

Conversation

arvidn
Copy link
Owner

@arvidn arvidn commented Jan 27, 2025

first draft. untested.

@zzzi2p
Copy link

zzzi2p commented Jan 27, 2025

thanks for doing this.

max_peer_entries=100 is a little much, since it's 32 bytes per,
although you're quite unlikely to see 100 peers on an i2p torrent.
Recommend ~32. Snark is currently at 24, which is its
per-torrent peer limit.

Re: how you store destinations/hashes for peers
(your comments in torrent.cpp, not directly related to i2p_pex)
I do recommend you base64decode() full destinations when you get them
and store them in binary to save some space.
You may also wish to cache and save the 32 byte hash with it
to avoid the hasher256() call every time.

But I don't recommend you discard the destination and store the
hash only; to look up the full destination every time is
pretty inefficient. Java I2P does have a LRU lookup cache for hash-to-destination
and that mitigates the inefficiency for you somewhat, i2pd does also.
But for best performance you should consider adding your own cache.

nothing else jumped out at me, but I'm not a c++ guy;
good luck with the testing

@mpeter50
Copy link

max_peer_entries=100 is a little much, since it's 32 bytes per,
although you're quite unlikely to see 100 peers on an i2p torrent.
Recommend ~32. Snark is currently at 24, which is its
per-torrent peer limit.

Wouldn't it make sense to have a config option for it, to make the implementation more future proof? I think this development would make I2P an interesting service to look into for more people, and also more visible at all.
Or would it not matter anyway because of the low bandwith?

@Vort
Copy link
Contributor

Vort commented Jan 28, 2025

untested

Simplest test which came to mind is to start torrent without tracker and add one peer, which use client with well tested I2P PEX support.
I looked if it can be done with client_test and found only this possibility:

// if non-empty, a peer that will be added to all torrents
std::string peer;

However, it looks like this feature is broken for i2p peers. Worth fixing I think.

Less reliable test was just adding random popular torrent and waiting until PEX support will appear in UI.

Magnet

magnet:?xt=urn:btih:323086d2d004b0ed0b6dd8da3d49e9e82626d03b&dn=I2P+Update+2.7.0&tr=http://tracker2.postman.i2p/announce.php

run.bat

client_test -f log.txt --alert_mask=all --enable_dht=false --i2p_hostname=127.0.0.1 --i2p_port=7656 --i2p_inbound_length=1 --i2p_outbound_length=1 magnet:?xt=urn:btih:323086d2d004b0ed0b6dd8da3d49e9e82626d03b^&dn=I2P+Update+2.7.0^&tr=http://tracker2.postman.i2p/announce.php

Results

lt_i2pdl

But there was no success with it: if I understand UI correctly, dark blue letter "p" in this case image means PEX wasn't used.

@arvidn arvidn force-pushed the i2p-pex branch 3 times, most recently from 7353b75 to 77a35ff Compare January 29, 2025 22:45
@arvidn arvidn marked this pull request as ready for review January 30, 2025 00:40
@arvidn
Copy link
Owner Author

arvidn commented Jan 30, 2025

I believe this works now, if anyone wants to give it a shot

@Vort
Copy link
Contributor

Vort commented Jan 30, 2025

to give it a shot

I saw white letter "p" in my test with 77a35ff:

image

Also log now contains messages like ==> I2P_PEX_FULL [ added: 1 msg_size: 67 ] and ==> I2P_PEX_DIFF [ dropped: 0 added: 5 msg_size: 67 ].
Is this enough to say "it works"?

@arvidn arvidn force-pushed the i2p-pex branch 2 times, most recently from 8de14b9 to ebc13e0 Compare January 30, 2025 10:51
@arvidn arvidn merged commit b43dbb9 into master Jan 30, 2025
43 checks passed
@arvidn arvidn deleted the i2p-pex branch January 30, 2025 21:09
@Neustradamus
Copy link

@arvidn: Good job, thanks!

Linked to:

Do not stop to add all improvements needed to have a perfect I2P support :)

I2P issues search:

Can you look for DHT?

I2P BitTorrent details:

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

Successfully merging this pull request may close these issues.

5 participants