diff options
author | open-trade <[email protected]> | 2020-03-09 19:35:57 +0800 |
---|---|---|
committer | open-trade <[email protected]> | 2020-03-09 19:35:57 +0800 |
commit | 2c35413d031c039eb6c152b00661f7ce14a53bb6 (patch) | |
tree | df86aa4f513469f09c81708e385c15402dc4eb8f /src | |
parent | 2812effd6dd09596081b5cb3b3d4c223c52a8dc6 (diff) | |
download | rustdesk-server-2c35413d031c039eb6c152b00661f7ce14a53bb6.tar.gz rustdesk-server-2c35413d031c039eb6c152b00661f7ce14a53bb6.zip |
debug!
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 9 | ||||
-rw-r--r-- | src/rendezvous_server.rs | 10 |
2 files changed, 13 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs index d1aad28..a59406e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,11 +2,12 @@ // https://blog.csdn.net/bytxl/article/details/44344855 use hbbs::*; -use std::error::Error; #[tokio::main] -async fn main() -> Result<(), Box<dyn Error>> { +async fn main() -> Result<(), Box<dyn std::error::Error>> { env_logger::init(); - RendezvousServer::start("0.0.0.0:21116").await?; + let addr = "0.0.0.0:21116"; + log::info!("Start Server {}", addr); + RendezvousServer::start(&addr).await?; Ok(()) -}
\ No newline at end of file +} diff --git a/src/rendezvous_server.rs b/src/rendezvous_server.rs index 571f446..3b7a7a1 100644 --- a/src/rendezvous_server.rs +++ b/src/rendezvous_server.rs @@ -26,7 +26,6 @@ impl RendezvousServer { pub async fn start(addr: &str) -> ResultType { let socket = UdpSocket::bind(addr).await?; let mut socket = UdpFramed::new(socket, BytesCodec::new()); - let mut rs = Self { peer_map: PeerMap::new(), }; @@ -46,6 +45,7 @@ impl RendezvousServer { match msg_in.union { Some(Message_oneof_union::register_peer(rp)) => { if rp.hbb_addr.len() > 0 { + log::debug!("New peer registered: {:?} {:?}", &rp.hbb_addr, &addr); self.peer_map .insert(rp.hbb_addr, Peer { socket_addr: addr }); } @@ -53,6 +53,12 @@ impl RendezvousServer { Some(Message_oneof_union::punch_hole_request(ph)) => { // punch hole request from A, forward to B if let Some(peer) = self.peer_map.get(&ph.hbb_addr) { + log::debug!( + "Punch hole {:?} {:?} request from {:?}", + &ph.hbb_addr, + &peer.socket_addr, + &addr + ); let mut msg_out = Message::new(); msg_out.set_punch_hole(PunchHole { socket_addr: AddrMangle::encode(&addr), @@ -64,6 +70,7 @@ impl RendezvousServer { Some(Message_oneof_union::punch_hole_sent(phs)) => { // punch hole sent from B, tell A that B ready let addr_a = AddrMangle::decode(&phs.socket_addr); + log::debug!("Punch hole response to {:?} from {:?}", &addr_a, &addr); let mut msg_out = Message::new(); msg_out.set_punch_hole_response(PunchHoleResponse { socket_addr: AddrMangle::encode(&addr), @@ -165,7 +172,6 @@ mod tests { let msg_in = parse_from_bytes::<Message>(&bytes).unwrap(); let remote_addr_b = AddrMangle::decode(&msg_in.get_punch_hole_response().socket_addr[..]); - println!("{:?}", msg_in); assert_eq!(local_addr_b, remote_addr_b); } |