{"id":17109750,"url":"https://github.com/bleargh45/cgi-remote_addr","last_synced_at":"2025-03-23T21:41:49.845Z","repository":{"id":56831449,"uuid":"339162275","full_name":"bleargh45/CGI-remote_addr","owner":"bleargh45","description":"Enhanced version of CGI.pm's \"remote_addr()\"","archived":false,"fork":false,"pushed_at":"2023-06-12T20:10:58.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-29T05:14:02.570Z","etag":null,"topics":["cgi","perl","remote-addr"],"latest_commit_sha":null,"homepage":"http://metacpan.org/release/CGI-remote_addr/","language":"Perl","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/bleargh45.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","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":"2021-02-15T17:58:32.000Z","updated_at":"2023-07-08T10:43:05.000Z","dependencies_parsed_at":"2022-08-28T20:10:49.025Z","dependency_job_id":null,"html_url":"https://github.com/bleargh45/CGI-remote_addr","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bleargh45%2FCGI-remote_addr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bleargh45%2FCGI-remote_addr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bleargh45%2FCGI-remote_addr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bleargh45%2FCGI-remote_addr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bleargh45","download_url":"https://codeload.github.com/bleargh45/CGI-remote_addr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245175322,"owners_count":20572781,"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":["cgi","perl","remote-addr"],"created_at":"2024-10-14T16:24:14.810Z","updated_at":"2025-03-23T21:41:49.824Z","avatar_url":"https://github.com/bleargh45.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NAME\n\nCGI::remote\\_addr - Enhanced version of CGI.pm's \"remote\\_addr()\"\n\n# SYNOPSIS\n\n```perl\nuse CGI;\nuse CGI::remote_addr;\n\nmy $cgi  = CGI-\u003enew();\nmy $addr = $cgi-\u003eremote_addr();\n```\n\n# DESCRIPTION\n\n`CGI::remote_addr` implements an enhanced version of the `remote_addr()`\nmethod provided by `CGI.pm`, which attempts to return the original IP address\nthat the connection originated from (which is not necessarily the IP address\nthat we received the connection from).\n\nSimply loading `CGI::remote_addr` causes it to over-ride the existing\n`remote_addr()` method.  Do note, though, that this is a global over-ride; if\nyou're running under mod\\_perl you've just over-ridden it for **all** of your\napplications.\n\n## Differences from CGI.pm\n\n- We check not only `$ENV{REMOTE_ADDR}` to find the IP address, but also look in\n`$ENV{HTTP_X_FORWARDED_FOR}` to find the IP address.  If\n`$ENV{HTTP_X_FORWARDED_FOR}` is defined, we try that first.\n- Only valid IP addresses are returned, regardless of whatever exists in\n`$ENV{REMOTE_ADDR}` or `$ENV{HTTP_X_FORWARDED_FOR}`.  I've seen lots of cases\nwhere the values for `$ENV{HTTP_X_FORWARDED_FOR}` were stuffed with garbage,\nand we make sure that you only get a real IP back.\n- We return IPs in both a scalar and a list context.  In scalar context you get\nthe first (originating) IP address.  In list context you get a unique list of\nall of the IPs that the connection was received through.\n- In the event that we cannot find a valid IP address, this method returns\n`undef`, **NOT** 127.0.0.1 (like `CGI.pm` does).\n\n# METHODS\n\n- remote\\_addr()\n\n    Returns the IP address(es) of the remote host.\n\n# AUTHOR\n\nGraham TerMarsch (cpan@howlingfrog.com)\n\n# COPYRIGHT\n\nCopyright (C) 2008 Graham TerMarsch.  All Rights Reserved.\n\nThis library is free software; you can redistribute it and/or modify it under\nthe same terms as Perl itself.\n\n# SEE ALSO\n\n- [CGI](https://metacpan.org/pod/CGI)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbleargh45%2Fcgi-remote_addr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbleargh45%2Fcgi-remote_addr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbleargh45%2Fcgi-remote_addr/lists"}