mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-15 01:47:19 +00:00
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:
parent
4e0fa55dcd
commit
061766859c
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user