{"action":"created","comment":{"url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/comments/89264326","pull_request_review_id":9810408,"id":89264326,"diff_hunk":"@@ -526,3 +587,47 @@ def handle(request):\n         return web.Response(body=result, status=status_code)\n \n     return handle\n+\n+\n+class IpBan(object):\n+    \"\"\"Represents banned IP address.\"\"\"\n+\n+    def __init__(self, ip_ban: str, banned_at: datetime=None) -> None:\n+        \"\"\"Initializing Ip Ban object.\"\"\"\n+        self.ip_address = ip_address(ip_ban)\n+        self.banned_at = banned_at\n+        if self.banned_at is None:\n+            self.banned_at = datetime.utcnow()\n+\n+\n+def load_ip_bans_config(path: str):\n+    \"\"\"Loading list of banned IPs from config file.\"\"\"\n+    ip_list = []\n+    ip_schema = vol.Schema({\n+        vol.Optional('banned_at'): vol.Any(None, cv.exact_time)\n+    })\n+\n+    try:\n+        list_ = load_yaml_config_file(path)\n+        for ip_ban in list_:\n+            try:\n+                ban = ip_schema(list_[ip_ban])\n+                ban['ip_ban'] = ip_address(ip_ban)\n+                ip_list.append(IpBan(**ban))\n+            except vol.Invalid:\n+                continue\n+\n+    except(HomeAssistantError, FileNotFoundError):\n+        return []","path":"homeassistant/components/http.py","position":214,"original_position":214,"commit_id":"fa6f24d256677366b2f1188f7fb20d38f19da119","original_commit_id":"fa6f24d256677366b2f1188f7fb20d38f19da119","user":{"login":"balloob","id":1444314,"avatar_url":"https://avatars.githubusercontent.com/u/1444314?v=3","gravatar_id":"","url":"https://api.github.com/users/balloob","html_url":"https://github.com/balloob","followers_url":"https://api.github.com/users/balloob/followers","following_url":"https://api.github.com/users/balloob/following{/other_user}","gists_url":"https://api.github.com/users/balloob/gists{/gist_id}","starred_url":"https://api.github.com/users/balloob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/balloob/subscriptions","organizations_url":"https://api.github.com/users/balloob/orgs","repos_url":"https://api.github.com/users/balloob/repos","events_url":"https://api.github.com/users/balloob/events{/privacy}","received_events_url":"https://api.github.com/users/balloob/received_events","type":"User","site_admin":false},"body":"You should report when a HomeAssistantError occurs","created_at":"2016-11-23T07:12:43Z","updated_at":"2016-11-23T07:17:38Z","html_url":"https://github.com/home-assistant/home-assistant/pull/4424#discussion_r89264326","pull_request_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/4424","_links":{"self":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/comments/89264326"},"html":{"href":"https://github.com/home-assistant/home-assistant/pull/4424#discussion_r89264326"},"pull_request":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/4424"}}},"pull_request":{"url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/4424","id":94053712,"html_url":"https://github.com/home-assistant/home-assistant/pull/4424","diff_url":"https://github.com/home-assistant/home-assistant/pull/4424.diff","patch_url":"https://github.com/home-assistant/home-assistant/pull/4424.patch","issue_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/4424","number":4424,"state":"open","locked":false,"title":"Advanced Ip filtering","user":{"login":"vkorn","id":3168836,"avatar_url":"https://avatars.githubusercontent.com/u/3168836?v=3","gravatar_id":"","url":"https://api.github.com/users/vkorn","html_url":"https://github.com/vkorn","followers_url":"https://api.github.com/users/vkorn/followers","following_url":"https://api.github.com/users/vkorn/following{/other_user}","gists_url":"https://api.github.com/users/vkorn/gists{/gist_id}","starred_url":"https://api.github.com/users/vkorn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkorn/subscriptions","organizations_url":"https://api.github.com/users/vkorn/orgs","repos_url":"https://api.github.com/users/vkorn/repos","events_url":"https://api.github.com/users/vkorn/events{/privacy}","received_events_url":"https://api.github.com/users/vkorn/received_events","type":"User","site_admin":false},"body":"**Description:**\r\nImplementation of automatic IP ban in case of multiple failed login attempts. Partially related to [this request](https://community.home-assistant.io/t/failed-login-lockout-brute-force-protection/6287). \r\n\r\nFile `ip_bans.yaml` automatically created in config folder.\r\n\r\n**Pull request in [home-assistant.github.io](https://github.com/home-assistant/home-assistant.github.io) with documentation (if applicable):** home-assistant/home-assistant.github.io#1450\r\n\r\n**Example entry for `configuration.yaml` (if applicable):**\r\nTwo new params in http component: \r\n```yaml\r\nhttp:\r\n  ip_ban_enabled: True\r\n  login_attempts_threshold: 2\r\n```\r\n\r\n**Checklist:**\r\n\r\nIf user exposed functionality or configuration variables are added/changed:\r\n  - [x] Documentation added/updated in [home-assistant.github.io](https://github.com/home-assistant/home-assistant.github.io)\r\n\r\nIf the code does not interact with devices:\r\n  - [x] Local tests with `tox` run successfully. **Your PR cannot be merged unless tests pass**\r\n  - [x] Tests have been added to verify that the new code works.\r\n\r\n[ex-requir]: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/keyboard.py#L16\r\n[ex-import]: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/keyboard.py#L51","created_at":"2016-11-16T21:28:24Z","updated_at":"2016-11-23T07:17:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"afdc274007ae338b9ff592728abafa842a54f5c3","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/4424/commits","review_comments_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/4424/comments","review_comment_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls/comments{/number}","comments_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/4424/comments","statuses_url":"https://api.github.com/repos/home-assistant/home-assistant/statuses/fa6f24d256677366b2f1188f7fb20d38f19da119","head":{"label":"vkorn:ip_filtering","ref":"ip_filtering","sha":"fa6f24d256677366b2f1188f7fb20d38f19da119","user":{"login":"vkorn","id":3168836,"avatar_url":"https://avatars.githubusercontent.com/u/3168836?v=3","gravatar_id":"","url":"https://api.github.com/users/vkorn","html_url":"https://github.com/vkorn","followers_url":"https://api.github.com/users/vkorn/followers","following_url":"https://api.github.com/users/vkorn/following{/other_user}","gists_url":"https://api.github.com/users/vkorn/gists{/gist_id}","starred_url":"https://api.github.com/users/vkorn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkorn/subscriptions","organizations_url":"https://api.github.com/users/vkorn/orgs","repos_url":"https://api.github.com/users/vkorn/repos","events_url":"https://api.github.com/users/vkorn/events{/privacy}","received_events_url":"https://api.github.com/users/vkorn/received_events","type":"User","site_admin":false},"repo":{"id":73741333,"name":"home-assistant","full_name":"vkorn/home-assistant","owner":{"login":"vkorn","id":3168836,"avatar_url":"https://avatars.githubusercontent.com/u/3168836?v=3","gravatar_id":"","url":"https://api.github.com/users/vkorn","html_url":"https://github.com/vkorn","followers_url":"https://api.github.com/users/vkorn/followers","following_url":"https://api.github.com/users/vkorn/following{/other_user}","gists_url":"https://api.github.com/users/vkorn/gists{/gist_id}","starred_url":"https://api.github.com/users/vkorn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkorn/subscriptions","organizations_url":"https://api.github.com/users/vkorn/orgs","repos_url":"https://api.github.com/users/vkorn/repos","events_url":"https://api.github.com/users/vkorn/events{/privacy}","received_events_url":"https://api.github.com/users/vkorn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vkorn/home-assistant","description":":house_with_garden: Open-source home automation platform running on Python 3","fork":true,"url":"https://api.github.com/repos/vkorn/home-assistant","forks_url":"https://api.github.com/repos/vkorn/home-assistant/forks","keys_url":"https://api.github.com/repos/vkorn/home-assistant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vkorn/home-assistant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vkorn/home-assistant/teams","hooks_url":"https://api.github.com/repos/vkorn/home-assistant/hooks","issue_events_url":"https://api.github.com/repos/vkorn/home-assistant/issues/events{/number}","events_url":"https://api.github.com/repos/vkorn/home-assistant/events","assignees_url":"https://api.github.com/repos/vkorn/home-assistant/assignees{/user}","branches_url":"https://api.github.com/repos/vkorn/home-assistant/branches{/branch}","tags_url":"https://api.github.com/repos/vkorn/home-assistant/tags","blobs_url":"https://api.github.com/repos/vkorn/home-assistant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vkorn/home-assistant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vkorn/home-assistant/git/refs{/sha}","trees_url":"https://api.github.com/repos/vkorn/home-assistant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vkorn/home-assistant/statuses/{sha}","languages_url":"https://api.github.com/repos/vkorn/home-assistant/languages","stargazers_url":"https://api.github.com/repos/vkorn/home-assistant/stargazers","contributors_url":"https://api.github.com/repos/vkorn/home-assistant/contributors","subscribers_url":"https://api.github.com/repos/vkorn/home-assistant/subscribers","subscription_url":"https://api.github.com/repos/vkorn/home-assistant/subscription","commits_url":"https://api.github.com/repos/vkorn/home-assistant/commits{/sha}","git_commits_url":"https://api.github.com/repos/vkorn/home-assistant/git/commits{/sha}","comments_url":"https://api.github.com/repos/vkorn/home-assistant/comments{/number}","issue_comment_url":"https://api.github.com/repos/vkorn/home-assistant/issues/comments{/number}","contents_url":"https://api.github.com/repos/vkorn/home-assistant/contents/{+path}","compare_url":"https://api.github.com/repos/vkorn/home-assistant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vkorn/home-assistant/merges","archive_url":"https://api.github.com/repos/vkorn/home-assistant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vkorn/home-assistant/downloads","issues_url":"https://api.github.com/repos/vkorn/home-assistant/issues{/number}","pulls_url":"https://api.github.com/repos/vkorn/home-assistant/pulls{/number}","milestones_url":"https://api.github.com/repos/vkorn/home-assistant/milestones{/number}","notifications_url":"https://api.github.com/repos/vkorn/home-assistant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vkorn/home-assistant/labels{/name}","releases_url":"https://api.github.com/repos/vkorn/home-assistant/releases{/id}","deployments_url":"https://api.github.com/repos/vkorn/home-assistant/deployments","created_at":"2016-11-14T19:49:35Z","updated_at":"2016-11-14T19:49:39Z","pushed_at":"2016-11-19T16:56:35Z","git_url":"git://github.com/vkorn/home-assistant.git","ssh_url":"git@github.com:vkorn/home-assistant.git","clone_url":"https://github.com/vkorn/home-assistant.git","svn_url":"https://github.com/vkorn/home-assistant","homepage":"https://home-assistant.io","size":43523,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"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":"dev"}},"base":{"label":"home-assistant:dev","ref":"dev","sha":"f3748ce5354d3198a6badf370a6ef80abbd7366e","user":{"login":"home-assistant","id":13844975,"avatar_url":"https://avatars.githubusercontent.com/u/13844975?v=3","gravatar_id":"","url":"https://api.github.com/users/home-assistant","html_url":"https://github.com/home-assistant","followers_url":"https://api.github.com/users/home-assistant/followers","following_url":"https://api.github.com/users/home-assistant/following{/other_user}","gists_url":"https://api.github.com/users/home-assistant/gists{/gist_id}","starred_url":"https://api.github.com/users/home-assistant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/home-assistant/subscriptions","organizations_url":"https://api.github.com/users/home-assistant/orgs","repos_url":"https://api.github.com/users/home-assistant/repos","events_url":"https://api.github.com/users/home-assistant/events{/privacy}","received_events_url":"https://api.github.com/users/home-assistant/received_events","type":"Organization","site_admin":false},"repo":{"id":12888993,"name":"home-assistant","full_name":"home-assistant/home-assistant","owner":{"login":"home-assistant","id":13844975,"avatar_url":"https://avatars.githubusercontent.com/u/13844975?v=3","gravatar_id":"","url":"https://api.github.com/users/home-assistant","html_url":"https://github.com/home-assistant","followers_url":"https://api.github.com/users/home-assistant/followers","following_url":"https://api.github.com/users/home-assistant/following{/other_user}","gists_url":"https://api.github.com/users/home-assistant/gists{/gist_id}","starred_url":"https://api.github.com/users/home-assistant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/home-assistant/subscriptions","organizations_url":"https://api.github.com/users/home-assistant/orgs","repos_url":"https://api.github.com/users/home-assistant/repos","events_url":"https://api.github.com/users/home-assistant/events{/privacy}","received_events_url":"https://api.github.com/users/home-assistant/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/home-assistant/home-assistant","description":":house_with_garden: Open-source home automation platform running on Python 3","fork":false,"url":"https://api.github.com/repos/home-assistant/home-assistant","forks_url":"https://api.github.com/repos/home-assistant/home-assistant/forks","keys_url":"https://api.github.com/repos/home-assistant/home-assistant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/home-assistant/home-assistant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/home-assistant/home-assistant/teams","hooks_url":"https://api.github.com/repos/home-assistant/home-assistant/hooks","issue_events_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/events{/number}","events_url":"https://api.github.com/repos/home-assistant/home-assistant/events","assignees_url":"https://api.github.com/repos/home-assistant/home-assistant/assignees{/user}","branches_url":"https://api.github.com/repos/home-assistant/home-assistant/branches{/branch}","tags_url":"https://api.github.com/repos/home-assistant/home-assistant/tags","blobs_url":"https://api.github.com/repos/home-assistant/home-assistant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/home-assistant/home-assistant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/home-assistant/home-assistant/git/refs{/sha}","trees_url":"https://api.github.com/repos/home-assistant/home-assistant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/home-assistant/home-assistant/statuses/{sha}","languages_url":"https://api.github.com/repos/home-assistant/home-assistant/languages","stargazers_url":"https://api.github.com/repos/home-assistant/home-assistant/stargazers","contributors_url":"https://api.github.com/repos/home-assistant/home-assistant/contributors","subscribers_url":"https://api.github.com/repos/home-assistant/home-assistant/subscribers","subscription_url":"https://api.github.com/repos/home-assistant/home-assistant/subscription","commits_url":"https://api.github.com/repos/home-assistant/home-assistant/commits{/sha}","git_commits_url":"https://api.github.com/repos/home-assistant/home-assistant/git/commits{/sha}","comments_url":"https://api.github.com/repos/home-assistant/home-assistant/comments{/number}","issue_comment_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/comments{/number}","contents_url":"https://api.github.com/repos/home-assistant/home-assistant/contents/{+path}","compare_url":"https://api.github.com/repos/home-assistant/home-assistant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/home-assistant/home-assistant/merges","archive_url":"https://api.github.com/repos/home-assistant/home-assistant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/home-assistant/home-assistant/downloads","issues_url":"https://api.github.com/repos/home-assistant/home-assistant/issues{/number}","pulls_url":"https://api.github.com/repos/home-assistant/home-assistant/pulls{/number}","milestones_url":"https://api.github.com/repos/home-assistant/home-assistant/milestones{/number}","notifications_url":"https://api.github.com/repos/home-assistant/home-assistant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/home-assistant/home-assistant/labels{/name}","releases_url":"https://api.github.com/repos/home-assistant/home-assistant/releases{/id}","deployments_url":"https://api.github.com/repos/home-assistant/home-assistant/deployments","created_at":"2013-09-17T07:29:48Z","updated_at":"2016-11-23T03:10:26Z","pushed_at":"2016-11-23T07:06:40Z","git_url":"git://github.com/home-assistant/home-assistant.git","ssh_url":"git@github.com:home-assistant/home-assistant.git","clone_url":"https://github.com/home-assistant/home-assistant.git","svn_url":"https://github.com/home-assistant/home-assistant","homepage":"https://home-assistant.io","size":86357,"stargazers_count":4699,"watchers_count":4699,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1234,"mirror_url":null,"open_issues_count":304,"forks":1234,"open_issues":304,"watchers":4699,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/4424"},"html":{"href":"https://github.com/home-assistant/home-assistant/pull/4424"},"issue":{"href":"https://api.github.com/repos/home-assistant/home-assistant/issues/4424"},"comments":{"href":"https://api.github.com/repos/home-assistant/home-assistant/issues/4424/comments"},"review_comments":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/4424/comments"},"review_comment":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/home-assistant/home-assistant/pulls/4424/commits"},"statuses":{"href":"https://api.github.com/repos/home-assistant/home-assistant/statuses/fa6f24d256677366b2f1188f7fb20d38f19da119"}}}}
{"actor":{"display_login":"balloob"}}