Forum Discussion
Interpret a string as an IP address
Given the information I provided, you make a great point, Michael. This particular issue, however is going to be avoided. Let me explain.
The application's timeout is far less than one week, it coincides just fine with our TCP Profile's timeout. The weeklong persistence is to test upgraded code on a new web server. Effectively, my customer wants to insert a new server into the mix and send 10% of traffic to that server (using ratio's). To fully test the new website, he wants clients directed to the new server to "stay" on the new code/website for a week. Throughout that week, they can make as many connection and application login/logouts as they want, so long as they are on the new server for the whole week to fully test the new site.
All that said, I managed to test Kevin's solution, and it did indeed work! Thanks Kevin. I also found another solution that worked as well, even though I didn't fully understand it ;).
Kevin's Solution:
if { [HTTP::cookie exists "cPersist"] } {
set do_pool "pool [LB::server pool] member [b64decode [HTTP::cookie value cPersist]]"
eval $do_pool
} else {
set setCookie 1
}
}
Another solution:
if { [HTTP::cookie exists "cPersist"] } {
set nodeIP "[string tolower [b64decode [HTTP::cookie value cPersist]]]"
pool [LB::server pool] member $nodeIP
} else {
set setCookie 1
}
}
For some reason, when I did a "string tolower" on the decoded value, the Pool command took it correctly as an IP address. String toupper worked as well. But if I did neither, for some reason it was unable to intepret the decoded value as an IP address, even if it looked exactly like an IP address. Very strange, don't know what was going on. Even logged all three and couldn't see a difference in my logs:
Jul 23 11:47:56 local/tmm info tmm[5323]: Playing with nodeIP -- nodeIP: 192.168.212.31 upper: 192.168.212.31 lower: 192.168.212.31
Don't know. Eitherway, it looks like doing some sort of string manipulation to the b64decod value allowed the interpretter to properly interpret the result as an IP address. If anyone has any guesses as to why, I'd love to hear them ;)
Thanks everyone for your help.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
