Skip to content

Commit bb7ba7b

Browse files
committed
Update
1 parent 9a9651c commit bb7ba7b

File tree

4 files changed

+9
-26
lines changed

4 files changed

+9
-26
lines changed

src/commands.rs

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ pub struct ClientHandshake {
1515
pub 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

src/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,6 @@ impl<B: MysqlShim<W>, R: Read, W: Write> MysqlIntermediary<B, R, W> {
393393
self.writer.write_all(&[0x00])?;
394394

395395
self.writer.flush()?;
396-
397-
println!("x22x {:?}", scramble);
398-
399396
{
400397
let (_seq, auth_response_data) = self.reader.next()?.ok_or_else(|| {
401398
io::Error::new(
@@ -406,8 +403,6 @@ impl<B: MysqlShim<W>, R: Read, W: Write> MysqlIntermediary<B, R, W> {
406403

407404
auth_response = auth_response_data.to_vec();
408405
}
409-
410-
println!("x2233x {:?}", auth_response);
411406
}
412407

413408
self.writer.set_seq(seq + 1);

src/packet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ impl<W: Write> PacketWriter<W> {
4444
self.to_write[3] = self.seq;
4545
self.seq = self.seq.wrapping_add(1);
4646

47-
println!("writer {:?}", &self.to_write[..]);
4847
self.w.write_all(&self.to_write[..])?;
4948
self.to_write.truncate(4); // back to just header
5049
}
@@ -94,6 +93,7 @@ impl<R: Read> PacketReader<R> {
9493
let bytes = &self.bytes[self.start..];
9594
unsafe { ::std::slice::from_raw_parts(bytes.as_ptr(), bytes.len()) }
9695
};
96+
9797
match packet(bytes) {
9898
Ok((rest, p)) => {
9999
self.remaining = rest.len();

src/value/decode.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ impl<'a> ValueInner<'a> {
138138
}
139139
ColumnType::MYSQL_TYPE_FLOAT => {
140140
let f = input.read_f32::<LittleEndian>()?;
141-
println!("read {}", f);
142141
Ok(ValueInner::Double(f64::from(f)))
143142
}
144143
ColumnType::MYSQL_TYPE_DOUBLE => {

0 commit comments

Comments
 (0)