Forum Discussion
What_Lies_Bene1
Cirrostratus
Feb 01, 2006Combining Logical Operators
Hi all. Hope you're all well.
I'd like to reduce some scripts I have that are used to restrict and redirect traffic. Access is based on domain name and client IP address. We've multiple doma...
Feb 01, 2006
Data Groups (or classes) can be operated on as if they were a TCL list. You can use the TCL list commands to get the length of the list and extract elements. I'm unsure why you want to use an array for this.
If you want to convert the values in the lines of the list into an array, I guess I could understand that but you can still use the list commands to achieve the same goal.
Another question I have is why you are including the number of items after the address in the class item value? Here's some code that will take a class, pull out line by line, convert each line into a separate list (from the comma separated values) and extract the relevant information.
class port_mappings {
"10.10.10.10,4111,4121",
"10.10.10.20,5111,5121"
}
*** BEGIN iRule ***
when HTTP_REQUEST {
iterate through port_mappings class (as a list)
foreach line $::port_mappings {
Create a list from the current line
set item_list [split $line ","]
Extract item 0 (ip address)
set ip [lindex $item_list 0]
iterate through all the port numbers.
for {set x 1} {$x<[llength $item_list]} {incr x} {
set port [lindex $src_list $x]
}
}
}
*** END iRule ***
Sidenote, if you are trying to use the data group with the matchclass command to find a matching ip address, you could use findclass instead and have it return the trailing list of ports if you format the line like this and call findclass with a separator of a space.
"10.10.10.10 4111,4121"
Not sure if this helps you or not, but I hope it gives you some ideas...
-Joe
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