@@ -15,7 +15,6 @@ pub struct ClientHandshake {
1515pub fn client_handshake ( i : & [ u8 ] ) -> nom:: IResult < & [ u8 ] , ClientHandshake > {
1616 // mysql handshake protocol documentation
1717 // https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase_packets_protocol_handshake_response.html
18-
1918 let ( i, cap) = nom:: number:: complete:: le_u16 ( i) ?;
2019
2120 let mut capabilities = CapabilityFlags :: from_bits_truncate ( cap as u32 ) ;
@@ -34,26 +33,17 @@ pub fn client_handshake(i: &[u8]) -> nom::IResult<&[u8], ClientHandshake> {
3433 let ( i, username) = nom:: bytes:: complete:: take_until ( & b"\0 " [ ..] ) ( i) ?;
3534 let ( i, _) = nom:: bytes:: complete:: tag ( b"\0 " ) ( i) ?;
3635
37- println ! ( "iii {:?}" , i) ;
3836 let ( i, auth_response) =
3937 if capabilities. contains ( CapabilityFlags :: CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA ) {
40- println ! ( "iii0 {:?}" , i) ;
41-
4238 let ( i, size) = read_length_encoded_number ( i) ?;
4339 nom:: bytes:: complete:: take ( size) ( i) ?
4440 } else if capabilities. contains ( CapabilityFlags :: CLIENT_SECURE_CONNECTION ) {
45- println ! ( "iii1 {:?}" , i) ;
46-
4741 let ( i, size) = nom:: number:: complete:: le_u8 ( i) ?;
4842 nom:: bytes:: complete:: take ( size) ( i) ?
4943 } else {
50- println ! ( "iii2 {:?}" , i) ;
51-
5244 nom:: bytes:: complete:: take_until ( & b"\0 " [ ..] ) ( i) ?
5345 } ;
5446
55- println ! ( "iii3 {:?}" , i) ;
56-
5747 let ( i, db) =
5848 if capabilities. contains ( CapabilityFlags :: CLIENT_CONNECT_WITH_DB ) && !i. is_empty ( ) {
5949 let ( i, db) = nom:: bytes:: complete:: take_until ( & b"\0 " [ ..] ) ( i) ?;
@@ -65,8 +55,6 @@ pub fn client_handshake(i: &[u8]) -> nom::IResult<&[u8], ClientHandshake> {
6555
6656 let ( i, auth_plugin) =
6757 if capabilities. contains ( CapabilityFlags :: CLIENT_PLUGIN_AUTH ) && !i. is_empty ( ) {
68- println ! ( "iii55 {:?}" , i) ;
69-
7058 let ( i, auth_plugin) = nom:: bytes:: complete:: take_until ( & b"\0 " [ ..] ) ( i) ?;
7159
7260 let ( i, _) = nom:: bytes:: complete:: tag ( b"\0 " ) ( i) ?;
@@ -226,12 +214,13 @@ mod tests {
226214 #[ test]
227215 fn it_parses_handshake ( ) {
228216 let data = & [
229- 0x4f , 0x00 , 0x00 , 0x01 , 0x85 , 0xa6 , 0xff , 0x09 , 0x00 , 0x00 , 0x00 , 0x01 , 0x21 , 0x00 ,
217+ 0x5b , 0x00 , 0x00 , 0x01 , 0x8d , 0xa6 , 0xff , 0x09 , 0x00 , 0x00 , 0x00 , 0x01 , 0x21 , 0x00 ,
230218 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
231- 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x6a , 0x6f , 0x6e , 0x00 , 0x14 , 0xf7 ,
232- 0xd1 , 0x6c , 0xe9 , 0x0d , 0x2f , 0x34 , 0xb0 , 0x2f , 0xd8 , 0x1d , 0x18 , 0xc7 , 0xa4 , 0xe8 ,
233- 0x98 , 0x97 , 0x67 , 0xeb , 0xad , 0x6d , 0x79 , 0x73 , 0x71 , 0x6c , 0x5f , 0x6e , 0x61 , 0x74 ,
234- 0x69 , 0x76 , 0x65 , 0x5f , 0x70 , 0x61 , 0x73 , 0x73 , 0x77 , 0x6f , 0x72 , 0x64 , 0x00 ,
219+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x64 , 0x65 , 0x66 , 0x61 , 0x75 , 0x6c ,
220+ 0x74 , 0x00 , 0x14 , 0xf7 , 0xd1 , 0x6c , 0xe9 , 0x0d , 0x2f , 0x34 , 0xb0 , 0x2f , 0xd8 , 0x1d ,
221+ 0x18 , 0xc7 , 0xa4 , 0xe8 , 0x98 , 0x97 , 0x67 , 0xeb , 0xad , 0x64 , 0x65 , 0x66 , 0x61 , 0x75 ,
222+ 0x6c , 0x74 , 0x00 , 0x6d , 0x79 , 0x73 , 0x71 , 0x6c , 0x5f , 0x6e , 0x61 , 0x74 , 0x69 , 0x76 ,
223+ 0x65 , 0x5f , 0x70 , 0x61 , 0x73 , 0x73 , 0x77 , 0x6f , 0x72 , 0x64 , 0x00 ,
235224 ] ;
236225
237226 let r = Cursor :: new ( & data[ ..] ) ;
@@ -245,14 +234,14 @@ mod tests {
245234 assert ! ( handshake
246235 . capabilities
247236 . contains( CapabilityFlags :: CLIENT_MULTI_RESULTS ) ) ;
248- assert ! ( ! handshake
237+ assert ! ( handshake
249238 . capabilities
250239 . contains( CapabilityFlags :: CLIENT_CONNECT_WITH_DB ) ) ;
251240 assert ! ( handshake
252241 . capabilities
253242 . contains( CapabilityFlags :: CLIENT_DEPRECATE_EOF ) ) ;
254243 assert_eq ! ( handshake. collation, UTF8_GENERAL_CI ) ;
255- assert_eq ! ( handshake. username, & b"jon " [ ..] ) ;
244+ assert_eq ! ( handshake. username, & b"default " [ ..] ) ;
256245 assert_eq ! ( handshake. maxps, 16777216 ) ;
257246 }
258247
0 commit comments