Forum Discussion
boneyard
MVP
Mar 07, 2012looking to optimize / generalize irule
i have an irule which selects a pool based on several known items (think: uri, client ip, port). i have many of these sets, so some strings and a poolname. currently this is all hard coded in the irul...
boneyard
MVP
Mar 09, 2012looked around some more and found an alternative which will do the trick i believe, would this be acceptable code or is there something to change / make better?
please dont focus on the specifics, used variables might not make sense, it is the general idea.
class all_app_classes {
class_app1
class_app2
}
class class_app1 {
"ip" {"192.168.34.23"}
"port" {"45"}
"pool" {"pool_1"}
}
class class_app2 {
{
"ip" {"192.145.224.23"}
"port" {"55"}
"pool" {"pool_2"}
}
set id [class startsearch all_app_classes]
while { [class anymore all_app_classes $id] } {
set x [class nextelement all_app_classes $id]
set app_class [lindex $x 0]
log local0. "$app_class"
if { [TCP::local_port] == [class match -value port equals $app_class] and [IP::client_addr] == [class match -value ip equals $app_class] } {
log local0. "$app_class is the right class"
set saved_class $app_class
}
}
pool [class match -value pool equals $saved_class]
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects