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

SAM: can't connect to self #2005

Closed
anikey-from-i2p opened this issue Jan 8, 2024 · 9 comments
Closed

SAM: can't connect to self #2005

anikey-from-i2p opened this issue Jan 8, 2024 · 9 comments

Comments

@anikey-from-i2p
Copy link

Steps to reproduce:

Open three terminals, all with netcat to SAM port.

Terminal 1 (input only):

HELLO VERSION
SESSION CREATE STYLE=STREAM ID=testing DESTINATION=TRANSIENT SIGNATURE_TYPE=7 i2cp.leaseSetEncType=4,0 inbound.length=2 outbound.length=2 inbound.quantity=2 outbound.quantity=2
NAMING LOOKUP NAME=ME

Copy the VALUE of NAMING LOOKUP.

Terminal 2 (input only):

HELLO VERSION
STREAM ACCEPT ID=testing

Terminal 3 (input only):

HELLO VERSION
STREAM CONNECT ID=testing DESTINATION=<paste the VALUE from NAMING LOOKUP>

Then try communicating with terminal 2 and 3.

In java i2p, it works fine: messages from one side appear on the other with a slight delay (because of tunnels i guess).

In i2pd it does not work:

  • in the terminal with STREAM ACCEPT it prints the destination, but the messages sent from the other one do not appear
  • in logs it keeps saying about missing / not finding remote leaseset
  • in webconsole streams list there are 2 streams: one with received=0, another with sent=0

practical consideration

qbittorrent seems to like to connect to itself.

@Vort
Copy link
Contributor

Vort commented Jan 9, 2024

I confirm this behaviour, with 2.50.1-8-g5cf1961f.

@Vort
Copy link
Contributor

Vort commented Jan 9, 2024

Check for self address was added intentionally, with this commit: d81ca5f.

However, no one remember why it was needed to be done this way.

I tried to disable check here:

if (leaseSet->GetIdentHash () != GetIdentHash ())
{
LogPrint (eLogDebug, "Destination: New remote LeaseSet added");
m_RemoteLeaseSets[key] = leaseSet;
}
else
LogPrint (eLogDebug, "Destination: Own remote LeaseSet dropped");

Connection established correctly, nothing exploded.

But I can't be sure that it is safe to make such change of course.

@orignal
Copy link
Contributor

orignal commented Jan 9, 2024

I don't see a reason why a destination should be able to connect to itself. For testing purposes, just create two session. Hence this check was added to avoid some potential security breaches.

@Vort
Copy link
Contributor

Vort commented Jan 9, 2024

Probably related:
qbittorrent/qBittorrent#10791
arvidn/libtorrent#7479

@orignal
Copy link
Contributor

orignal commented Jan 9, 2024

I would prefer to return CANT_REACH_PEER error in this case

@zzzi2p
Copy link

zzzi2p commented Jan 9, 2024

after discussion, Java I2P agrees with orignal that we should send CANT_REACH_PEER, and propose to make that change in our code unless somebody can come up with a good reason why we should support loopback

@orignal
Copy link
Contributor

orignal commented Jan 10, 2024

cd08756

@anikey-from-i2p
Copy link
Author

I just thought i should report it because it also causes log spam with messages like "Remote LeaseSet not found" and "Can't send packets, missing remote LeaseSet, sSID=..."

@zzzi2p
Copy link

zzzi2p commented Jan 10, 2024

@orignal orignal closed this as completed Jan 25, 2024
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

4 participants