proc
4 TopicsCalling procs dynamically
I have successfully tested calling procs like this: eval call [string tolower {HTTP::host}]::procName However, I'm trying to stop using HTTP::host directly because the TCL checker freaks completely out thinking things are out of context when this type of call is defined outside of an event. I understand that and am trying to work around it by using set host [string tolower [HTTP::host]] and all kinds of other dumbness. I'm not expanding/unpacking the variable properly. All of the following fail: call $host::procName $arg1 $arg2 eval call [string tolower {$host}]::procName $arg1 $arg2 eval [call {$host}]::procName $arg1 $arg2 However, as expected, using actualValueInHostVar::procname $arg1 $arg2 works perfectly. I know that someone out there can set me straight on this. Thanks.259Views0likes2Commentsproc - how to interpret
Hi, I am puzzled what is exact purpose of char declaration in proc below (from proc randomNumberGenerator {length {chars "0123456789"}} { set range [expr {[string length $chars]-1}] set txt "" for {set i 0} {$i < $length} {incr i} { set pos [expr {int(rand()*$range)}] append txt [string range $chars $pos $pos] } return $txt } (from article) I assume that char is receiving value (10) passed to proc via: set x [call library::randomNumberGenerator 10]. But what length {chars "0123456789"} is exactly doing here? Piotr251Views0likes3CommentsScope of variables when using call
Hi I have some irule code that looks like in one file MyLib_v1.0 proc process_URL {} { log local0. "process_URL: Enter" if { [ACCESS::session exists] && [ACCESS::session exists -state_allow -sid [ACCESS::session sid]] } { log local0. "process_URL: Has APM Session" set durl_ck -1 } else { log local0. "process_URL: No APM Session" if { [ HTTP::cookie exists $durl_ck_nm ] } { log local0. "process_URL: Has Cookie: $durl_ck_nm [HTTP::cookie $durl_ck_nm]" set durl_flag 1 set durl_url "https://[HTTP::host][HTTP::uri]" #set durl_url $str set durl_ck 1 } else { log local0. "process_URL: No Cookie" # I can't set the cookie normally have to do a redirect back to myself and set cookie at the same time ACCESS::disable set cookie [format "%s=%s; path=/; domain=%s; secure; HttpOnly; Max-Age=1200" $durl_ck_nm $durl_url ".test.com"] HTTP::respond 302 -version 1.1 Localtion "https://[HTTP::host][HTTP::uri]" "Set-Cookie" $cookie } } } when RULE_INIT { # The destination url set durl_url "" # Flag 0 do nothing # Flag 1 Want to dest set durl_flag 0 # What to do with cookie # -1 clear cookie in response # 0 do nothing # 1 set cookie in response set durl_ck 0 set durl_ck_nm "SomeCookie.durl" } # # Mark entry points here when HTTP_REQUEST priority 80 { # Some reason not calling init ? set durl_flag 0 set durl_ck 0 set durl_ck_nm "SomeCookie.durl" } # Do stuff with returning cookie when HTTP_RESPONSE priority 80 { if { $durl_ck == -1} { HTTP::cookie remove $durl_ck_nm set durl_ck 0 } elseif { ( $durl_flag == 1 ) && ( $durl_ck == 1) } { HTTP::cookie insert $durl_ck_nm value $durl_url domain ".test.com" path "/" HTTP::cookie domain $durl_ck_nm ".yieldbroker.com" HTTP::cookie maxage $durl_ck_nm 1200 HTTP::cookie attribute $durl_ck_nm insert "SameSite" "Strict" HTTP::cookie secure $durl_ck_nm enable HTTP::cookie httponly $durl_ck_nm enable } } F5 complains when it gets to the code in proc $durl_ck_nm not set ???? plus I had to add to each request when HTTP_REQUEST priority 80 { # Some reason not calling init ? set durl_flag 0 set durl_ck 0 set durl_ck_nm "yb.sso.durl" } because it loks like RULE_INIT is not running What am I missing ? Oh this is added as a resource to the VS and there is another irule file that call the above procSolved1.7KViews0likes7CommentsKnown limitation of HSL with proc
Hi, We have iRules in which we log using HSL. If log servers are down we log locally. We wanted to convert HSL logging to proc so that instead of writing these many lines of code just for logging we can use a proc. Is there any known of using HSL with proc. when CLIENT_ACCEPTED { set hsl [HSL::open -publisher $static::log_publisher] if { $log_hsl == 1 } { if {[active_members hsl_pool] < 1 ] } { log local0.info "Accepted client conn [IP::client_addr]:[TCP::client_port]" } else { HSL::send $hsl "$CLIENT_ACCEPTED_INFO Accepted client conn [IP::client_addr]:[TCP::client_port]" } } else { log local0.info "Accepted client conn [IP::client_addr]:[TCP::client_port]" } } Thanks Syed Nazir540Views0likes5Comments