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

Domain name parsing bug fix #612

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server/swimos_server_app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ percent-encoding = { workspace = true }
[dev-dependencies]
swimos_recon = { path = "../../api/formats/swimos_recon", features = ["async_parser"] }
tokio = { workspace = true, features = ["rt", "macros", "test-util"] }
rustls = { workspace = true }
swimos_form = { path = "../../api/swimos_form" }
swimos_messages = { path = "../../runtime/swimos_messages" }
hyper = { workspace = true, features = ["client"] }
14 changes: 6 additions & 8 deletions server/swimos_server_app/src/server/runtime/downlinks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,13 @@ where
match key {
CommanderKey::Remote(shp) => {
debug!(remote = %shp, "Handling request for remote command channel.");
let host_str: Text = shp.to_string().into();
let SchemeHostPort(scheme, host_name, port) = shp.clone();
if pending.push_remote_cmd(host_str.clone(), request) {
if pending.push_remote_cmd(host_name.clone().into(), request) {
tasks.push(
dns.resolve(host_name, port)
dns.resolve(host_name.clone(), port)
.map(move |result| Event::Resolved {
scheme,
host: host_str,
host: host_name.into(),
result,
})
.boxed(),
Expand Down Expand Up @@ -178,14 +177,13 @@ where
} = &request;
if let Some(shp) = remote.clone() {
debug!(remote = %shp, node = %address.node, lane = %address.lane, kind = ?kind, "Handling request for downlink to remote lane.");
let host_str: Text = shp.to_string().into();
let SchemeHostPort(scheme, host_name, port) = shp;
if pending.push_remote(host_str.clone(), request) {
if pending.push_remote(host_name.clone().into(), request) {
tasks.push(
dns.resolve(host_name, port)
dns.resolve(host_name.clone(), port)
.map(move |result| Event::Resolved {
scheme,
host: host_str,
host: host_name.into(),
result,
})
.boxed(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ use futures::{
Future, FutureExt, SinkExt, StreamExt,
};
use parking_lot::Mutex;
use rustls::ServerName;
use swimos_api::{
downlink::DownlinkKind,
error::DownlinkRuntimeError,
net::SchemeHostPort,
protocol::downlink::{
DownlinkNotification, DownlinkOperation, DownlinkOperationEncoder, ValueNotificationDecoder,
},
Expand Down Expand Up @@ -163,8 +163,8 @@ struct Endpoints {
}

fn check_hosts(actual: &str, expected: &str) {
let actual = actual.parse::<SchemeHostPort>().expect("Invalid host.");
let expected = expected.parse::<SchemeHostPort>().expect("Invalid host.");
let actual = ServerName::try_from(actual).expect("Invalid host.");
let expected = ServerName::try_from(expected).expect("Invalid host.");
assert_eq!(actual, expected);
}

Expand Down Expand Up @@ -265,7 +265,7 @@ impl FakeServerTask {
responder,
..
}))) => {
check_hosts(host.as_str(), URL);
check_hosts(host.as_str(), HOST);
let result = if sock_addrs.iter().any(|a| a == &addr) {
Ok(EstablishedClient {
tx: attach_tx.clone(),
Expand Down