Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Adds support for listening on and connecting to I2P and Onion services securely #3293

Merged
merged 43 commits into from
Sep 23, 2024

Conversation

eyedeekay
Copy link
Contributor

@eyedeekay eyedeekay commented Dec 27, 2023

This PR adds 2 dendrite-demo main's, each designed expressly to serve a Hidden Service/Overlay network.

The first, dendrite-demo-i2p add self-configuration for use of dendrite as an I2P hidden service(eepsite) and to connect to I2P services(federate) as an I2P client. It further disables the dendrite server from communicating with non-anonymous servers by federation(because I2P does not canonically have the ability to exit, we rely on donors for exit traffic), and enables the use of self-signed TLS certificates(because I2P services are self-authenticating but TLS is still required for other aspects of the system to work reliably). This demo turns the system into an "pseudonymous" homeserver which people can connect to using an I2P-enabled Matrix client(I like cinny and it's what I tested with).

The second, dendrite-demo-tor adds self-configuration for the use of dendrite as an Onion service and to connect to other onion services and non-anonymous web sites using Tor to obfuscate it's physical location and providing, optionally, pseudonymity. It also enables the use of self-signed TLS certificates, for the same reason as with I2P, because onion services aren't typically eligible for TLS certificates. It has also been tested with cinny.

These services are both pseudonymous like myself, not anonymous. I will be meeting members of the element team at the CCC assembly shortly to discuss contributing under my pseudonym.

As none of the other dendrite-demo have unit tests I did not add them to these checkins.

@eyedeekay eyedeekay requested a review from a team as a code owner December 27, 2023 19:28
@eyedeekay eyedeekay changed the title I2p demo Adds support for listening on and connecting to I2P and Onion services securely Dec 27, 2023
@eyedeekay
Copy link
Contributor Author

I hereby donate this code to Anoa.

@anoadragon453
Copy link
Member

I accept this donation and sign off on this code.

Signed-off-by: Andrew Morgan <andrewm@amorgan.xyz>

@eyedeekay
Copy link
Contributor Author

eyedeekay commented Dec 27, 2023

Moving this from README_I2P.md to here becasue README_I2P.md is about to me mostly irrelevant.

How to build a Dendrite Homeserver modified to run over I2P or Tor
==================================================================

I2P mode: I2P must be installed first, and the SAMv3 API bridge must
be activated.

1. First, clone the `matrix-org/dendrite` implementation of dendrite into your GOPATH and change branch to the `i2p-demo` checkout.


2. Second, build the binary:

    go build -o bin/dendrite-demo-i2p ./cmd/dendrite-demo-i2p

3. Third, run it.

    go build -o bin/dendrite-demo-i2p ./cmd/dendrite-demo-i2p

Tor mode: Tor must be installed first.

1. First, clone the `matrix-org/dendrite` implementation of dendrite into your GOPATH and change branch to the `i2p-demo` checkout.

2. Second, build the binary:

    go build -o bin/dendrite-demo-tor ./cmd/dendrite-demo-tor

3. Third, run it.

    go build -o bin/dendrite-demo-tor ./cmd/dendrite-demo-tor

@anoadragon453
Copy link
Member

(@eyedeekay I can officially confirm that the code donation above checks out 🙂)

@eyedeekay
Copy link
Contributor Author

I have demo instances up and running but I'm not sure how best to share them, as I have enabled open registration for now and don't think that I should make them that public. Let me know if there's a best way to share them with testers on your side.

@S7evinK
Copy link
Contributor

S7evinK commented Feb 29, 2024

Sorry for just moving this to contrib, as much as I like this contribution, I don't see us maintain this.
Hope this is OK with you, @eyedeekay

@anoadragon453
Copy link
Member

@eyedeekay heads up you have some CI failures

@eyedeekay
Copy link
Contributor Author

Yeah for some reason it's still running the failing tests, I'll have to find some other way to keep them from running

@eyedeekay
Copy link
Contributor Author

Well that was weirder than it should have been, lol. Turns out disabling the unit test just ran the main without any of the instrumentation, so the only way to fix it was to look for the CI in the demo application being tested. Works now though, locally and in CI. I see you fixed the linter errors so I'll leave it here until you have more feedback.

@eyedeekay
Copy link
Contributor Author

The demand for something like matrix-over-I2P is really growing from my side of things. As a result, I changed one fundamental thing about how this PR works I2P hosted dendrite servers. In the latest checkin, I changed it so that:

  • in the case where it attempts to make a server-to-server connection to a hostname which does not end in .i2p
  • it will attempt to contact it over Tor instead
  • allowing the I2P version to communicate with I2P, Onion, and regular-internet hosts if configured to do so.

I had not intended to do this until later in a future PR, but I think the demand for intra-overlay-network communication will be present fairly early when I deploy the I2P demo of Dendrite and if it's all the same to you, I'd rather do it in this PR.

@eyedeekay
Copy link
Contributor Author

At some point my onion-on-TLS listener support broke and I didn't notice until I tried running the onion version of this again. It is now fixed in onramp library 0.33.8 and I have also updated this PR to use the new library version.

@S7evinK
Copy link
Contributor

S7evinK commented Sep 22, 2024

@eyedeekay Are you fine with my changes regarding context? I'd like to finally get this merged. (you've already waited 3/4 of a year..)

Copy link

codecov bot commented Sep 22, 2024

Codecov Report

Attention: Patch coverage is 3.64078% with 397 lines in your changes missing coverage. Please review.

Project coverage is 67.68%. Comparing base (df770da) to head (1fea81a).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
contrib/dendrite-demo-i2p/main_i2p.go 7.69% 108 Missing ⚠️
contrib/dendrite-demo-tor/main_tor.go 5.50% 103 Missing ⚠️
contrib/dendrite-demo-i2p/main.go 0.00% 93 Missing ⚠️
contrib/dendrite-demo-tor/main.go 0.00% 93 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3293      +/-   ##
==========================================
- Coverage   68.26%   67.68%   -0.59%     
==========================================
  Files         513      518       +5     
  Lines       47030    47457     +427     
==========================================
+ Hits        32105    32119      +14     
- Misses      10916    11338     +422     
+ Partials     4009     4000       -9     
Flag Coverage Δ
unittests 52.90% <3.64%> (-0.40%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@eyedeekay
Copy link
Contributor Author

Testing on my side confirms that it all still works, so I'm ready with you are :)

@S7evinK S7evinK merged commit 6cd1285 into matrix-org:main Sep 23, 2024
18 of 20 checks passed
@S7evinK
Copy link
Contributor

S7evinK commented Sep 23, 2024

Sorry for the delay and thank you for your patience! :)

@kovalensky
Copy link

Dazzling!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants