File tree Expand file tree Collapse file tree 3 files changed +15
-8
lines changed
Expand file tree Collapse file tree 3 files changed +15
-8
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " mc-oauth"
3- version = " 0.1.5 "
3+ version = " 0.1.6 "
44edition = " 2021"
55
66[dependencies ]
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ use bytes::{BufMut, BytesMut};
1919use cfb8:: Encryptor ;
2020use std:: { sync:: Arc , time:: Duration } ;
2121use tokio:: net:: TcpStream ;
22- use tracing:: { debug, info} ;
22+ use tracing:: { debug, error , info} ;
2323use uuid:: Uuid ;
2424
2525#[ derive( Debug ) ]
@@ -77,7 +77,17 @@ impl MinecraftClient {
7777 }
7878 }
7979
80- pub async fn run ( & mut self ) -> Result < ( ) > {
80+ pub async fn run ( & mut self ) {
81+ match self . _run ( ) . await {
82+ Ok ( _) => info ! (
83+ "Connection from {:?} closed successfully" ,
84+ self . stream. peer_addr( ) . unwrap( )
85+ ) ,
86+ Err ( e) => error ! ( "Internal error occurred: {}" , e) ,
87+ }
88+ }
89+
90+ pub async fn _run ( & mut self ) -> Result < ( ) > {
8191 loop {
8292 let mut temp_buf = vec ! [ 0 ; 1024 ] ;
8393 self . stream . readable ( ) . await ?;
Original file line number Diff line number Diff line change @@ -97,13 +97,10 @@ async fn main() -> anyhow::Result<()> {
9797
9898 tokio:: spawn( async move {
9999 // Setting client timeout
100- match timeout(
100+ timeout(
101101 Duration :: from_secs( config. server. timeout) ,
102102 client. run( )
103- ) . await {
104- Ok ( _) => info!( "Connection from {} closed" , addr) ,
105- Err ( e) => error!( "Client exceptionally closed connection: {}" , e)
106- }
103+ ) . await . unwrap_or_else( |_| { error!( "Connection from {} has been timed out" , addr) ; } )
107104 } ) ;
108105 } ,
109106 Err ( e) => {
You can’t perform that action at this time.
0 commit comments