R_Marc
Jun 10, 2014Nimbostratus
Need to access server IP in CLIENT_DATA
I need to make a modification to the TCP::payload with the target IP of the back-end server. I'm able to make the modifications (when there's one known target server) but I need to do this with a cluster of backend servers.
This sorta works, but breaks down if there are multiple back end servers, as another LB selection is made and so my modified payload doesn't always match the target server. Note, my goal is to not override the load balancing.
when CLIENT_DATA {
if { [TCP::payload] contains "(CONNECT_DATA=" } {
set selection [LB::select]
log local0. "LB server [lindex $selection 3]"
set ip_match [regexp -all -inline -indices [IP::local_addr] [TCP::payload]]
log local0. "[TCP::payload]"
foreach instance $ip_match {
set service_start [lindex $instance 0]
set original_tcp_length [TCP::payload length]
TCP::payload replace $service_start 14 [lindex $selection 3]
log local0. "[TCP::payload]"
TCP::payload replace 0 2 [binary format S1 [TCP::payload length]]
}
}
TCP::release
}