1 unstable release
0.1.1 | Jun 7, 2024 |
---|
#4 in #hole
161 downloads per month
Used in gday
53KB
843 lines
Note: this crate is still in early-development, so expect breaking changes.
gday_hole_punch
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
-
Peer A connects to a gday_contact_exchange_server using a function such as [
server_connector::connect_to_random_server()
]. -
Peer A creates a room in the server using [
ContactSharer::create_room()
] with a random room code. -
Peer A tells Peer B which server and room code to join, possibly by giving them a
PeerCode
(done via phone call, email, etc.). -
Peer B connects to the same server using [
server_connector::connect_to_server_id()
]. -
Peer B joins the same room using [
ContactSharer::join_room()
]. -
Both peers call [
ContactSharer::get_peer_contact()
] to get their peer's contact. -
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