~roger-booth/mysql-proxy/laminator

582 by jan at mysql
added a directly mapped routing example
1
---
2
-- print the socket information to all IP based routing
3
--
4
-- * setup one virtual IP per backend server
5
-- * let the proxy to all those IPs
6
-- * create a lua-table that maps a "client.dst.name" to a backend
7
8
---
9
-- print a address 
10
--
11
function address_print(prefix, address)
12
	print(("%s: %s (type = %d, address = %s, port = %d"):format(prefix,
13
		address.name or "nil",
14
		address.type or -1,
15
		address.address or "nil",
16
		address.port or -1)) -- unix-sockets don't have a port
17
end
18
19
---
20
-- print the address of the client side
21
--
22
function connect_server()
23
	address_print("client src", proxy.connection.client.src)
24
	address_print("client dst", proxy.connection.client.dst)
25
end
26
27
---
28
-- print the address of the connected side and trigger a close of the connection
29
--
30
function read_handshake()
31
	address_print("server src", proxy.connection.server.src)
32
	address_print("server dst", proxy.connection.server.dst)
33
34
	-- tell the client the server denies us
35
	proxy.response = {
36
		type = proxy.MYSQLD_PACKET_ERR,
37
		errmsg = "done"
38
	}
39
40
	return proxy.PROXY_SEND_RESULT
41
end
42