Fortinet white logo
Fortinet white logo

Script Reference Guide

proxy_shared_table_lookup

PROXY:shared_table_lookup()

Looks up whether a key exists in the shared table. If the key exists, returns the corresponding value.

This function will fail if the table has not been created yet; it will not trigger the creation of a new table.

Returns the stored value if successful, otherwise, returns Boolean false. The returned value can be an Lua string, integer, or table. The table will be deserialized before returning, so the API will receive a Lua table.

Syntax

PROXY:shared_table_lookup(table_name, key);

Arguments

Name Description
table_name

A Lua string as the name of the shared table. This is the unique identification of a shared table. This parameter is mandatory.

The maximum length of this table name is 255.

key

The key can be a Lua string or integer. This parameter is mandatory.

The maximum length for the string is 255.

Events

Applicable in the following events:

  • RULE_INIT

  • HTTP events: HTTP_REQUEST, HTTP_RESPONSE, HTTP_DATA_REQUEST, HTTP_DATA_RESPONSE, BEFORE_AUTH, AUTH_RESULT, COOKIE_BAKE

  • SSL events: CLIENTSSL_HANDSHAKE, SERVERSSL_HANDSHAKE, CLIENTSSL_RENEGOTIATE, SERVERSSL_RENEGOTIATE

  • TCP events: TCP_ACCEPTED, TCP_CLOSED, SERVER_CONNECTED, SERVER_CLOSED, VS_LISTENER_BIND, SERVER_BEFORE_CONNECT

  • WAF events: WAF_REQUEST_BEFORE_SCAN, WAF_RESPONSE_BEFORE_SCAN, WAF_REQUEST_ATTACK_DETECTED, WAF_RESPONSE_ATTACK_DETECTED

Example

when HTTP_REQUEST { 
	table_name = "TableDemo1" 
	key1="keyString101" 
	ret = PROXY:shared_table_lookup(table_name,key1) 
	if ret then 
	   debug("===>>shared_table_lookup success: [Table:%s]  [%s]=[%s]\n", table_name, key1, ret) 
	else 
	   debug("===>>shared_table_lookup failed for key: [Table:%s] [%s]\n", table_name, key1) 
	end 
} 

Supported Version

FortiADC version 7.4.2 and later.

proxy_shared_table_lookup

PROXY:shared_table_lookup()

Looks up whether a key exists in the shared table. If the key exists, returns the corresponding value.

This function will fail if the table has not been created yet; it will not trigger the creation of a new table.

Returns the stored value if successful, otherwise, returns Boolean false. The returned value can be an Lua string, integer, or table. The table will be deserialized before returning, so the API will receive a Lua table.

Syntax

PROXY:shared_table_lookup(table_name, key);

Arguments

Name Description
table_name

A Lua string as the name of the shared table. This is the unique identification of a shared table. This parameter is mandatory.

The maximum length of this table name is 255.

key

The key can be a Lua string or integer. This parameter is mandatory.

The maximum length for the string is 255.

Events

Applicable in the following events:

  • RULE_INIT

  • HTTP events: HTTP_REQUEST, HTTP_RESPONSE, HTTP_DATA_REQUEST, HTTP_DATA_RESPONSE, BEFORE_AUTH, AUTH_RESULT, COOKIE_BAKE

  • SSL events: CLIENTSSL_HANDSHAKE, SERVERSSL_HANDSHAKE, CLIENTSSL_RENEGOTIATE, SERVERSSL_RENEGOTIATE

  • TCP events: TCP_ACCEPTED, TCP_CLOSED, SERVER_CONNECTED, SERVER_CLOSED, VS_LISTENER_BIND, SERVER_BEFORE_CONNECT

  • WAF events: WAF_REQUEST_BEFORE_SCAN, WAF_RESPONSE_BEFORE_SCAN, WAF_REQUEST_ATTACK_DETECTED, WAF_RESPONSE_ATTACK_DETECTED

Example

when HTTP_REQUEST { 
	table_name = "TableDemo1" 
	key1="keyString101" 
	ret = PROXY:shared_table_lookup(table_name,key1) 
	if ret then 
	   debug("===>>shared_table_lookup success: [Table:%s]  [%s]=[%s]\n", table_name, key1, ret) 
	else 
	   debug("===>>shared_table_lookup failed for key: [Table:%s] [%s]\n", table_name, key1) 
	end 
} 

Supported Version

FortiADC version 7.4.2 and later.