{"id":15824332,"url":"https://github.com/aravindnc/ip-domain-filter","last_synced_at":"2025-07-30T00:33:34.372Z","repository":{"id":66340121,"uuid":"180265201","full_name":"aravindnc/ip-domain-filter","owner":"aravindnc","description":"Validates IPv4, IPv6 and domain names for whitelisting based on micromatch rules.","archived":false,"fork":false,"pushed_at":"2020-04-16T04:43:27.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-06T08:41:31.087Z","etag":null,"topics":["blacklisting","blacklisting-filter","domain","domain-filter","filter","ip","ip-domain-filter","ipfilter","ipv4","ipv6","micromatch","rules","whitelisting","whitelisting-filter"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aravindnc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-09T02:01:02.000Z","updated_at":"2020-04-16T04:43:29.000Z","dependencies_parsed_at":"2023-02-22T02:15:27.916Z","dependency_job_id":null,"html_url":"https://github.com/aravindnc/ip-domain-filter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aravindnc/ip-domain-filter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aravindnc%2Fip-domain-filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aravindnc%2Fip-domain-filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aravindnc%2Fip-domain-filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aravindnc%2Fip-domain-filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aravindnc","download_url":"https://codeload.github.com/aravindnc/ip-domain-filter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aravindnc%2Fip-domain-filter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267785821,"owners_count":24144122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blacklisting","blacklisting-filter","domain","domain-filter","filter","ip","ip-domain-filter","ipfilter","ipv4","ipv6","micromatch","rules","whitelisting","whitelisting-filter"],"created_at":"2024-10-05T08:41:33.970Z","updated_at":"2025-07-30T00:33:34.344Z","avatar_url":"https://github.com/aravindnc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ip-domain-filter\n[![npm version](https://img.shields.io/npm/v/ip-domain-filter.svg)](https://www.npmjs.com/package/ip-domain-filter)\n[![Dependency Status](https://david-dm.org/WebGangster/ip-domain-filter.svg)](https://david-dm.org/WebGangster/ip-domain-filter)\n[![devDependency Status](https://david-dm.org/WebGangster/ip-domain-filter/dev-status.svg)](https://david-dm.org/WebGangster/ip-domain-filter#info=devDependencies)\n[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/WebGangster/ip-domain-filter/issues)\n[![Downloads](https://img.shields.io/npm/dm/ip-domain-filter.svg)](https://img.shields.io/npm/dm/ip-domain-filter.svg)\n[![HitCount](http://hits.dwyl.io/WebGangster/ip-domain-filter.svg)](http://hits.dwyl.io/WebGangster/ip-domain-filter)\n\n\u003e Validates IPs (IPv4 and IPv6) and domain names using micromatch ruleset. Can be used for IP/Domain whitelisting functionality.\n\n[![NPM](https://nodei.co/npm/ip-domain-filter.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://www.npmjs.com/package/ip-domain-filter)\n\n## Install\n```\nnpm i ip-domain-filter --save\n```\n\n## Usage\n\n```js\nconst hostFilter = require('ip-domain-filter');\n\nlet rules = [{\n    category: 'ip',\n    allowed: ['127.0.0.2', '127.0.0.4', '127.0.0.6']\n  },\n  {\n    category: 'domain',\n    allowed: ['localhost', 'google.com']\n  },\n  {\n    category: 'ipRange',\n    allowed: ['127.1.0.8', '127.1.0.20']\n  },\n  {\n    category: 'ip',\n    allowed: ['192.168.??.1']\n  },\n  {\n    category: 'ip',\n    allowed: ['192.168.1.*']\n  }\n];\n\nlet caseA = '192.168.10.1';\nhostFilter.filter(caseA, rules);\n// Returns true as it matches 4th rule.\n\nlet caseB = '192.168.2.1';\nhostFilter.filter(caseB, rules);\n// Returns false as it does'nt match any of the rules.\n\n\n```\n\u003e For more use-cases see the [tests](./test/test.js)\n\n**Params**\n\n* `ip` **{String}**: Accepts IP and Domain names.\n* `rules` **{Array}**: Filter rules/conditions.\n* `returns` **{Bool}**: If there is a match it returns `true`, otherwise `false`.\n\n### Rules\n\nRule will be an object array having 2 parameters `category` and `allowed`.\n\n| Category  | Description   |\n| :------------ | :------------ |\n| ip | To check whether the given IP is valid in a list of IP's. |\n| ipRange | To check whether the given ip is in a range or not.  |\n| domain | To check wheter the domain matches a given list of domains. |\n\n## Examples\n\n**(1)** Rule using `ip`,\nThis will check whether the given ip is available in the allowed list or not.\n```\nlet rules = [{\n    category: 'ip',\n    allowed: ['127.0.0.2', '127.0.0.4', '127.0.0.6']\n  }\n]\n```\n**(2)** Rule using `ipRange`,\nThis will check whether the given ip is between the specified range or not.\n\n*Note: In the case of **ipRange**, `allowed` should have only 2 values, [ipStart, ipEnd]*\n```\nlet rules = [{\n    category: 'ipRange',\n    allowed: ['127.1.0.8', '127.1.0.20']\n  }\n]\n```\n**(3)** Rule using `domain`,\nThis will check whether the given domain is between the specified list or not.\n\n```\nlet rules = [{\n    category: 'domain',\n    allowed: ['localhost', 'google.com']\n  }\n]\n```\n\n### Extended Useage\n**(4)** Rule using `ip` with micromatch,\nThis will check whether the given ip is in the format `192.168.*.1`. And the `*` can be any character.\n```\nlet rules = [{\n    category: 'ip',\n    allowed: ['192.168.*.1']\n  }\n]\n\n// 192.168.1.1 - true\n// 192.168.10.1 - true\n// 192.168.1.2 - false\n```\n\n**(5)** Rule using `ip` with micromatch,\nThis will check whether the given ip is in the format `192.168.?.1`. And the `?` can be any character from 0 to 9.\n```\nlet rules = [{\n    category: 'ip',\n    allowed: ['192.168.?.1']\n  }\n]\n\n// 192.168.1.1 - true\n// 192.168.9.1 - true\n// 192.168.10.1 -  false\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faravindnc%2Fip-domain-filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faravindnc%2Fip-domain-filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faravindnc%2Fip-domain-filter/lists"}