Some destinations not connecting via SAM

All around i2pd - a different implementation of the I2P protocol
Post Reply
anikey
Posts: 22
Joined: 30 Nov 2023 20:08

Some destinations not connecting via SAM

Post by anikey »

There's this weird thing going on, i have no idea how it happens.

Some sites, such as i2p-projekt.i2p open fine both on the http proxy and when trying with SAM (testing with netcat). In this case i connect to site over SAM, type the http headers and stuff, and it gives me a reply almost immediately.

Now there are some other sites (i notice this with tracker2.postman.i2p) that work ok with http proxy, but they don't connect with SAM. In this case, after me typing the http headers, it says "STREAM STATUS RESULT=OK" then just waits for a really long time and times out.

During this time, the log has some messages like "warn - Streaming: LeaseSet was not confirmed in 4000 milliseconds. Trying to resubmit" and "error - Streaming: No packets have been received yet".

But if i try to load the site in http proxy (browser), it opens (so it's not like the site is down).

This is some problem that prevents using things like qbittorrent, which uses SAM and seems to contact trackers also via SAM. (more specifically, i tried adding postman's tracker and also some other tracker to the same torrent, and that other tracker worked, while postman's tracker kept timing out all the time).

What could it possibly be? any way to fix?

ps. i use i2pd and have been trying connecting with SAM for some time already; i only tried doing this with java i2p once, and then java sam just gave error with something about unsupported something (when trying connect tracker2)

Edit: java i2p says: "Unsupported encryption options" when connecting to tracker2 via SAM bridge. Also, the whole thing described above, it does not get fixed when i add SIGNATURE_TYPE=7
anikey
Posts: 22
Joined: 30 Nov 2023 20:08

Re: Some destinations not connecting via SAM

Post by anikey »

Steps to reproduce this problem with netcat: (applicable to java i2p too, but beware of pings and timeouts, i.e just respond with PONG when it asks you)

Open two terminals.

In terminal 1, enter this command:

Code: Select all

nc <ip-of-i2p-router> 7656
That should open a netcat session with the SAM bridge.
Now type these two SAM commands to handshake and initialize:

Code: Select all

HELLO VERSION
SESSION CREATE STYLE=STREAM ID=testing123 DESTINATION=TRANSIENT inbound.length=2 outbound.length=2 inbound.quantity=3 outbound.quantity=3
That will create an i2p destination that we will use to contact.
Be sure not to close it until you're done following these instructions.

Then, in terminal 2, open another netcat session to the SAM bridge:

Code: Select all

nc <ip-of-i2p-router> 7656
Then enter these SAM commands to handshake and connect to a destination that should work (namely i2p-projekt.i2p, because it has both elgamal and ecies):

Code: Select all

HELLO VERSION
STREAM CONNECT ID=testing123 DESTINATION=i2p-projekt.i2p
It should now tell you that it connected successfully.

Now let's do a HTTP request:

Code: Select all

GET / HTTP/1.1

(empty newline at the end is important)
Now it should output some text about some redirection. That means it worked.

Now let's get to an ecies-only destination, such as tracker2.postman.i2p.
Close the netcat session in terminal 2, by pressing Ctrl-C.
In terminal 2, open another netcat session:

Code: Select all

nc <ip-of-i2p-router> 7656
And try to connect to that destination:

Code: Select all

HELLO VERSION
STREAM CONNECT ID=testing123 DESTINATION=tracker2.postman.i2p
This is where java i2p and i2pd diverge.
Java i2p will tell you "Unsupported encryption options".
i2pd will happily say that it connected.

Next steps are i2pd-specific.

In terminal 2 (without closing its netcat session), try to actually make a request to the postman tracker!

Code: Select all

GET / HTTP/1.1

What do we see here? It just waits... On and on.... On and on....

In some time (like a lot of time) it will eventially timeout (and will print a message in i2pd log).

But until it timed out, you can open i2pd console, then go to "SAM sessions", click the "testing123" session, then select the only destination there.
You will see at the bottom 1 stream listed (connected to 6a4kx...). This stream is the one you made to postman tracker. You will see that it will display some number sent, but 0 received.
anikey
Posts: 22
Joined: 30 Nov 2023 20:08

RESOLVED: Some destinations not connecting via SAM

Post by anikey »

Resolved!!
Thanks for helping, this is what it came down to:

You need to add 'i2cp.leaseSetEncType=4,0' to the SAM session create options!!

See discussion on github: https://github.com/qbittorrent/qBittorrent/issues/19625
User avatar
zzz
Posts: 155
Joined: 31 Mar 2018 13:15

Re: Some destinations not connecting via SAM

Post by zzz »

This is great detective work, thank you.

I'll add a recommendation to our bittorrent doc for clients to use 4,0. I also verified that both i2psnark and BiglyBT set 4,0.
Post Reply