Skip to content

Commit

Permalink
Merge branch 'classes_fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
landro committed Apr 29, 2016
2 parents 99ab81f + fed915b commit 4b46e91
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ TesTcl has partial support for the `class` command. For example, we could test t
```tcl
rule classes {
when HTTP_REQUEST {
if { [class match [IP::remote_addr] equals blacklist] } {
if { [class match [IP::remote_addr] eq blacklist] } {
drop
} else {
pool main-pool
Expand Down
21 changes: 21 additions & 0 deletions examples/example_irule_classes.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package require -exact testcl 1.0.8
namespace import ::testcl::*

before {
event HTTP_REQUEST
class configure blacklist {
"blacklisted" "192.168.6.66"
}
}

it "should drop blacklisted addresses" {
on IP::remote_addr return "192.168.6.66"
endstate drop
run irules/classes_irule.tcl classes
}

it "should drop blacklisted addresses" {
on IP::remote_addr return "192.168.0.1"
endstate pool main-pool
run irules/classes_irule.tcl classes
}
11 changes: 11 additions & 0 deletions irules/classes_irule.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
rule classes {

when HTTP_REQUEST {
if { [class match [IP::remote_addr] eq blacklist] } {
drop
} else {
pool main-pool
}
}

}
2 changes: 1 addition & 1 deletion pkgIndex.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if { $::tcl_platform(platform) eq "java" } {
puts stderr "WARNING"
}

set files { assert.tcl it.tcl on.tcl onirule.tcl irulehttp.tcl iruleuri.tcl global.tcl ip.tcl }
set files { assert.tcl it.tcl on.tcl onirule.tcl irulehttp.tcl iruleuri.tcl global.tcl ip.tcl classes.tcl }
set sources {}
foreach {f} $files {
lappend sources [list source [file join $dir src $f]]
Expand Down
2 changes: 1 addition & 1 deletion src/classes.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ proc ::testcl::class {cmd args} {
lookup {
set item [lindex $args 0]
set classname [lindex $args 1]
return [::testcl::class match -value $item equals $classname]
return [::testcl::class match -value $item eq $classname]
}
element {
set index [lindex $args 0]
Expand Down
2 changes: 1 addition & 1 deletion src/disabled_commands_jtcl.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ saferename socket ::tcl::socket
saferename tell ::tcl::tell
saferename time ::tcl::time
saferename update ::tcl::update
saferename upvar ::tcl::upvar
#saferename upvar ::tcl::upvar
saferename vwait ::tcl::vwait

rename saferename {}

0 comments on commit 4b46e91

Please sign in to comment.