Documentation ¶
Index ¶
Constants ¶
const ( // Speaks 4.1 protocol. ClientProtocol41 = 0x00000200 // Can do 4.1 authentication. ClientPluginAuth = 0x00008000 )
Capability flags.
const (
UTF8GeneralCI = 0x21
)
Character sets.
Variables ¶
var ComQUIT = []byte{1, 0, 0, 0, 1}
ComQUIT is a complete MySQL packet of COM_QUIT. https://dev.mysql.com/doc/internals/en/com-quit.html
Functions ¶
func NewHealthCheckPacket ¶
NewHealthCheckPacket creates MySQL packet for health checking with given username. NOTE: The returned bytes contains two MySQL packets in the following order: 1. HandshakeResponse 2. Command QUIT
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker does health checking with MySQL protocol. It does a login and expecting an reply.
func NewChecker ¶
func NewChecker(config *hc.MySQLChecker) (*Checker, error)
NewChecker creates MySQLChecker.
type HandshakeResponse ¶
type HandshakeResponse struct { CapabilityFlags uint32 MaxPacketSize uint32 CharacterSet uint8 Reserved [23]uint8 Username string // AuthResponse should be a string but password is not used yet, so it will always be a \0. AuthResponse uint8 }
HandshakeResponse is composed as follows: https://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::HandshakeResponse 4 capability flags, CLIENT_PROTOCOL_41 always set 4 max-packet size 1 character set string[23] reserved (all [0]) string[NUL] username
if capabilities & CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA { lenenc-int length of auth-response string[n] auth-response } else if capabilities & CLIENT_SECURE_CONNECTION {
1 length of auth-response string[n] auth-response } else {
string[NUL] auth-response }
if capabilities & CLIENT_CONNECT_WITH_DB { string[NUL] database }
if capabilities & CLIENT_PLUGIN_AUTH { string[NUL] auth plugin name }
if capabilities & CLIENT_CONNECT_ATTRS { lenenc-int length of all key-values lenenc-str key lenenc-str value if-more data in 'length of all key-values', more keys and value pairs }
func (*HandshakeResponse) Bytes ¶
func (r *HandshakeResponse) Bytes() []byte
Bytes returns the payload as bytes.
type Header ¶
Header maps the header of a MySQL packet. https://dev.mysql.com/doc/internals/en/mysql-packet.html
func NewMySQLHeaderFromReader ¶
NewMySQLHeaderFromReader reads a MySQLHeader from reader.
func (*Header) PayloadLength ¶
PayloadLength returns length of payload.