Spec-Zone .ru
спецификации, руководства, описания, API

15.7.4.4. Examining the Handshake with read_handshake()

Handshake information is sent by the server to the client after the initial connection (through connect_server()) has been made. The handshake information contains details about the MySQL version, the ID of the thread that will handle the connection information, and the IP address of the client and server. This information is exposed through the proxy.connection structure.

For example, you can print out the handshake data and refuse clients by IP address with the following function:

function read_handshake()        print("<-- let's send him some information about us")        print("    mysqld-version: " .. proxy.connection.server.mysqld_version)        print("    thread-id     : " .. proxy.connection.server.thread_id)        print("    scramble-buf  : " .. string.format("%q",proxy.connection.server.scramble_buffer))        print("    server-addr   : " .. proxy.connection.server.dst.name)        print("    client-addr   : " .. proxy.connection.client.dst.name)        if not proxy.connection.client.src.name:match("^127.0.0.1:") then                proxy.response.type = proxy.MYSQLD_PACKET_ERR                proxy.response.errmsg = "only local connects are allowed"                print("we don't like this client");                return proxy.PROXY_SEND_RESULT        endend

Note that you must return an error packet to the client by using proxy.PROXY_SEND_RESULT.