-
Notifications
You must be signed in to change notification settings - Fork 317
feat(iroh): add initial scaffolding for WebRTC support #3440
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
fb83cc8
908eef3
676a6b3
54e9423
257bdb5
3496a19
a559b35
219915a
d4ce636
4a358f2
b87d3f8
7d4cfbd
dd02f37
b054362
829a419
f446b67
70aed13
42264d9
5aaf775
d5c14a5
b00e5ac
4540a68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,8 @@ use std::{collections::BTreeSet, net::SocketAddr}; | |
|
|
||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| use crate::{ChannelId, NodeId, PublicKey, RelayUrl}; | ||
| use crate::{NodeId, PublicKey, RelayUrl}; | ||
| use crate::webrtc_port::ChannelId; | ||
|
|
||
| /// Network-level addressing information for an iroh node. | ||
| /// | ||
|
|
@@ -42,10 +43,18 @@ pub struct NodeAddr { | |
| pub node_id: NodeId, | ||
| /// The node's home relay url. | ||
| pub relay_url: Option<RelayUrl>, | ||
| /// The node's webrtc port | ||
| /// The node's channel_id port | ||
| pub channel_id: Option<ChannelId>, | ||
| /// Socket addresses where the peer might be reached directly. | ||
| pub direct_addresses: BTreeSet<SocketAddr>, | ||
| /// Static Webrtc connection information for the node | ||
| pub webrtc_info: Option<WebRtcInfo>, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] | ||
| pub struct WebRtcInfo{ | ||
| /// The hash of the certificate, prefixed with the algorithm, e.g./ "sha-256, B1:....:4E" | ||
| pub cert_fingerprints: BTreeSet<String> | ||
| } | ||
|
|
||
| impl NodeAddr { | ||
|
|
@@ -56,6 +65,7 @@ impl NodeAddr { | |
| relay_url: None, | ||
| channel_id: None, | ||
| direct_addresses: Default::default(), | ||
| webrtc_info: None, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are these two separate fields?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be fixed. |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -91,6 +101,7 @@ impl NodeAddr { | |
| relay_url, | ||
| direct_addresses: direct_addresses.into_iter().collect(), | ||
| channel_id: None, | ||
| webrtc_info: None, | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -106,6 +117,22 @@ impl NodeAddr { | |
| relay_url, | ||
| channel_id, | ||
| direct_addresses: direct_addresses.into_iter().collect(), | ||
| webrtc_info: None, | ||
| } | ||
| } | ||
| /// Creates a new [`NodeAddr`] from its parts | ||
| pub fn from_parts_with_webrtc_info( | ||
| node_id: PublicKey, | ||
| relay_url: Option<RelayUrl>, | ||
| webrtc_info: Option<WebRtcInfo>, | ||
| direct_addresses: impl IntoIterator<Item = SocketAddr>, | ||
| ) -> Self { | ||
| Self { | ||
| node_id, | ||
| relay_url, | ||
| channel_id: None, | ||
| direct_addresses: direct_addresses.into_iter().collect(), | ||
| webrtc_info | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -128,6 +155,11 @@ impl NodeAddr { | |
| pub fn channel_id(&self) -> Option<&ChannelId> { | ||
| self.channel_id.as_ref() | ||
| } | ||
|
|
||
| /// Returns the WebRTC info | ||
| pub fn webrtc_info(&self) -> Option<&WebRtcInfo> { | ||
| self.webrtc_info.as_ref() | ||
| } | ||
| } | ||
|
|
||
| impl From<(PublicKey, Option<RelayUrl>, &[SocketAddr])> for NodeAddr { | ||
|
|
@@ -138,6 +170,7 @@ impl From<(PublicKey, Option<RelayUrl>, &[SocketAddr])> for NodeAddr { | |
| relay_url, | ||
| direct_addresses: direct_addresses_iter.iter().copied().collect(), | ||
| channel_id: None, | ||
| webrtc_info: None, | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding:
NodeAddr is used by the discovery system to locate nodes in the network. For discovery purposes, we only need the node_id to find a node. Once found, WebRTC connections are established through the standard offer/answer exchange process.
My concern:
Since WebRTC connections require dynamic offer/answer negotiation anyway, is it necessary to store static WebRTC information like channel_id and webrtc_info (certificate fingerprints) here?