Skip to content

Commit

Permalink
Support dns addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
ligustah committed Apr 11, 2024
1 parent 692ba95 commit 8a7bde7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ libp2p = { version = "0.53.2", features = [
"kad",
"gossipsub",
"identify",
"dns",
] }
tokio = { version = "1.36.0", features = ["full"] }
eyre = "0.6.12"
Expand Down
12 changes: 8 additions & 4 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ async fn list_all(
) -> Result<Json<Vec<PremintTypes>>, (StatusCode, String)> {
match storage::list_all(&state.db).await {
Ok(premints) => Ok(Json(premints)),
Err(_e) => Err((
StatusCode::INTERNAL_SERVER_ERROR,
"Failed to list all premints".to_string(),
)),
Err(_e) => {
tracing::warn!("Failed to list all premints: {:?}", _e);

Err((
StatusCode::INTERNAL_SERVER_ERROR,
"Failed to list all premints".to_string(),
))
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ impl SwarmController {
noise::Config::new,
yamux::Config::default,
)?
.with_dns()?
.with_behaviour(|key| {
let message_id_fn = |message: &gossipsub::Message| {
let mut s = DefaultHasher::new();
Expand Down
14 changes: 13 additions & 1 deletion src/stdin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,19 @@ async fn process_stdin_line(ctl: ControllerInterface, line: String) {
if line.is_empty() {
return;
}
if line.starts_with("/ip4") {
if line.starts_with("/connect ") {
if let Err(err) = ctl
.send_command(ControllerCommands::ConnectToPeer {
address: (&line[9..]).parse().unwrap(),
})
.await
{
tracing::error!(
error = err.to_string(),
"Error sending connect to peer command"
);
};
} else if line.starts_with("/ip4") {
if let Err(err) = ctl
.send_command(ControllerCommands::ConnectToPeer { address: line })
.await
Expand Down

0 comments on commit 8a7bde7

Please sign in to comment.