Wednesday 8 June 2011

Can it make a cup of coffee

Sometimes after weeks of troubleshooting network issues people ask in jest, can it make a cup of coffee?

when HTTP_REQUEST {
set coffee { 5)3;; 4(3;; 2+1-5+1;; 2|1 5|1]1;; 2\1-5/1;;_9_2;;\1_9/1}
set response "<html><head><title>Coffee 2.0</title></head><body><pre>"
switch [HTTP::uri] {
"/coffee" {
append response "<p>"
for {set x 0} {$x < [string length $coffee] } {incr x} {
set mychar [string index $coffee $x]
set myrepeat [string index $coffee [incr x]]
if {$mychar equals ";"} {
append response "<br>"
continue
}
append response [string repeat $mychar $myrepeat]
}
append response "<p></pre><i><small>Your coffee is served.<p>"
append response "The Virtual Coffee Machine<p>"
HTTP::respond 200 content $response
event disable all
}
}
}

 

F5 OS Version: 10.2.0
Author: Kevin Davies

Introductions

This blog has been setup for iRule aficionados as a lounge to publish iRules and anything related for discussion and comment. This is by no means a support channel but more a place to have some fun, go on about iRules and perhaps show off your own code.See the first post in this blog for how to publish to it.

Contributing

Hello and welcome to the iRules Magic Blog. If you have some code you want to share the login is irulesmagic and then the secret word is the first http event name. I am sure you can figure that out being a keen iRule developer. The simplest way to contribute to this blog is download windows live writer and install the plugin below.

Plugins
iRules Syntax Highlighting