Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read auth_data_len from InitialHandshake packet instead of hard code #640

Merged
merged 7 commits into from
Nov 15, 2021

Conversation

guoyuanchao1202
Copy link
Contributor

Now

When Fake Slave receive initialHandshake packet from Master, it'll decodes this packet. The current implementation uses hard-coded methods to obtain auth_data_part_2.

Change

But actually we can get auth_data_len from initHandshake packet. We can use the same method to get auth_plugin_name(ref to MySQL Doc)

Test

I've tested this change with my local MySQL, it's ok

@guoyuanchao1202
Copy link
Contributor Author

Btw, when syncer receive an EOF Packet, it's means that user set 'BINLOG_DUMP_NON_BLOCK' flag in COM_BINLOG_DUMP command and there is no more binlog event now. master will send this Packet instead of blocking

client/auth.go Outdated
// auth_data is end with 0x00, max data length is 13 + 8 = 21
// ref to https://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::Handshake
maxAuthDataLen := 21
if c.capability&CLIENT_PLUGIN_AUTH != 0 && int(data[pos]) < maxAuthDataLen {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if int(data[pos]) is 9, resetOfAuthDataEndPos will equals pos. But as stated $len=MAX(13, length of auth-plugin-data - 8) in https://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::Handshake, resetOfAuthDataEndPos should be pos + 13 - 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, it's my fault. it's min_auth_data_len is 21, not max_data_len.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this pr is a little bit old, need to be updated :-)

@lance6716 lance6716 merged commit 95d05ef into go-mysql-org:master Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants