@@ -99,17 +99,27 @@ impl Client {
99
99
}
100
100
}
101
101
} else {
102
- * gameprofile = Some ( GameProfile {
102
+ let profile = GameProfile {
103
103
id : login_start. uuid ,
104
104
name : login_start. name ,
105
105
properties : vec ! [ ] ,
106
106
profile_actions : None ,
107
- } ) ;
107
+ } ;
108
108
109
- // TODO: check config for encryption
110
- let verify_token: [ u8 ; 4 ] = rand:: random ( ) ;
111
- self . send_packet ( & server. encryption_request ( & verify_token, BASIC_CONFIG . online_mode ) )
109
+ if BASIC_CONFIG . encryption {
110
+ let verify_token: [ u8 ; 4 ] = rand:: random ( ) ;
111
+ self . send_packet (
112
+ & server. encryption_request ( & verify_token, BASIC_CONFIG . online_mode ) ,
113
+ )
112
114
. await ;
115
+ } else {
116
+ if ADVANCED_CONFIG . packet_compression . enabled {
117
+ self . enable_compression ( ) . await ;
118
+ }
119
+ self . finish_login ( & profile) . await ;
120
+ }
121
+
122
+ * gameprofile = Some ( profile) ;
113
123
}
114
124
}
115
125
@@ -118,34 +128,43 @@ impl Client {
118
128
server : & Server ,
119
129
encryption_response : SEncryptionResponse ,
120
130
) {
121
- let shared_secret = server. decrypt ( & encryption_response. shared_secret ) . unwrap ( ) ;
131
+ let shared_secret = match server. decrypt ( & encryption_response. shared_secret ) {
132
+ Ok ( shared_secret) => shared_secret,
133
+ Err ( error) => {
134
+ self . kick ( & error. to_string ( ) ) . await ;
135
+ return ;
136
+ }
137
+ } ;
122
138
123
139
if let Err ( error) = self . set_encryption ( Some ( & shared_secret) ) . await {
124
140
self . kick ( & error. to_string ( ) ) . await ;
125
141
return ;
126
142
}
143
+
127
144
let mut gameprofile = self . gameprofile . lock ( ) . await ;
128
145
146
+ let Some ( profile) = gameprofile. as_mut ( ) else {
147
+ self . kick ( "No Game profile" ) . await ;
148
+ return ;
149
+ } ;
150
+
129
151
if BASIC_CONFIG . online_mode {
130
152
match self
131
- . autenticate ( server, & shared_secret, & gameprofile . as_ref ( ) . unwrap ( ) . name )
153
+ . autenticate ( server, & shared_secret, & profile . name )
132
154
. await
133
155
{
134
- Ok ( profile ) => * gameprofile = Some ( profile ) ,
156
+ Ok ( new_profile ) => * profile = new_profile ,
135
157
Err ( e) => {
136
158
self . kick ( & e. to_string ( ) ) . await ;
159
+ return ;
137
160
}
138
161
}
139
162
}
140
163
141
- if let Some ( profile) = gameprofile. as_ref ( ) {
142
- if ADVANCED_CONFIG . packet_compression . enabled {
143
- self . enable_compression ( ) . await ;
144
- }
145
- self . finish_login ( profile) . await ;
146
- } else {
147
- self . kick ( "No Game profile" ) . await ;
164
+ if ADVANCED_CONFIG . packet_compression . enabled {
165
+ self . enable_compression ( ) . await ;
148
166
}
167
+ self . finish_login ( profile) . await ;
149
168
}
150
169
151
170
async fn enable_compression ( & self ) {
0 commit comments