{"id":18024009,"url":"https://github.com/lete114/get-user-ip","last_synced_at":"2026-03-08T07:32:21.004Z","repository":{"id":109798282,"uuid":"436965109","full_name":"Lete114/Get-User-IP","owner":"Lete114","description":"一个轻量、小巧的Node.js模块，用于检索请求用户的IP地址 | A lightweight, small Node.js module to retrieve the IP address of the requesting user","archived":false,"fork":false,"pushed_at":"2024-05-21T15:29:48.000Z","size":36,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-22T18:11:21.400Z","etag":null,"topics":["client-ip","get-client-ip","get-request-ip","get-user-ip","request-ip","user-ip"],"latest_commit_sha":null,"homepage":"https://get-user-ip.vercel.app","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/Lete114.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":"2021-12-10T12:06:38.000Z","updated_at":"2024-06-11T14:56:18.000Z","dependencies_parsed_at":"2023-12-13T15:39:05.432Z","dependency_job_id":"abd7c22d-89cb-42c6-99fb-449887a86a2a","html_url":"https://github.com/Lete114/Get-User-IP","commit_stats":{"total_commits":4,"total_committers":2,"mean_commits":2.0,"dds":0.25,"last_synced_commit":"931c805437b0b17c8e4d6c8512906ef3da96d4c1"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lete114%2FGet-User-IP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lete114%2FGet-User-IP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lete114%2FGet-User-IP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lete114%2FGet-User-IP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lete114","download_url":"https://codeload.github.com/Lete114/Get-User-IP/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245760562,"owners_count":20667886,"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","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":["client-ip","get-client-ip","get-request-ip","get-user-ip","request-ip","user-ip"],"created_at":"2024-10-30T07:11:38.842Z","updated_at":"2026-03-08T07:32:20.974Z","avatar_url":"https://github.com/Lete114.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"right\"\u003e\n  Language:\n  English\n  \u003ca title=\"Chinese\" href=\"README_ZH.md\"\u003e中文\u003c/a\u003e\n\u003c/div\u003e\n\n\u003ch1 align=\"center\"\u003e\u003ca href=\"https://github.com/lete114/Get-User-IP\" target=\"_blank\"\u003eGet-User-IP\u003c/a\u003e\u003c/h1\u003e\n\u003cp align=\"center\"\u003eA lightweight, small Node.js module to retrieve the IP address of the requesting user\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/Lete114/Get-User-IP/releases/\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/get-user-ip\" alt=\"Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/Lete114/Get-User-IP/tree/main\"\u003e\u003cimg src=\"https://img.shields.io/github/package-json/v/Lete114/Get-User-IP/main?color=%231ab1ad\u0026label=main\" alt=\"dev\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/Lete114/Get-User-IP/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/Lete114/Get-User-IP?color=FF5531\" alt=\"MIT License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Installation\n\n```bash\nnpm install get-user-ip --save\n```\n\n## Getting Started\n\n```javascript\nconst GetUserIP = require('get-user-ip')\nconst http = require('http')\n\nconst server = http.createServer((req,res)=\u003e{\n  res.end(GetUserIP(req))\n})\n\nserver.listen(6870)\n\n// on localhost you'll see 127.0.0.1 if you're using IPv4\n// or ::1, ::ffff:127.0.0.1 if you're using IPv6\n```\n\nIf there are some special cases, such as the use of `CloudFlare`, you can append a second parameter, which is an array so it can contain more than one params\n\n```javascript\nconst server = http.createServer((req,res)=\u003e{\n  // This gives priority to getting headers.cf-connecting-ip, and if it doesn't exist, continue with the default parameters\n  res.end(GetUserIP(req,['headers.cf-connecting-ip']))\n})\n```\n\n## How It Works\n\nIt looks for a specific header in the request and returns the `0.0.0.0` default if it does not exist\n\nThe user IP is determined by the following order\n\n```javascript\nconst defaultHeaders = [\n  'headers.x-client-ip',\n  'headers.x-real-ip',\n  'headers.x-forwarded-for', // This header will return multiple IP addresses, Format: (Client IP, Proxy 1 IP, Proxy 2 IP...) So return the first\n  'connection.remoteAddress',\n  'socket.remoteAddress',\n  'connection.socket.remoteAddress'\n]\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flete114%2Fget-user-ip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flete114%2Fget-user-ip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flete114%2Fget-user-ip/lists"}