Brocade Virtual ADX OpenScript Programmer’s Guide (Support Manual do Utilizador Página 17

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 30
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 16
Brocade Virtual ADX OpenScript Programmer’s Guide 9
53-1003244-01
Basic anatomy of a script
2
Basic anatomy of a script
The basic example script (abc.pl) is designed to exercise access control based on a client’s IP
address and a running count of the total number of connections per virtual server port. As
displayed, it consists of the following elements:
Declaration Block – Declares the packages being used by the script.
Initialization block – Only evaluated once before the first run of the script.
User-defined method 1 – Method 1 is designed to handle a new TCP client connection request.
It is invoked on every TCP SYN received on the vport bind point.
User-defined method 2– Method 2 is designed to run on receiving a TCP CLOSE request from a
client.
# Access control based on client IP address
# and a running count of total number of
# connections per vip:vport.
use OS_TCP;
use OS_IP;
use feature 'State';
Declaration
Block
Initialization
Block
BEGIN {
# total_conns must persist across runs
state $total_conns;
# We want a /24 match. Could be an array too
$bad_ip = "171.68.2.";
}
User-dened
Method 1
sub TCP_CLIENT_SYN {
# Look for blacklisted subnet in src ip
if (OS_IP::src =~ m/$bad_ip/)
OS_TCP::reset;
else
$total_conns++;
}
User-dened
Method 2
sub TCP_CLIENT_CLOSE {
# If we let it in, no need to check really
if (OS_IP::src !~ m/$bad_ip/)
$total_conns--;
}
Script: “abc.pl”
Vista de página 16
1 2 ... 12 13 14 15 16 17 18 19 20 21 22 ... 29 30

Comentários a estes Manuais

Sem comentários