mysql-proxy read_query方法实现执行特殊SQL后认证连接
Java代码
local authed = false
function read_query( packet )
if (authed == false) then
if packet:byte() == proxy.COM_QUERY then
if(packet:sub(2):lower() == "select 2013 from dual") then
authed = true
else
proxy.response.type = proxy.MYSQLD_PACKET_ERR
proxy.response.errmsg = "unauthed connection !!! "
return proxy.PROXY_SEND_RESULT
end
else
proxy.response.type = proxy.MYSQLD_PACKET_ERR
proxy.response.errmsg = "unauthed connection !!!"
return proxy.PROXY_SEND_RESULT
end
end
end