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 holepunching - Initial implementation #830

Merged
merged 330 commits into from
Jun 9, 2023
Merged

Implement holepunching - Initial implementation #830

merged 330 commits into from
Jun 9, 2023

Conversation

dignifiedquire
Copy link
Contributor

Just opening this as a draft for tracking purpose

@RangerMauve
Copy link

Are you going to be testing this on mobile by any chance?

@dignifiedquire
Copy link
Contributor Author

Are you going to be testing this on mobile by any chance?

Yes, very much so

ramfox and others added 27 commits March 13, 2023 18:50
…f the client connection (#826)

* added `Conn` trait, `ClientConn`, & added more to `Server`, 
* `ClientConnManager`, `ClientConnWriter`, `ClientConnReader`
Implement structures that manage the connection from the server to the
client:

When the server "accepts" a connection (`accept` is not yet
implemented), it separates the write and read portions of the
connection. It should create a `ClientConnManager` to interact with the
connection. The `ClientConnManager` runs the `ClientConnWriter` and `ClientConnReader` in a loop.
The `ClientConnWriter` accepts notifications & relayed packets from the server & sends them to the client.
The `ClientConnReader` to reads any notifications or packets it wants
the server to relay from the client, & sends them to be processed in the
server.
The server should hold onto the `ClientConnManager`, and use that as
a handle to communicate with the `ClientConnWriter` to forward any
relayed packets, or to shutdown the connection with the client if
something goes wrong.
[WIP] Fix endpoint updates and deadlocks
…nnected clients (#846)

* add `Client` and `Clients`

`Client` will eventually be able to handle multiple `ClientConnManager`s, but for now, the lastest connection will be the one we hold onto

The server will use the `Clients` struct to manages all the clients connection to the server. It is how it will actually send the packets from one client to another.

* comments

* shutdown & creation of `Client` is sync

* add `types.rs` file

keep types used in multiple systems in the same file
The `ServerActor` does all the work of coordinating traffic on the server, including sending packets, forwarding packets, adding & removing clients, adding & removing packet forwarders, adding "watchers" (verified peers in the mesh that need to be kept informed about the topology of the network), and shutting down the server.
* `Server::new` & other `Server` methods
* `ClientConnHandler` & `PacketForwarderHandler` used to add new client connections and add and remove packet forwarders, respectfully.
* implement init_meta_cert
* temporarily(?) change node keys to `crypto_box keys
* test relaying packets from a client to the server to another client, as well as a client to the server to a packet forwarder


Co-authored-by: dignifiedquire <me@dignifiedquire.com>
* start implementation of bin/derper

* update crypto-box

* derper: expand structure

* implement basic http server functionality
dignifiedquire and others added 9 commits June 3, 2023 13:25
* ci: try latest cross

* try stable rust
* feat: use BASE32_LOWER_NOPAD for encoding of peerid and ticket

Unfortunately BASE32_LOWER_NOPAD is not a constant, so we have to use
BASE32_NOPAD and to_upper/to_lower.

Also use hex for encoding hashes. This is not a public format, since cids
should be encoded using Blake3Cid.

Get rid of the base64 dependency.

* docs: update docs to reflect that we now use base32

also use base32 for Hash.

* fix: make data-encoding non optional

we need it to format peerids and hashes
…efactoring (#1070)

* fix: add handling of --single parameter for stdout target

* fix: add handling of --single parameter for dir target

* test: add tests for --single paramter

both stdout and file output, but not resume

* fix: allow using Blake3Cid in tests even for the MSRV test
* get rid of DataSource::File

it's always named now, with the name being inferred from the path if not given

* refactor: move foo/mod.rs into foo.rs
Try and improve on the online stun test:

- It uses our own STUN server so we can control both sides.
- The stun server avoids a unneeded delay.
- Adds logging of STUN transaction IDs on both sides so we
  can correlate them

It's still a flaky test, but succeeds sometimes now.

---------

Co-authored-by: dignifiedquire <me@dignifiedquire.com>
Co-authored-by: Floris Bruynooghe <flub@devork.be>
We have flaky tests on platforms.  It's best to let them all run on
all platforms so we see all failures and have more debugging tools.
Sounds like we don't use this format and that makes the failures more
readable for humans.
This branch should now be stable enough that we should deny compiler
warnings again.

Fix resulting clippy error: no .into_iter() call on a reference
s.client_conn_handler(headers)
});
let tls_config = if serve_tls {
let contact = "d@iroh.computer".to_string(); // TODO: configurable.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes 😅 this should be done, I am not the contact person

}

const NO_CONTENT_CHALLENGE_HEADER: &str = "X-Tailscale-Challenge";
const NO_CONTENT_RESPONSE_HEADER: &str = "X-Tailscale-Response";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't look like this is terribly important, but we should probably change these headers.

self.network_send_wakers
.lock()
.unwrap()
.replace(cx.waker().clone());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably does not make a big difference, but I think you only have to store the waker if you return pending.

If this returns with n>0 we will return Ready.

for (buf_out, meta_out) in bufs.iter_mut().zip(metas.iter_mut()) {
match self.network_recv_ch.try_recv() {
Err(flume::TryRecvError::Empty) => {
self.network_recv_wakers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. If we return ready we don't have to store the waker.

src/hp/magicsock/conn.rs Show resolved Hide resolved
flub and others added 3 commits June 6, 2023 17:56
- use rooted fqdn
- use .context()? instead of .expect()
- typo
* fix: update integration tests

* fix: ignore NAT integration tests
The distinction is now just whether something is stored internally or externally.
@ramfox ramfox marked this pull request as ready for review June 8, 2023 17:18
flub and others added 5 commits June 9, 2023 10:58
This makes cargo-add respect the sorting as well, it's generally nicer
to find things.
The cargo check runs do not help with any speedup, they cost >20s, do
not test anything that's not already covered by other tests.  So
remove them.

Updates the cargo test invocations to:

- Use --workspace instead of deprecated --all.  We don't have a
  workspace crate yet though so could just remove it for now, but this
  is a bit more future-proof I guess.

- Use --all-features since we have no features that are incompatible
  with each other.  Let's keep it that way!

- Select the --lib --bins and --tests targets, --all-targets would
  include the benches which we probably don't want to run as part of the
  main test run, but we don't have any yet so that is also just
  future-proofing.
This test is now just a best effort, you need to run it with
--nocapture to see if it works or not.  Sad.
@dignifiedquire dignifiedquire changed the title [WIP] Implement holepunching Implement holepunching - Initial implementation Jun 9, 2023
Copy link
Contributor

@ramfox ramfox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's merge this bad boy and make incremental improvements after

Copy link
Collaborator

@Arqu Arqu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems simple enough, LGTM 😄

@dignifiedquire dignifiedquire merged commit 5c96bb3 into main Jun 9, 2023
@dignifiedquire dignifiedquire deleted the x-hp branch June 9, 2023 18:16
rklaehn added a commit to n0-computer/iroh-blobs that referenced this pull request Oct 22, 2024
matheus23 pushed a commit that referenced this pull request Nov 14, 2024
Implement holepunching - Initial implementation
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.

6 participants