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 1
1
[package ]
2
2
name = " mc-oauth"
3
- version = " 0.1.5 "
3
+ version = " 0.1.6 "
4
4
edition = " 2021"
5
5
6
6
[dependencies ]
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ use bytes::{BufMut, BytesMut};
19
19
use cfb8:: Encryptor ;
20
20
use std:: { sync:: Arc , time:: Duration } ;
21
21
use tokio:: net:: TcpStream ;
22
- use tracing:: { debug, info} ;
22
+ use tracing:: { debug, error , info} ;
23
23
use uuid:: Uuid ;
24
24
25
25
#[ derive( Debug ) ]
@@ -77,7 +77,17 @@ impl MinecraftClient {
77
77
}
78
78
}
79
79
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 < ( ) > {
81
91
loop {
82
92
let mut temp_buf = vec ! [ 0 ; 1024 ] ;
83
93
self . stream . readable ( ) . await ?;
Original file line number Diff line number Diff line change @@ -97,13 +97,10 @@ async fn main() -> anyhow::Result<()> {
97
97
98
98
tokio:: spawn( async move {
99
99
// Setting client timeout
100
- match timeout(
100
+ timeout(
101
101
Duration :: from_secs( config. server. timeout) ,
102
102
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) ; } )
107
104
} ) ;
108
105
} ,
109
106
Err ( e) => {
You can’t perform that action at this time.
0 commit comments