MINOR: contrib/spoa_server: Add random IP score

The example configuration uses sess.ip_score however this variable
is not referenced within the example scripts.  This patch adds support
for sess.ip_score to the python + lua scripts and generates a
random number between 1 and 100.
This commit is contained in:
Daniel Corbett 2019-06-11 10:04:15 -04:00 committed by Willy Tarreau
parent 4e0fa55dcd
commit 061766859c
2 changed files with 4 additions and 0 deletions

View File

@ -1,4 +1,5 @@
require("print_r")
require("math")
print_r("Load lua message processors")
@ -14,4 +15,5 @@ spoa.register_message("check-client-ip", function(args)
spoa.set_var_ipv6("ipv6", spoa.scope.txn, "1::f")
spoa.set_var_str("str", spoa.scope.txn, "1::f")
spoa.set_var_bin("bin", spoa.scope.txn, "1::f")
spoa.set_var_int32("ip_score", spoa.scope.sess, math.random(100))
end)

View File

@ -1,6 +1,7 @@
from pprint import pprint
import spoa
import ipaddress
import random
def check_client_ip(args):
pprint(args)
@ -14,6 +15,7 @@ def check_client_ip(args):
spoa.set_var_ipv6("ipv6", spoa.scope_txn, ipaddress.IPv6Address(u"1::f"))
spoa.set_var_str("str", spoa.scope_txn, "1::f")
spoa.set_var_bin("bin", spoa.scope_txn, "1:\x01:\x02f\x00\x00")
spoa.set_var_int32("ip_score", spoa.scope_sess, random.randint(1,100))
return