~jan-kneschke/mysql-proxy/packet-tracking-assertions

« back to all changes in this revision

Viewing changes to tags/mysql-proxy-0.6.1/lib/auditing.lua

  • Committer: Kay Roepke
  • Author(s): Jan Kneschke
  • Date: 2008-01-23 22:00:28 UTC
  • Revision ID: kay@mysql.com-20080123220028-hq2xqb69apa75fnx
first round on mysql-shell based on the proxy code

this is mostly a verification if the proxy-code is flexible enough to handle 
all three scenarios of: client, server and forwarding (proxy)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--[[
 
2
 
 
3
   Copyright (C) 2007 MySQL AB
 
4
 
 
5
   This program is free software; you can redistribute it and/or modify
 
6
   it under the terms of the GNU General Public License as published by
 
7
   the Free Software Foundation; version 2 of the License.
 
8
 
 
9
   This program is distributed in the hope that it will be useful,
 
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
   GNU General Public License for more details.
 
13
 
 
14
   You should have received a copy of the GNU General Public License
 
15
   along with this program; if not, write to the Free Software
 
16
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
 
 
18
--]]
 
19
 
 
20
local user = ""
 
21
 
 
22
function read_handshake( auth )
 
23
        print("<-- let's send him some information about us")
 
24
        print("    server-addr   : " .. auth.server_addr)
 
25
        print("    client-addr   : " .. auth.client_addr)
 
26
end
 
27
 
 
28
function read_auth( auth )
 
29
        print("--> there, look, the client is responding to the server auth packet")
 
30
        print("    username      : " .. auth.username)
 
31
 
 
32
        user = auth.username
 
33
end
 
34
 
 
35
function read_auth_result( auth )
 
36
        local state = auth.packet:byte()
 
37
 
 
38
        if state == proxy.MYSQLD_PACKET_OK then
 
39
                print("<-- auth ok");
 
40
        elseif state == proxy.MYSQLD_PACKET_ERR then
 
41
                print("<-- auth failed");
 
42
        else
 
43
                print("<-- auth ... don't know: " .. string.format("%q", auth.packet));
 
44
        end
 
45
end
 
46
 
 
47
function read_query( packet ) 
 
48
        print("--> '".. user .."' sent us a query")
 
49
        if packet:byte() == proxy.COM_QUERY then
 
50
                print("    query: " .. packet:sub(2))
 
51
        end
 
52
end
 
53
 
 
54