PurpleI2P / i2pd

🛡 I2P: End-to-End encrypted and anonymous Internet
https://i2pd.website
BSD 3-Clause "New" or "Revised" License
3.22k stars 415 forks source link

RouterInfo and Lease Set queries #2081

Open sxlissxn opened 1 month ago

sxlissxn commented 1 month ago

Hello, i'm conducting a simulation of I2pd in a self-contained environment. I'm having a few issues... Currently it requires the simulation of the reseed server for boostraping and floodfill routers. Those entities requires the su3 files, which can be generated using some available tools. However, the su3 is constructed using the routerinfo.dat files, but the i2pd routers only generates the router.info files. Based on my research the routerinfo.dat file contains additional metadata.Thus are there ways to generate the router.info files and lease sets for a given number of simulated routers?

Vort commented 1 month ago

I don't know exact answer to your question. However, as far as I know, I2P network can work without reseeds, but you need to manually copy some starting routerinfos to netDb directories. Here is some example code: https://codeberg.org/weko/i2pd-test-tools/src/commit/4663af6da3b511af1c066940a8535ea32cb15eaf/start_testnet.py. Also you can look how reseeds work here: https://github.com/PurpleI2P/pyseeder

sxlissxn commented 1 month ago

thanks :) i did the reseeding manually, however, i am unsure about whether its the reseed which is causing this: Screenshot_20240814_165208 image Are there ways to solve this?

Vort commented 1 month ago

Not enough nodes maybe? You can look if nodes make connections at all: /debug - SSU2: Connecting to ip:port (hash) /debug - NTCP2: Connecting to ip:port (hash)

Also you need some nodes to have floodfill option enabled.

sxlissxn commented 4 weeks ago

i have simulated 15 i2pd routers, however, is the self-contained characteristic of my simulation tool causing the peer discovery issue? i have filled the NetDB, have floodfill and reseed server but i still get the same error. image image

Vort commented 4 weeks ago

How IP addresses for your nodes look like? Also it worth checking for connections as I said before.

There may be bugs in simulation tool of course, but first of all, more probable variants should be checked.

sxlissxn commented 3 weeks ago

for the ip addresse , now i am getting those errors, the nodes are not making connection at all: image

Vort commented 3 weeks ago

Try using "real" addresses like 1.1.1.1 - 1.1.1.254 for example. I think simulation environment should allow it.

Not sure if errors will go away, there may be more problems, but changing IP addreses is worth to try.

sxlissxn commented 3 weeks ago

