Skip to content

Commit

Permalink
chore(connlib): upgrade domain version from 0.9 to 0.10 (#5028)
Browse files Browse the repository at this point in the history
  • Loading branch information
conectado committed May 20, 2024
1 parent deae9a9 commit 361aafb
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 90 deletions.
9 changes: 5 additions & 4 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ secrecy = "0.8"
hickory-resolver = { git = "https://github.com/hickory-dns/hickory-dns", rev="a3669bd80f3f7b97f0c301c15f1cba6368d97b63", features = ["tokio-runtime"] }
str0m = { version = "0.5", default-features = false }
futures-bounded = "0.2.1"
domain = { version = "0.9", features = ["serde"] }
domain = { version = "0.10", features = ["serde"] }
dns-lookup = "2.0"
tokio-tungstenite = "0.21"
rtnetlink = { version = "0.14.1", default-features = false, features = ["tokio_socket"] }
Expand Down
2 changes: 1 addition & 1 deletion rust/connlib/shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub use phoenix_channel::{LoginUrl, LoginUrlError};

use rand_core::OsRng;

pub type Dname = domain::base::Dname<Vec<u8>>;
pub type DomainName = domain::base::Name<Vec<u8>>;

/// Bundle ID / App ID that the client uses to distinguish itself from other programs on the system
///
Expand Down
8 changes: 4 additions & 4 deletions rust/connlib/shared/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod key;

pub use key::{Key, SecretKey};

use crate::Dname;
use crate::DomainName;

#[derive(Hash, Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq)]
pub struct GatewayId(Uuid);
Expand Down Expand Up @@ -157,7 +157,7 @@ pub struct RequestConnection {
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
pub struct ClientPayload {
pub ice_parameters: Offer,
pub domain: Option<Dname>,
pub domain: Option<DomainName>,
}

/// Represent a request to reuse an existing gateway connection from a client to a given resource.
Expand All @@ -171,7 +171,7 @@ pub struct ReuseConnection {
/// Id of the gateway we want to reuse
pub gateway_id: GatewayId,
/// Payload that the gateway will receive
pub payload: Option<Dname>,
pub payload: Option<DomainName>,
}

// Custom implementation of partial eq to ignore client_rtc_sdp
Expand All @@ -185,7 +185,7 @@ impl Eq for RequestConnection {}

#[derive(Debug, Deserialize, Serialize, Clone, Hash, PartialEq, Eq)]
pub struct DomainResponse {
pub domain: Dname,
pub domain: DomainName,
pub address: Vec<IpAddr>,
}

Expand Down
19 changes: 11 additions & 8 deletions rust/connlib/tunnel/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use connlib_shared::messages::{
Answer, ClientPayload, DnsServer, DomainResponse, GatewayId, Interface as InterfaceConfig,
IpDnsServer, Key, Offer, Relay, RelayId, RequestConnection, ResourceId, ReuseConnection,
};
use connlib_shared::{callbacks, Callbacks, Dname, PublicKey, StaticSecret};
use connlib_shared::{callbacks, Callbacks, DomainName, PublicKey, StaticSecret};
use domain::base::Rtype;
use ip_network::{IpNetwork, Ipv4Network, Ipv6Network};
use ip_network_table::IpNetworkTable;
Expand Down Expand Up @@ -44,11 +44,14 @@ const DNS_REFRESH_INTERVAL: Duration = Duration::from_secs(300);
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct DnsResource {
pub id: ResourceId,
pub address: Dname,
pub address: DomainName,
}

impl DnsResource {
pub fn from_description(description: &ResourceDescriptionDns, address: Dname) -> DnsResource {
pub fn from_description(
description: &ResourceDescriptionDns,
address: DomainName,
) -> DnsResource {
DnsResource {
id: description.id,
address,
Expand Down Expand Up @@ -297,7 +300,7 @@ pub struct ClientState {

#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct AwaitingConnectionDetails {
pub domain: Option<Dname>,
pub domain: Option<DomainName>,
gateways: HashSet<GatewayId>,
pub last_intent_sent_at: Instant,
}
Expand Down Expand Up @@ -612,7 +615,7 @@ impl ClientState {
self.dns_resources_internal_ips
.insert(resource_description.clone(), addrs.clone());

send_dns_answer(self, Rtype::Aaaa, &resource_description, &addrs);
send_dns_answer(self, Rtype::AAAA, &resource_description, &addrs);
send_dns_answer(self, Rtype::A, &resource_description, &addrs);

Ok(addrs.iter().copied().map(Into::into).collect())
Expand Down Expand Up @@ -715,7 +718,7 @@ impl ClientState {
fn on_connection_intent_to_resource(
&mut self,
resource: ResourceId,
domain: Option<Dname>,
domain: Option<DomainName>,
now: Instant,
) {
debug_assert!(self.resource_ids.contains_key(&resource));
Expand Down Expand Up @@ -771,7 +774,7 @@ impl ClientState {
self.dns_mapping.clone()
}

fn is_connected_to(&self, resource: ResourceId, domain: &Option<Dname>) -> bool {
fn is_connected_to(&self, resource: ResourceId, domain: &Option<DomainName>) -> bool {
let Some(resource) = self.resource_ids.get(&resource) else {
return false;
};
Expand All @@ -783,7 +786,7 @@ impl ClientState {
fn get_resource_ip(
&self,
resource: &ResourceDescription,
domain: &Option<Dname>,
domain: &Option<DomainName>,
) -> Vec<IpNetwork> {
match resource {
ResourceDescription::Dns(dns_resource) => {
Expand Down
Loading

0 comments on commit 361aafb

Please sign in to comment.