Acl

Classin acl@fastly/js-compute 3.46.0since 3.32.0View source

Methods

lookup(ipAddress: string): Promise<{ action: 'ALLOW' | 'BLOCK'; prefix: string } | null>

Lookup a given IP address in the ACL list.

Parameters

ipAddress: string

Ipv6 or IPv4 IP address string

Returns

Promise<{ action: 'ALLOW' | 'BLOCK'; prefix: string } | null>

An object containing the ACL action and IP prefix if the given IP address matches an ACL entry, or null if there is no match.

import { Acl } from 'fastly:acl';
addEventListener('fetch', async (evt) => {
const myAcl = Acl.open('myacl');
const result = await myAcl.lookup(evt.client.address);
evt.respondWith(new Response(result?.action === 'BLOCK' ? 'blocked' : 'allowed'));
});

open

staticView source
static open(aclName: string): Acl

Opens the given ACL store by name

Parameters

aclName: string

Returns