Skip to content

Commit

Permalink
fix: remove error!() usage
Browse files Browse the repository at this point in the history
  • Loading branch information
gotlougit committed Oct 26, 2023
1 parent 8d5507e commit 1d6b2ba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::config::Config;
use anyhow::Result;
use std::env;
use tracing::error;

mod client;
mod config;
Expand All @@ -20,7 +19,7 @@ async fn main() -> Result<()> {
// TODO: use clap crate for CLI arguments
let args: Vec<String> = env::args().collect();
if args.len() != 4 {
error!("Insufficient args entered! Usage: ./program client <file_to_get> or ./program server <file_to_serve> <pre_shared_secret>");
eprintln!("Insufficient args entered! Usage: ./program client <file_to_get> or ./program server <file_to_serve> <pre_shared_secret>");
}

// client mode or server mode
Expand All @@ -39,7 +38,7 @@ async fn main() -> Result<()> {
.await
.unwrap();
} else {
error!("Incorrect args entered!");
eprintln!("Incorrect args entered!");
}
Ok(())
}
4 changes: 2 additions & 2 deletions src/nat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::net::{SocketAddr, ToSocketAddrs};
use std::time::Duration;
use stunclient::StunClient;
use tokio::net::UdpSocket;
use tracing::{error, info, warn};
use tracing::{info, warn};

const DUMMY_MSG_NUM: usize = 5;
const MAX_WAIT_TIME: Duration = Duration::from_millis(500);
Expand Down Expand Up @@ -74,7 +74,7 @@ async fn get_external_info(socket: &UdpSocket, ip: String) -> SocketAddr {
x
}
Err(_) => {
error!("Error at protocol.rs: STUN");
eprintln!("Error at protocol.rs: STUN");
socket.local_addr().unwrap()
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use anyhow::Result;
use quinn::{ConnectionError, Endpoint, EndpointConfig, ServerConfig};
use std::sync::Arc;
use tokio::net::UdpSocket;
use tracing::error;

/// Constructs a QUIC endpoint configured to listen for incoming connections on a certain address
/// and port.
Expand Down Expand Up @@ -59,7 +58,7 @@ pub async fn run_server(
if msg.len() == 2 && msg[0] == filename && msg[1] == auth {
eprintln!("Got good message from client");
} else {
error!("Bad message; could not authenticate: {} {}", msg[0], msg[1]);
eprintln!("Bad message; could not authenticate: {} {}", msg[0], msg[1]);
}
let buffer = crate::file::get_file_contents(filename).await?;
tx.write_all(&buffer).await?;
Expand Down

0 comments on commit 1d6b2ba

Please sign in to comment.