It does not work :( For the peer selection, does it take it from the NetDB? Since i am not connecting to the internet for the simulation, i had to manually add files to the netDB and create the su3 files, is the fact that i changed the extension from router.info to routerInfo-Id.dat probably creating this issue?

Vort commented 3 weeks ago

It does not work :(

Maybe it worth to try something simpler than i2pd first - web server (nginx) and web client (curl) for example. Or custom made tcp server and client.

For the peer selection, does it take it from the NetDB?

Yes, but problem in your case appears much earlier: Node can't open its own ports. It makes no sense trying to connect to other nodes in such case. This problem should be solved first.

sxlissxn commented 3 weeks ago

Maybe it worth to try something simpler than i2pd first - web server (nginx) and web client (curl) for example. Or custom made tcp server and client.

I've already tried those early this year.

Try using "real" addresses like 1.1.1.1 - 1.1.1.254 for example. I think simulation environment should allow it. I was able to solve the binding problem by assigning ip addresses using the simulation configuration file instead of the i2pd configuration file. image However, i'm still having issues with the peer connection and now i am facing a new issue: image

Vort commented 3 weeks ago

However, i'm still having issues with the peer connection

Do you see Connecting messages like I mentioned eariler?

and now i am facing a new issue:

I don't think this error is much important. And it affects only SSU2. NTCP2 should be unaffected.

Vort commented 3 weeks ago

Also I suggest to look at routerinfos inside of netdb directory for your nodes. Do they have host and port specified? What caps they have? image

sxlissxn commented 3 weeks ago

image

Vort commented 3 weeks ago

PfG caps are not right. Why transit is disabled? It should not be like that. Also where this RI was located? In netdb of node with other IP (like 100.0.0.2)?

upd: It should be possible to use this node as floodfill, but no tunnels through it will be possible. upd2: Another thing to check: node can be banned because of unreachability if you started it little later than it was contacted by other node. It is better to clear peerProfiles directory just in case. And start first node slightly earlier than others.

sxlissxn commented 3 weeks ago

this is the router.info found in the data directory for that specific i2pd router.I haven't enabled the no transit

Vort commented 3 weeks ago

this is the router.info found in the data directory for that specific i2pd router

It should appear in netdb directory of other routers, in some way, either manually (which I suggest to try first) or with the help of reseeds. With different name, like this one: netDb\r6\routerInfo-6NcDCoHU0H2TRBEANjcZaonkqPtYYn2wnCIHAfILZPE=.dat. This name is made by hashing part of RI contents.

I haven't enabled the no transit

Ok, maybe this situation will correct itself somehow (with simulation of longer duration for example).

sxlissxn commented 3 weeks ago

i added the routerInfo manually to the netDB.However, i though that "6NcDCoHU0H2TRBEANjcZaonkqPtYYn2wnCIHAfILZPE=" was the router ID and not hashed part of the RI content... I've set the simulation for 30 min, however, due to the errors in tunnel creations it lasts only 15-20 seconds

Vort commented 3 weeks ago

Router Ident is calculated with hashing. I was saying it because if you have RI file of "unknown" router, you can calculate such ID without additional information.

i added the routerInfo manually to the netDB

So other routers have this file? They should try to make connections to this router then.

Vort commented 3 weeks ago

I made test by myself, with two virtual machines. First machine, 100.0.0.1, hosted floodfill with such config:

bandwidth = P
floodfill = true
loglevel = debug

host = 100.0.0.1
port = 1024

[reseed]
urls =
yggurls =

Second virtual machine, 100.0.0.2, hosted regular node:

bandwidth = P
floodfill = false
loglevel = debug

[reseed]
urls =
yggurls =

After I placed floodfill (node1) RI into correct place, i2pd_node2.zip\netdb\rK\routerInfo-k3Kki0MLyPKK-uhKZEosY80CM8AF~r8mupJxwsbMXQ8=.dat, second node was able to start making connection:

17:03:59@332/debug - SSU2: Connecting to 100.0.0.1:1024 (k3Kk)
...
17:03:59@332/debug - SSU2: Block type 0 of size 4
17:03:59@332/debug - SSU2: Datetime
17:03:59@332/debug - SSU2: Block type 13 of size 6
17:03:59@332/debug - SSU2: Address
17:03:59@332/info - SSU2: Our external address is 100.0.0.2:10849
...

You can look at full logs in these archives: i2pd_node1.zip i2pd_node2.zip Binaries are omitted to keep files small.

sxlissxn commented 2 weeks ago

Hello, I tried it tool on virtual machines, it works. I think the issue lies within the simulation tool itself and not within the i2pd configuration.

Vort commented 2 weeks ago

You may also check for time related problems. If simulation have zero timestamps at the start, it may cause problems. I don't know for sure if that's the case, but many programs have special meaning for zero values.

upd. Also you need to be sure that your RouterInfos are not from future and not too old. If timestamps in RouterInfos are too different from local time, i2pd will throw them away.


Also I suggest to compare debug logs made in virtual machine with logs made in simulation. There is high chance to have visible differences giving a clues.

sxlissxn commented 2 weeks ago

The timestamp in my simulation seems fine. The i2pd routers in my simulation are set up in such a way that it connects to the i2p network, however, is there a way to ensure that it does not connect to the i2p network but rather communicate with each other only (private network)?

Vort commented 2 weeks ago

is there a way to ensure that it does not connect to the i2p network but rather communicate with each other only

By clearing extra RouterInfos in netdb directories and setting

[reseed]
urls =
yggurls =

on each node.

My example with two nodes in virtual machines was set up this way.

You may also disable addressbook, but it should not prevent nodes from working anyway.