Forum Discussion
Question about creating a guid in iRules
Interesting one! It seems like the parser gives this sort of error when it's defined with no input variables, though it does seem to function correctly anyway. Adding a dummy input variable eliminates the error. It's not very clear from our docs if it's supposed to require one or not.
This version of the script with just a dummy input variable added doesn't produce any errors or warnings:
proc CreateGuid foo {
append s [clock seconds] [IP::local_addr] [IP::client_addr] [expr { int(100000000 * rand()) }] [clock clicks]
set s [md5 $s]
binary scan $s c* s
lset s 8 [expr {([lindex $s 8] & 0x7F) | 0x40}]
lset s 6 [expr {([lindex $s 6] & 0x0F) | 0x40}]
set s [binary format c* $s]
binary scan $s H* s
append u [substr $s 0 8] "-" [substr $s 8 4] "-" [substr $s 12 4] "-" [substr $s 16 4] "-" [substr $s 20 12]
unset s
return $u
}
when HTTP_REQUEST {
log local0. "function return: [call CreateGuid 1]"
}
For clearing variables: The TCL variables are associated with the conn flow and will become un-set automatically when the flow expires. I still like to think that it's good programming practice to free all of your variables explicitly, so I usually try to remember to do it anyway, just in case some issue happens where a lot of connections are made at once, or whatever.
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