Check if incoming IP address is in the provided range
@dylan
code:
data:privatelast updated:3 years ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 800,000+ developers using the Pipedream platform
steps.
trigger
HTTP API
Deploy to generate unique URL
This workflow runs on Pipedream's servers and is triggered by HTTP / Webhook requests.
steps.
is_ip_in_list_of_subnets
auth
to use OAuth tokens and API keys in code via theauths object
params
IP address

The IP to check

{{event.client_ip}}
string ·params.ip
Subnets

Is the IP in this list of subnets? Provide a value in CIDR notation, e.g. 10.4.5.0/16. To add another subnet, click on the + button on the right.

[0]:
192.0.2.0/24
[1]:
92.188.61.0/24
array ·params.subnets
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps, params) => {
1
2
3
}
4
const { isInSubnet } = require('is-in-subnet'); 
return isInSubnet(params.ip, params.subnets)
steps.
exit_if_ip_not_in_subnet
auth
to use OAuth tokens and API keys in code via theauths object
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps) => {
1
2
3
4
}
5
if (!steps.is_ip_in_list_of_subnets.$return_value) {
  $end("IP not in range. Exiting")
}