beautypg.com

Example – Brocade Virtual ADX OpenScript API Guide (Supporting ADX v03.1.00) User Manual

Page 131

background image

Brocade Virtual ADX OpenScript API Guide

119

53-1003243-01

Methods

9

Example

In the following example, the script scans the payload to read the member information. If it finds
the ‘visitor’ string, it logs a warning on the log server and replaces ‘login.php' with 'visitor.php'. If it
finds other member information, it replaces 'login.php' with 'gold_login' or 'basic_login'.

use OS_HTTP_REQUEST;

use OS_PAYLOAD_INSPECT;

use OS_SLB;

sub HTTP_REQUEST {

if (OS_HTTP_REQUEST::url =~ /login/) {

OS_PAYLOAD_INSPECT::match(

‘gold_member’,

‘basic_member’,

‘visitor’

);

}

}

sub PAYLOAD_INSPECT_MATCHED {

my $index = OS_PAYLOAD_INSPECT::matched_idx();

if ( $index > 1 ) {

OS_SLB::log("Warning: Visitor login!");

OS_PAYLOAD_INSPECT::matched_replace(

"", 0,

"", 0,

‘login.php’, ‘visitor.php’

);

} else {

OS_PAYLOAD_INSPECT::matched_replace(

‘login.php’, ‘gold_login.php’,

‘login.php’, ‘basic_login.php’

);

}

}