{"id":18368128,"url":"https://github.com/thinkjs/think-ip-filter","last_synced_at":"2025-10-16T10:21:03.531Z","repository":{"id":73609606,"uuid":"45302237","full_name":"thinkjs/think-ip-filter","owner":"thinkjs","description":"IP filter middleware for ThinkJS 2.0, support whiteList \u0026 blackList","archived":false,"fork":false,"pushed_at":"2017-02-21T02:10:54.000Z","size":6,"stargazers_count":6,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-22T04:25:59.118Z","etag":null,"topics":["blacklist","ip-filter","support-whitelist","thinkjs"],"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/thinkjs.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":"2015-10-31T13:13:55.000Z","updated_at":"2019-02-12T03:39:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"326cf2c3-729b-435d-99db-d14eac03edca","html_url":"https://github.com/thinkjs/think-ip-filter","commit_stats":null,"previous_names":["welefen/think-ip-filter"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/thinkjs/think-ip-filter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Fthink-ip-filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Fthink-ip-filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Fthink-ip-filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Fthink-ip-filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thinkjs","download_url":"https://codeload.github.com/thinkjs/think-ip-filter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Fthink-ip-filter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279177827,"owners_count":26120046,"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-10-16T02:00:06.019Z","response_time":53,"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":["blacklist","ip-filter","support-whitelist","thinkjs"],"created_at":"2024-11-05T23:24:44.215Z","updated_at":"2025-10-16T10:21:03.525Z","avatar_url":"https://github.com/thinkjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# think-ip-filter\n\nIP filter middleware for **ThinkJS 2.0**, support whiteList \u0026 blackList.\n\n## Install\n\n```sh\nnpm install think-ip-filter --save\n```\n\n## How to use\n\n### register middleware \n\ncreate file if not exist, `src/common/bootstrap/middleware.js`.\n\n```js\nimport ipFilter from 'think-ip-filter';\nthink.middleware('ip_filter', ipFilter);\n```\n\n### config hook\n\ncreate file if not exist, `src/common/config/hook.js`.\n\n```js\nexport default {\n  request_begin: ['prepend', 'ip_filter']\n}\n```\n\n### config ip whiteList or blackList\n\nadd `ip_filter` config in file `src/common/config/config.js`.\n\n**black list**\n\n```js\nexport default {\n  ip_filter: ['111.222.333.444', '121.233.120.11']\n}\n```\n\n**white list**\n\n```js\nexport default {\n  ip_filter: {\n    whiteList: ['123.222.122.11', '22.33.11.22']\n  }\n}\n```\n\n**\\* rule**\n\n```js\nexport default {\n  ip_filter: {\n    whiteList: ['123.*.122.11', '*.33.11.22']\n  }\n}\n```\n\n**RegExp rule**\n\n```js\nexport default {\n  ip_filter: {\n    whiteList: [/^10\\./]\n  }\n}\n```\n\n**dynamic load**\n\ndynamic load by function, must be return Promise.\n\n```js\nexport default {\n  ip_filter: function(){\n    //such as: get from db\n    return Promise.resolve(['111.*']);\n  }\n}\n```\n\n## LICENSE\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkjs%2Fthink-ip-filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthinkjs%2Fthink-ip-filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkjs%2Fthink-ip-filter/lists"}