All Projects → lifeblood → lua-resty-ipcidr

lifeblood / lua-resty-ipcidr

Licence: other
A simple and very fast function to check against CIDR

Programming Languages

perl
6916 projects
lua
6591 projects
Makefile
30231 projects

Projects that are alternatives of or similar to lua-resty-ipcidr

ip
Immutable value object for IPv4 and IPv6 addresses, including helper methods and Doctrine support.
Stars: ✭ 212 (+1147.06%)
Mutual labels:  ip, cidr
Motan Openresty
A cross-language RPC framework for rapid development of high performance distributed services based on OpenResty.
Stars: ✭ 117 (+588.24%)
Mutual labels:  luajit, openresty
Lua Resty Route
URL Routing Library for OpenResty Supporting Pluggable Matching Engines
Stars: ✭ 88 (+417.65%)
Mutual labels:  luajit, openresty
Aggregator
A stand-alone class implementation of the IPv4+IPv6 IP+CIDR aggregator from CIDRAM.
Stars: ✭ 19 (+11.76%)
Mutual labels:  ip, cidr
Lua Resty Redis Connector
Connection utilities for lua-resty-redis
Stars: ✭ 186 (+994.12%)
Mutual labels:  luajit, openresty
Lua Resty Post
HTTP post utility for openresty
Stars: ✭ 30 (+76.47%)
Mutual labels:  luajit, openresty
Lua Resty Http
Lua HTTP client cosocket driver for OpenResty / ngx_lua.
Stars: ✭ 1,647 (+9588.24%)
Mutual labels:  luajit, openresty
Luajit.io
luajit io framework
Stars: ✭ 277 (+1529.41%)
Mutual labels:  luajit, openresty
Lua Resty Jit Uuid
Fast and dependency-free UUID library for LuaJIT/ngx_lua
Stars: ✭ 169 (+894.12%)
Mutual labels:  luajit, openresty
Lua Resty Repl
Interactive console (REPL) for Openresty and luajit code
Stars: ✭ 165 (+870.59%)
Mutual labels:  luajit, openresty
Lua Nginx Redis
🌺 Redis、Lua、Nginx、OpenResty 笔记和资料
Stars: ✭ 757 (+4352.94%)
Mutual labels:  luajit, openresty
is-cidr
Check if a string is an IP address in CIDR notation
Stars: ✭ 27 (+58.82%)
Mutual labels:  ip, cidr
Ledge
An RFC compliant and ESI capable HTTP cache for Nginx / OpenResty, backed by Redis
Stars: ✭ 412 (+2323.53%)
Mutual labels:  luajit, openresty
Vanilla
An OpenResty Lua MVC Web Framework
Stars: ✭ 1,018 (+5888.24%)
Mutual labels:  luajit, openresty
Apioak
Full Lifecycle Management API Gateway.
Stars: ✭ 335 (+1870.59%)
Mutual labels:  luajit, openresty
Lua Cassandra
Pure Lua driver for Apache Cassandra
Stars: ✭ 95 (+458.82%)
Mutual labels:  luajit, openresty
lua-resty-maxminddb
A Lua library for reading MaxMind's Geolocation database
Stars: ✭ 72 (+323.53%)
Mutual labels:  luajit, openresty
Lua Resty Mlcache
Layered caching library for OpenResty
Stars: ✭ 274 (+1511.76%)
Mutual labels:  luajit, openresty
Api Umbrella
Open source API management platform
Stars: ✭ 1,735 (+10105.88%)
Mutual labels:  luajit, openresty
nginx-lua
Nginx 1.19+ with LUA support based on Alpine Linux, Amazon Linux, Debian, Fedora and Ubuntu.
Stars: ✭ 112 (+558.82%)
Mutual labels:  luajit, openresty

lua-resty-ipcidr Build Status

A simple and very fast function to check against CIDR

Overview

access_by_lua_block {
    local ipcidr = require("resty.ipcidr")
    local whitelist_ips = {
      "127.0.0.1",
      "10.10.10.0/24",
      "192.168.0.0/16",
  }
    if not ipcidr.ip_in_cidrs(ngx.var.remote_addr, whitelist_ips) then
      return ngx.exit(ngx.HTTP_FORBIDDEN)
    end
}

Methods

ip_in_cidrs

syntax: bool, err = ipcidr.ip_in_cidrs(ip, cidrs)

Takes a string IPv4 address and a table of parsed CIDRs.

Returns a true or false if the IP exists within any of the specified networks.

Returns nil and an error message with an invalid IP

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].