The Run Lua script policy item provides the capabilities of the Lua script language to make decisions and perform actions in policy.
Similar to the Run Javascript script policy item, you provide the body of a function which is called when the policy item is evaluated. This involves writing Lua script to perform actions and evaluate logic. Returning true or false specifies the policy path that the policy processing will take next.
The Lua runtime (script execution) environment has access to the full set of event data and global variables. You can access these by directly typing the relevant variable names into the script edit window or browsing for them using the Symbol Browser. You can also use Lua modules to gain access to other functionality provided by these modules, such as file system access, network services, access to COM objects etc. This makes the Lua script decision item very flexible and powerful.
By default an empty function is created called filter. This is the function that you must complete to provide the functionality for the policy item. Event data is shown as passed-in parameters to the function (in parentheses). The function by default returns true. You will need to modify the body of this function to perform the logic and actions you wish. Do not modify the function definition of the filter function, as this will prevent the function from working correctly.
All script must conform to Lua rules. The Lua script item in WinGate uses Lua 5.1. Documentation for Lua 5.1 is available online at http://www.lua.org/docs.html
To access event or global data in your script, you can either type the variable names in directly, or insert them at the cursor by clicking the Insert symbol button to open the Symbol Browser.
In this example the Lua script will check to see whether the user involved with the event (the policy is based on) is called bob. This is done through selecting the User.Name method from the Symbol Browser. If it is, then the global data counter called Bobs count will be incremented by 1 (by using the Data.GetCounter method from the Symbol Browser) and the Lua script policy item will return true (a Yes path). If it isnt bob then the Lua script policy item will simply return a false (a No path).
©2012 Qbik New Zealand Limited
no comments yet...
You can use basic Full-Text Searches against the page title and body to find matching articles. Use the following search modifiers to refine your query:
You can create a new account or reset your password at forum.wingate.com.