LmenD
May 06, 2016Nimbostratus
Help with MySQL_Proxy iApp
I'm using the MySQL_Proxy iApp to load balance traffic between two MySQL servers. The associated iRule is generating error when clients attempt to connect to the virtual server. Would someone be able to assist me in determining the cause of the error message?
Here's the error message I'm seeing.
TCL error: mysql_irule - can't read "from_client_password": no such variable while executing "if { $from_client_xor_result eq $from_client_password } { log local0.debug "BIG-IP MySQL Proxy -- mysql client: good authentication. ..."
Here's a snippet of the iRule involed from its beginning to where the error message appears to originate.
when CLIENT_ACCEPTED {
array set mysql_pools {
"read" "mysql-slave.3306.pool"
"write" "mysql-master.3306.pool"
}
array set mysql_pools_reverse {
"mysql-slave.3306.pool" "read"
"mysql-master.3306.pool" "write"
}
array set authenticated_state {
"client" 0
"read" 0
"write" 0
}
array set replication {
"time" 5
"max_time" 30
}
log local0.debug "BIG-IP MySQL Proxy -- clientside initial connection"
set salt [b64encode [md5 [expr { int(100000000 * rand()) }]]]
set client_scramble_buff1 [string range $salt 0 7]
set client_scramble_buff2 [string range $salt 8 19]
set clientside_proxied_payload ""
set clientside_proxied_payload_replayed 0
set clientside_set_command_payload ""
set serverside_current_pool "read"
log local0.debug "BIG-IP MySQL Proxy -- clientside responding with server WELCOME packet"
set server_welcome_formatting "c1A19x1i1a8x1B16c1B16x13a12x1"
set server_welcome_args [list]
lappend server_welcome_args 10 "BIG-IP MySQL Proxy" 1 $client_scramble_buff1 0000110010100010 48 0000001000000000 $client_scramble_buff2
set server_welcome_length [string length [eval "binary format $server_welcome_formatting $server_welcome_args"]]
set server_welcome_packet "binary format s1x1c1$server_welcome_formatting $server_welcome_length 0 $server_welcome_args"
TCP::respond [eval $server_welcome_packet]
TCP::collect
}
when CLIENT_DATA {
if { $authenticated_state(client) != 1 } {
log local0.debug "BIG-IP MySQL Proxy -- clientside authenticated flag not set"
set clientside_payload [TCP::payload]
binary scan $clientside_payload c3cH2a* clientside_mysql_len clientside_mysql_num clientside_mysql_cmd clientside_mysql_arg
if { $clientside_mysql_num == 1 && $clientside_mysql_cmd eq "8f" } {
log local0.debug "BIG-IP MySQL Proxy -- mysql client: attempting to authenticate"
binary scan $clientside_mysql_arg @31A* from_client_user_payload
set from_client_user [substr $from_client_user_payload 0 "\000"]
binary scan [findstr $from_client_user_payload "\000" 3] A20A* from_client_password from_client_database
set from_client_hash_stage $client_scramble_buff1
append from_client_hash_stage $client_scramble_buff2 [sha1 [binary format H40 [class lookup $from_client_user mysql.app_data_group]]]
binary scan [binary format H40 [class lookup $from_client_user mysql.app_data_group]] c* from_client_xor_lhs
binary scan [sha1 $from_client_hash_stage] c* from_client_xor_rhs
set from_client_xor_buffer [list]
foreach l $from_client_xor_lhs r $from_client_xor_rhs {
lappend from_client_xor_buffer [expr { $l ^ $r }]
}
set from_client_xor_result [binary format c* $from_client_xor_buffer]
if { $from_client_xor_result eq $from_client_password } {
log local0.debug "BIG-IP MySQL Proxy -- mysql client: good authentication. "
set authenticated_state(client) 1