{"action":"created","comment":{"url":"https://api.github.com/repos/symfony/symfony/pulls/comments/27200881","id":27200881,"diff_hunk":"@@ -0,0 +1,166 @@\n+<?php\n+\n+/*\n+ * This file is part of the Symfony package.\n+ *\n+ * (c) Fabien Potencier <fabien@symfony.com>\n+ *\n+ * For the full copyright and license information, please view the LICENSE\n+ * file that was distributed with this source code.\n+ */\n+\n+namespace Symfony\\Component\\HttpFoundation\\IpRetriever;\n+\n+\n+use Symfony\\Component\\HttpFoundation\\IpUtils;\n+use Symfony\\Component\\HttpFoundation\\Request;\n+\n+/**\n+ * IpRetriever\n+ *\n+ * Can retrieve real user ip from various contexts (proxified query or not).\n+ * If you use a reverse proxy, set his ip with setTrustedProxies\n+ * otherwise, you'll get your reverse proxy ip anyway.\n+ *\n+ * @author Xavier Leune <xavier.leune@gmail.com>\n+ */\n+class IpRetriever implements IpRetrieverInterface\n+{\n+    /**\n+     * Names for headers that can be trusted when\n+     * using trusted proxies.\n+     *\n+     * The FORWARDED header is the standard as of rfc7239.\n+     *\n+     * The other headers are non-standard, but widely used\n+     * by popular reverse proxies (like Apache mod_proxy or Amazon EC2).\n+     */\n+    protected $trustedHeaders = array(\n+        self::HEADER_FORWARDED => 'FORWARDED',\n+        self::HEADER_CLIENT_IP => 'X_FORWARDED_FOR',\n+        self::HEADER_REAL_IP => 'X_REAL_IP',\n+    );\n+\n+    protected $trustedProxies = array();\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function setTrustedProxies(array $proxies)\n+    {\n+        $this->trustedProxies = $proxies;\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function getTrustedProxies()\n+    {\n+        return $this->getTrustedProxies();\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function setTrustedHeaderName($key, $value)","path":"src/Symfony/Component/HttpFoundation/IpRetriever/IpRetriever.php","position":65,"original_position":65,"commit_id":"14d622b3919b39ac5e33f5dd5f58c57108cfebdd","original_commit_id":"4b982179dc82bd3ad429f883ff8ddcb4d5b7bf28","user":{"login":"stof","id":439401,"avatar_url":"https://avatars.githubusercontent.com/u/439401?v=3","gravatar_id":"","url":"https://api.github.com/users/stof","html_url":"https://github.com/stof","followers_url":"https://api.github.com/users/stof/followers","following_url":"https://api.github.com/users/stof/following{/other_user}","gists_url":"https://api.github.com/users/stof/gists{/gist_id}","starred_url":"https://api.github.com/users/stof/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stof/subscriptions","organizations_url":"https://api.github.com/users/stof/orgs","repos_url":"https://api.github.com/users/stof/repos","events_url":"https://api.github.com/users/stof/events{/privacy}","received_events_url":"https://api.github.com/users/stof/received_events","type":"User","site_admin":false},"body":"@xavierleune If we design a new API, we should design it properly. If we make it stateful when introducing it, we cannot easily turn it stateless in Sf3. We have to make the new API usable directly","created_at":"2015-03-26T10:18:01Z","updated_at":"2015-03-26T10:18:01Z","html_url":"https://github.com/symfony/symfony/pull/14029#discussion_r27200881","pull_request_url":"https://api.github.com/repos/symfony/symfony/pulls/14029","_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments/27200881"},"html":{"href":"https://github.com/symfony/symfony/pull/14029#discussion_r27200881"},"pull_request":{"href":"https://api.github.com/repos/symfony/symfony/pulls/14029"}}},"pull_request":{"url":"https://api.github.com/repos/symfony/symfony/pulls/14029","id":31754859,"html_url":"https://github.com/symfony/symfony/pull/14029","diff_url":"https://github.com/symfony/symfony/pull/14029.diff","patch_url":"https://github.com/symfony/symfony/pull/14029.patch","issue_url":"https://api.github.com/repos/symfony/symfony/issues/14029","number":14029,"state":"open","locked":false,"title":"Request : new service IpRetriever","user":{"login":"xavierleune","id":2320425,"avatar_url":"https://avatars.githubusercontent.com/u/2320425?v=3","gravatar_id":"","url":"https://api.github.com/users/xavierleune","html_url":"https://github.com/xavierleune","followers_url":"https://api.github.com/users/xavierleune/followers","following_url":"https://api.github.com/users/xavierleune/following{/other_user}","gists_url":"https://api.github.com/users/xavierleune/gists{/gist_id}","starred_url":"https://api.github.com/users/xavierleune/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xavierleune/subscriptions","organizations_url":"https://api.github.com/users/xavierleune/orgs","repos_url":"https://api.github.com/users/xavierleune/repos","events_url":"https://api.github.com/users/xavierleune/events{/privacy}","received_events_url":"https://api.github.com/users/xavierleune/received_events","type":"User","site_admin":false},"body":"Actually the logic to retrieve real ip(s) from the final user is in the request class and cannot be defined against the actual context (special reverse proxy, CDN, etc.)\r\n\r\nThis PR is a purposal to handle it in a better way.\r\nI define a new IpRetrieverInterface which can be implemented to handle special case.\r\nThe default implementation is done with IpRetriever => it's the code from Request used in this one.\r\nThere is a new implementation for AkamaiIpRetriever to handle this CDN special purposes.\r\n\r\nAs this PR is based against the 2.7 branch, there is no BC Break. The Request uses the new service to handle getClientIps and getClientIp.\r\n\r\nA new configuration key under \"framework\" has been added : \"ip_retriever\" to define the service name to use.\r\n\r\nI'll rebase my branch against the master later to have one commit only => this will be easier to handle your feedback right now.\r\n\r\n| Q             | A\r\n| ------------- | ---\r\n| Bug fix?      | no\r\n| New feature?  | yes\r\n| BC breaks?    | no\r\n| Deprecations? | yes\r\n| Tests pass?   | yes\r\n| Fixed tickets | ¤\r\n| License       | MIT\r\n| Doc PR        | ¤","created_at":"2015-03-23T17:29:26Z","updated_at":"2015-03-26T10:18:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f82d6d918f15bffc16500b216a93aa0aa9fc03d7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/symfony/symfony/pulls/14029/commits","review_comments_url":"https://api.github.com/repos/symfony/symfony/pulls/14029/comments","review_comment_url":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/14029/comments","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/14d622b3919b39ac5e33f5dd5f58c57108cfebdd","head":{"label":"xavierleune:feature/ip-retriever","ref":"feature/ip-retriever","sha":"14d622b3919b39ac5e33f5dd5f58c57108cfebdd","user":{"login":"xavierleune","id":2320425,"avatar_url":"https://avatars.githubusercontent.com/u/2320425?v=3","gravatar_id":"","url":"https://api.github.com/users/xavierleune","html_url":"https://github.com/xavierleune","followers_url":"https://api.github.com/users/xavierleune/followers","following_url":"https://api.github.com/users/xavierleune/following{/other_user}","gists_url":"https://api.github.com/users/xavierleune/gists{/gist_id}","starred_url":"https://api.github.com/users/xavierleune/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xavierleune/subscriptions","organizations_url":"https://api.github.com/users/xavierleune/orgs","repos_url":"https://api.github.com/users/xavierleune/repos","events_url":"https://api.github.com/users/xavierleune/events{/privacy}","received_events_url":"https://api.github.com/users/xavierleune/received_events","type":"User","site_admin":false},"repo":{"id":32339582,"name":"symfony","full_name":"xavierleune/symfony","owner":{"login":"xavierleune","id":2320425,"avatar_url":"https://avatars.githubusercontent.com/u/2320425?v=3","gravatar_id":"","url":"https://api.github.com/users/xavierleune","html_url":"https://github.com/xavierleune","followers_url":"https://api.github.com/users/xavierleune/followers","following_url":"https://api.github.com/users/xavierleune/following{/other_user}","gists_url":"https://api.github.com/users/xavierleune/gists{/gist_id}","starred_url":"https://api.github.com/users/xavierleune/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xavierleune/subscriptions","organizations_url":"https://api.github.com/users/xavierleune/orgs","repos_url":"https://api.github.com/users/xavierleune/repos","events_url":"https://api.github.com/users/xavierleune/events{/privacy}","received_events_url":"https://api.github.com/users/xavierleune/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xavierleune/symfony","description":"The Symfony PHP framework","fork":true,"url":"https://api.github.com/repos/xavierleune/symfony","forks_url":"https://api.github.com/repos/xavierleune/symfony/forks","keys_url":"https://api.github.com/repos/xavierleune/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xavierleune/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xavierleune/symfony/teams","hooks_url":"https://api.github.com/repos/xavierleune/symfony/hooks","issue_events_url":"https://api.github.com/repos/xavierleune/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/xavierleune/symfony/events","assignees_url":"https://api.github.com/repos/xavierleune/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/xavierleune/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/xavierleune/symfony/tags","blobs_url":"https://api.github.com/repos/xavierleune/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xavierleune/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xavierleune/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/xavierleune/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xavierleune/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/xavierleune/symfony/languages","stargazers_url":"https://api.github.com/repos/xavierleune/symfony/stargazers","contributors_url":"https://api.github.com/repos/xavierleune/symfony/contributors","subscribers_url":"https://api.github.com/repos/xavierleune/symfony/subscribers","subscription_url":"https://api.github.com/repos/xavierleune/symfony/subscription","commits_url":"https://api.github.com/repos/xavierleune/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/xavierleune/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/xavierleune/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/xavierleune/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/xavierleune/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/xavierleune/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xavierleune/symfony/merges","archive_url":"https://api.github.com/repos/xavierleune/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xavierleune/symfony/downloads","issues_url":"https://api.github.com/repos/xavierleune/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/xavierleune/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/xavierleune/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/xavierleune/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xavierleune/symfony/labels{/name}","releases_url":"https://api.github.com/repos/xavierleune/symfony/releases{/id}","created_at":"2015-03-16T16:55:25Z","updated_at":"2015-03-16T16:55:40Z","pushed_at":"2015-03-26T09:56:22Z","git_url":"git://github.com/xavierleune/symfony.git","ssh_url":"git@github.com:xavierleune/symfony.git","clone_url":"https://github.com/xavierleune/symfony.git","svn_url":"https://github.com/xavierleune/symfony","homepage":"symfony.com","size":53544,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"2.7"}},"base":{"label":"symfony:2.7","ref":"2.7","sha":"1a4d7d7e48efd7c81c4fa65845be6d7532e0b20b","user":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"repo":{"id":458058,"name":"symfony","full_name":"symfony/symfony","owner":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/symfony/symfony","description":"The Symfony PHP framework","fork":false,"url":"https://api.github.com/repos/symfony/symfony","forks_url":"https://api.github.com/repos/symfony/symfony/forks","keys_url":"https://api.github.com/repos/symfony/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/symfony/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/symfony/symfony/teams","hooks_url":"https://api.github.com/repos/symfony/symfony/hooks","issue_events_url":"https://api.github.com/repos/symfony/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/symfony/symfony/events","assignees_url":"https://api.github.com/repos/symfony/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/symfony/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/symfony/symfony/tags","blobs_url":"https://api.github.com/repos/symfony/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/symfony/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/symfony/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/symfony/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/symfony/symfony/languages","stargazers_url":"https://api.github.com/repos/symfony/symfony/stargazers","contributors_url":"https://api.github.com/repos/symfony/symfony/contributors","subscribers_url":"https://api.github.com/repos/symfony/symfony/subscribers","subscription_url":"https://api.github.com/repos/symfony/symfony/subscription","commits_url":"https://api.github.com/repos/symfony/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/symfony/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/symfony/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/symfony/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/symfony/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/symfony/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/symfony/symfony/merges","archive_url":"https://api.github.com/repos/symfony/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/symfony/symfony/downloads","issues_url":"https://api.github.com/repos/symfony/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/symfony/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/symfony/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/symfony/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/symfony/symfony/labels{/name}","releases_url":"https://api.github.com/repos/symfony/symfony/releases{/id}","created_at":"2010-01-04T14:21:21Z","updated_at":"2015-03-26T10:16:25Z","pushed_at":"2015-03-26T10:08:08Z","git_url":"git://github.com/symfony/symfony.git","ssh_url":"git@github.com:symfony/symfony.git","clone_url":"https://github.com/symfony/symfony.git","svn_url":"https://github.com/symfony/symfony","homepage":"symfony.com","size":210835,"stargazers_count":9893,"watchers_count":9893,"language":"PHP","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":3870,"mirror_url":null,"open_issues_count":782,"forks":3870,"open_issues":782,"watchers":9893,"default_branch":"2.7"}},"_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/14029"},"html":{"href":"https://github.com/symfony/symfony/pull/14029"},"issue":{"href":"https://api.github.com/repos/symfony/symfony/issues/14029"},"comments":{"href":"https://api.github.com/repos/symfony/symfony/issues/14029/comments"},"review_comments":{"href":"https://api.github.com/repos/symfony/symfony/pulls/14029/comments"},"review_comment":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/symfony/symfony/pulls/14029/commits"},"statuses":{"href":"https://api.github.com/repos/symfony/symfony/statuses/14d622b3919b39ac5e33f5dd5f58c57108cfebdd"}}}}