#tcp-connection #peer #authenticated #hole #securely #gday #establish

gday_hole_punch

Establish an authenticated peer-to-peer connection using TCP hole-punching

1 unstable release

0.1.1 Jun 7, 2024

#4 in #hole

Download history 148/week @ 2024-06-03 13/week @ 2024-06-10

161 downloads per month
Used in gday

MIT license

53KB
843 lines

Note: this crate is still in early-development, so expect breaking changes.

gday_hole_punch

Crates.io Version docs.rs

Want to send files easily, securely, and directly, without a relay or port forwarding? Then go to the gday page.

This library provides functions for two peers to establish a direct TCP connection.

This library is used by gday.


lib.rs:

Note: this crate is still in early-development, so expect breaking changes.

Lets peers behind NAT (network address translation) try to establish a direct authenticated TCP connection.

Uses TCP hole punching and a helper gday_contact_exchange_server to do this.

This library is used by gday, a command line tool for sending files.

Example steps

  1. Peer A connects to a gday_contact_exchange_server using a function such as [server_connector::connect_to_random_server()].

  2. Peer A creates a room in the server using [ContactSharer::create_room()] with a random room code.

  3. Peer A tells Peer B which server and room code to join, possibly by giving them a PeerCode (done via phone call, email, etc.).

  4. Peer B connects to the same server using [server_connector::connect_to_server_id()].

  5. Peer B joins the same room using [ContactSharer::join_room()].

  6. Both peers call [ContactSharer::get_peer_contact()] to get their peer's contact.

  7. Both peers pass this contact and a shared secret to [try_connect_to_peer()], which returns a TCP stream, and an authenticated cryptographically-secure shared key.

Dependencies

~14–24MB
~453K SLoC