{"id":23545456,"url":"https://github.com/mo7zayed/reqip","last_synced_at":"2025-04-24T03:12:52.098Z","repository":{"id":41871419,"uuid":"265441724","full_name":"mo7zayed/reqip","owner":"mo7zayed","description":"A simple tool for retrieving a request's IP address on the server.","archived":false,"fork":false,"pushed_at":"2022-10-26T05:59:59.000Z","size":5,"stargazers_count":16,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-24T03:12:44.642Z","etag":null,"topics":["cloudflare","http","http-headers","ip","ipaddress","ipv4","ipv6","request"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mo7zayed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-20T03:38:51.000Z","updated_at":"2024-06-20T14:25:53.000Z","dependencies_parsed_at":"2023-01-20T02:03:50.449Z","dependency_job_id":null,"html_url":"https://github.com/mo7zayed/reqip","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mo7zayed%2Freqip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mo7zayed%2Freqip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mo7zayed%2Freqip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mo7zayed%2Freqip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mo7zayed","download_url":"https://codeload.github.com/mo7zayed/reqip/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250552076,"owners_count":21449165,"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":["cloudflare","http","http-headers","ip","ipaddress","ipv4","ipv6","request"],"created_at":"2024-12-26T08:17:25.886Z","updated_at":"2025-04-24T03:12:52.072Z","avatar_url":"https://github.com/mo7zayed.png","language":"Go","readme":"# reqip\nA simple tool for retrieving a request's IP address on the server. Inspired from [request-ip](https://github.com/pbojinov/request-ip)\n\n# Installation\nVia `go get`\n\n```bash\ngo get github.com/mo7zayed/reqip\n```\n\n# How to use\n```golang\npackage main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"github.com/mo7zayed/reqip\"\n)\n\nfunc main() {\n\thttp.HandleFunc(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\t\tfmt.Fprintf(\n\t\t\tw,\n\t\t\tfmt.SprintF(\"your ip is %s\", reqip.GetClientIP(r)) // reqip.GetClientIP receives a *http.Request var type\n\t\t)\n\t})\n\n\tfmt.Println(\"server started on: http://127.0.1.1:8000\")\n\thttp.ListenAndServe(\":8000\", nil)\n}\n```\n\n## How It Works\n\nIt looks for specific headers in the request and falls back to some defaults if they do not exist.\n\nThe user ip is determined by the following order:\n\n1. `X-Client-IP`\n2. `X-Forwarded-For` (Header may return multiple IP addresses in the format: \"client IP, proxy 1 IP, proxy 2 IP\", so we take the the first one.)\n3. `CF-Connecting-IP` (Cloudflare)\n4. `Fastly-Client-Ip` (Fastly CDN and Firebase hosting header when forwared to a cloud function)\n5. `True-Client-Ip` (Akamai and Cloudflare)\n6. `X-Real-IP` (Nginx proxy/FastCGI)\n7. `X-Cluster-Client-IP` (Rackspace LB, Riverbed Stingray)\n8. `X-Forwarded`, `Forwarded-For` and `Forwarded` (Variations of #2)\n9. `http.Request.RemoteAddr`\n\n## License\nThe MIT License (MIT) - 2020","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmo7zayed%2Freqip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmo7zayed%2Freqip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmo7zayed%2Freqip/lists"}