Network List interface
The Azion.networkList.contains()
interface can be used by edge functions on Edge Firewall to match an IP address against a specific network list. If the IP address informed is within the network list, it returns true
and the desired implementation logic can go on based on that information.
Syntax
Section titled Syntax Azion.networkList.contains(networklistID, ipAddress)
Parameters
Section titled ParametersParameter | Type | Description |
---|---|---|
networkListId | string | The ID of the network list to be used for matching. |
ipAddress | string | The IP address to be matched against the network list. |
Note: if the network list ID informed is incorrect, an error is thrown.
Find out more about Network Lists on the Azion Platform.
Return value
Section titled Return valuebool
: returns true
if the IP address is in the network list and false
if it’s not.
Usage
Section titled UsageBasic usage of Azion.networkList.contains()
with a specific IP address and network list ID:
addEventListener("firewall", (event) => {
let ip = event.request.metadata["remote_addr"] // Accessing the remote address
try { let found = Azion.networkList.contains(String(networkListId), ip); // Checking if the ip is in the list if (found) { event.deny(); // If it's in the list, deny the request } } catch (err) { event.console.error(`Error: `, err.stack); } });
Error handling
Section titled Error handlingIf an error occurs during the execution of Azion.networkList.contains()
, an exception may be thrown. Make sure to handle potential errors and provide appropriate error messages or fallback actions in your code.
Best practices
Section titled Best practices- Regularly update and maintain the network lists to ensure accurate matching and minimize false positives or false negatives.
- Combine network list matching with other security measures for comprehensive protection.
- Ensure the integrity and security of the network lists to prevent unauthorized modifications or access.
- Regularly review and update the network list configurations to address changing security threats and requirements.