Deon
Jan 06, 2009Nimbostratus
How To Concatenate Strings
OK, Newbie here. Trying to figure out how to concatenate strings properly in an iRule. Ive got the following code and the newaddr value is not being formatted like I expect.
when HTTP_RESPONSE {
set addr [IP::server_addr]
log local0. $addr
set c [getfield $addr "." 3]
set d [getfield $addr "." 4]
set newaddr [concat "1.1." $c "." $d]
log local0. $newaddr
HTTP::header insert "Server_ID" [IP::server_addr]
}
The intent of the iRule is to insert a somewhat obfuscated IP address of the member server as a header tag in the response. So, if the member server IP is 10.44.6.11, the desired tag value inserted would be "1.1.6.11". The result I am getting is "1.1. 6 . 11 ". How do I strip out the spaces around the vars c and d? Is there a better or more desirable way to do this than the code I've got here?
Thanks much!
-Deon