{"id":16828056,"url":"https://github.com/kataras/realip","last_synced_at":"2025-08-14T21:24:50.803Z","repository":{"id":57533770,"uuid":"279543290","full_name":"kataras/realip","owner":"kataras","description":"Extract the real HTTP client's Remote IP Address","archived":false,"fork":false,"pushed_at":"2022-12-24T06:22:31.000Z","size":13,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T01:51:10.569Z","etag":null,"topics":["go","golang","http","iris","realip"],"latest_commit_sha":null,"homepage":"","language":"Go","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/kataras.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"kataras"}},"created_at":"2020-07-14T09:37:02.000Z","updated_at":"2023-01-12T13:33:33.000Z","dependencies_parsed_at":"2023-01-30T20:10:17.298Z","dependency_job_id":null,"html_url":"https://github.com/kataras/realip","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kataras%2Frealip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kataras%2Frealip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kataras%2Frealip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kataras%2Frealip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kataras","download_url":"https://codeload.github.com/kataras/realip/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248339262,"owners_count":21087214,"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":["go","golang","http","iris","realip"],"created_at":"2024-10-13T11:24:25.461Z","updated_at":"2025-04-11T03:51:07.898Z","avatar_url":"https://github.com/kataras.png","language":"Go","funding_links":["https://github.com/sponsors/kataras"],"categories":[],"sub_categories":[],"readme":"# Real IP\r\n\r\n[![build status](https://img.shields.io/github/actions/workflow/status/kataras/realip/ci.yml?style=for-the-badge)](https://github.com/kataras/realip/actions) [![report card](https://img.shields.io/badge/report%20card-a%2B-ff3333.svg?style=for-the-badge)](https://goreportcard.com/report/github.com/kataras/realip) [![godocs](https://img.shields.io/badge/go-%20docs-488AC7.svg?style=for-the-badge)](https://pkg.go.dev/github.com/kataras/realip)\r\n\r\nExtract the real HTTP client's Remote IP Address.\r\n\r\n## Installation\r\n\r\nThe only requirement is the [Go Programming Language](https://golang.org/dl).\r\n\r\n```sh\r\n$ go get github.com/kataras/realip\r\n```\r\n\r\n## Getting Started\r\n\r\nThe main function is `Get`, it makes use of the `Default` options to extract the request's remote address.\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n\t\"fmt\"\r\n\t\"net/http\"\r\n\r\n\t\"github.com/kataras/realip\"\r\n)\r\n\r\nfunc main() {\r\n    http.HandleFunc(\"/\", handler)\r\n    http.ListenAndServe(\":8080\", nil)\r\n}\r\n\r\nfunc handler(w http.ResponseWriter, r *http.Request) {\r\n    ip := realip.Get(r)\r\n    fmt.Fprintf(w, \"Your Public IPv4 is: %s\", ip)\r\n}\r\n```\r\n\r\n\u003e The `Get(r)` function calls the `Default.Get(r)` method\r\n\r\n### Options\r\n\r\nHere are the default values:\r\n\r\n```go\r\nvar Default = Options{\r\n\tHeaders: []string{\r\n\t\t\"X-Real-Ip\",\r\n\t\t\"X-Forwarded-For\",\r\n\t\t\"CF-Connecting-IP\",\r\n\t},\r\n\tPrivateSubnets: []Range{\r\n\t\t{\r\n\t\t\tStart: net.ParseIP(\"10.0.0.0\"),\r\n\t\t\tEnd:   net.ParseIP(\"10.255.255.255\"),\r\n\t\t},\r\n\t\t{\r\n\t\t\tStart: net.ParseIP(\"100.64.0.0\"),\r\n\t\t\tEnd:   net.ParseIP(\"100.127.255.255\"),\r\n\t\t},\r\n\t\t{\r\n\t\t\tStart: net.ParseIP(\"172.16.0.0\"),\r\n\t\t\tEnd:   net.ParseIP(\"172.31.255.255\"),\r\n\t\t},\r\n\t\t{\r\n\t\t\tStart: net.ParseIP(\"192.0.0.0\"),\r\n\t\t\tEnd:   net.ParseIP(\"192.0.0.255\"),\r\n\t\t},\r\n\t\t{\r\n\t\t\tStart: net.ParseIP(\"192.168.0.0\"),\r\n\t\t\tEnd:   net.ParseIP(\"192.168.255.255\"),\r\n\t\t},\r\n\t\t{\r\n\t\t\tStart: net.ParseIP(\"198.18.0.0\"),\r\n\t\t\tEnd:   net.ParseIP(\"198.19.255.255\"),\r\n\t\t},\r\n\t},\r\n}\r\n```\r\n\r\nUse the `AddRange` method helper to add an IP range in **custom** options:\r\n\r\n```go\r\nfunc main() {\r\n    myOptions := \u0026realip.Options{Headers: []string{\"X-Forwarded-For\"}}\r\n    myOptions.AddRange(\"192.168.0.0\", \"192.168.255.255\")\r\n\r\n    // [...]\r\n    http.HandleFunc(\"/\", handler(myOptions))\r\n}\r\n\r\nfunc handler(opts *realip.Options) http.HandlerFunc {\r\n    return func(w http.ResponseWriter, r *http.Request){\r\n        ip := opts.Get(r)\r\n\r\n        // [...]\r\n    }\r\n}\r\n```\r\n\r\nPlease navigate through [_examples](_examples) directory for more.\r\n\r\n## License\r\n\r\nThis software is licensed under the [MIT License](LICENSE).\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkataras%2Frealip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkataras%2Frealip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkataras%2Frealip/lists"}