{"action":"created","comment":{"url":"https://api.github.com/repos/znc/znc/pulls/comments/47445582","id":47445582,"diff_hunk":"@@ -852,6 +852,94 @@ bool CUser::IsHostAllowed(const CString& sHostMask) const {\n     for (const CString& sHost : m_ssAllowedHosts) {\n         if (sHostMask.WildCmp(sHost)) {\n             return true;\n+        } else {\n+            // CIDR notation checker, e.g. \"192.0.2.0/24\" or \"2001:db8::/32\"\n+\n+            // Try to split the string into an IP and routing prefix\n+            VCString vsSplitCIDR;\n+            const int iSplitCIDRCount = sHost.Split(\"/\", vsSplitCIDR, false);\n+            const int iRoutingPrefix = vsSplitCIDR.back().ToInt();\n+\n+            if (iSplitCIDRCount != 2 || iRoutingPrefix < 0) continue;\n+\n+            // Convert each IP from a numeric string to an addrinfo\n+            addrinfo aiHints;\n+            memset(&aiHints, 0, sizeof(addrinfo));\n+            aiHints.ai_flags = AI_NUMERICHOST;\n+\n+            addrinfo* aiHost;\n+            int iIsHostValid =\n+                getaddrinfo(sHostMask.c_str(), NULL, &aiHints, &aiHost);\n+            if (iIsHostValid != 0) continue;\n+\n+            aiHints.ai_family = aiHost->ai_family;  // Host and range must be in\n+                                                    // the same address family\n+\n+            addrinfo* aiRange;\n+            int iIsRangeValid = getaddrinfo(vsSplitCIDR.front().c_str(), NULL,\n+                                            &aiHints, &aiRange);\n+            if (iIsRangeValid != 0) {\n+                freeaddrinfo(aiHost);\n+                continue;\n+            }\n+\n+            // \"/0\" allows all IPv[4|6] addresses","path":"src/User.cpp","position":35,"original_position":35,"commit_id":"56c97af14b5ef15f5cc5842b9681d2c342c866bc","original_commit_id":"56c97af14b5ef15f5cc5842b9681d2c342c866bc","user":{"login":"DinCahill","id":510163,"avatar_url":"https://avatars.githubusercontent.com/u/510163?v=3","gravatar_id":"","url":"https://api.github.com/users/DinCahill","html_url":"https://github.com/DinCahill","followers_url":"https://api.github.com/users/DinCahill/followers","following_url":"https://api.github.com/users/DinCahill/following{/other_user}","gists_url":"https://api.github.com/users/DinCahill/gists{/gist_id}","starred_url":"https://api.github.com/users/DinCahill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DinCahill/subscriptions","organizations_url":"https://api.github.com/users/DinCahill/orgs","repos_url":"https://api.github.com/users/DinCahill/repos","events_url":"https://api.github.com/users/DinCahill/events{/privacy}","received_events_url":"https://api.github.com/users/DinCahill/received_events","type":"User","site_admin":false},"body":"Alrighty!","created_at":"2015-12-13T14:49:25Z","updated_at":"2015-12-13T14:49:25Z","html_url":"https://github.com/znc/znc/pull/1205#discussion_r47445582","pull_request_url":"https://api.github.com/repos/znc/znc/pulls/1205","_links":{"self":{"href":"https://api.github.com/repos/znc/znc/pulls/comments/47445582"},"html":{"href":"https://github.com/znc/znc/pull/1205#discussion_r47445582"},"pull_request":{"href":"https://api.github.com/repos/znc/znc/pulls/1205"}}},"pull_request":{"url":"https://api.github.com/repos/znc/znc/pulls/1205","id":53494687,"html_url":"https://github.com/znc/znc/pull/1205","diff_url":"https://github.com/znc/znc/pull/1205.diff","patch_url":"https://github.com/znc/znc/pull/1205.patch","issue_url":"https://api.github.com/repos/znc/znc/issues/1205","number":1205,"state":"open","locked":false,"title":"Add support for CIDR notation in allowed hosts list.","user":{"login":"DinCahill","id":510163,"avatar_url":"https://avatars.githubusercontent.com/u/510163?v=3","gravatar_id":"","url":"https://api.github.com/users/DinCahill","html_url":"https://github.com/DinCahill","followers_url":"https://api.github.com/users/DinCahill/followers","following_url":"https://api.github.com/users/DinCahill/following{/other_user}","gists_url":"https://api.github.com/users/DinCahill/gists{/gist_id}","starred_url":"https://api.github.com/users/DinCahill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DinCahill/subscriptions","organizations_url":"https://api.github.com/users/DinCahill/orgs","repos_url":"https://api.github.com/users/DinCahill/repos","events_url":"https://api.github.com/users/DinCahill/events{/privacy}","received_events_url":"https://api.github.com/users/DinCahill/received_events","type":"User","site_admin":false},"body":"Fixes #207 \r\n\r\nThis is my first time writing C++. Please let me know if anything looks dodgy.\r\nA non-exhaustive bunch of test cases all seem to work. I've also left wildcard matching in there.\r\n\r\nI also have a patch for 1.6.x, but I don't know if that's desired.","created_at":"2015-12-13T07:29:01Z","updated_at":"2015-12-13T14:49:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"add1c9dcbbbec192a03b7a2b4cf47c156e616e6a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/znc/znc/pulls/1205/commits","review_comments_url":"https://api.github.com/repos/znc/znc/pulls/1205/comments","review_comment_url":"https://api.github.com/repos/znc/znc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/znc/znc/issues/1205/comments","statuses_url":"https://api.github.com/repos/znc/znc/statuses/56c97af14b5ef15f5cc5842b9681d2c342c866bc","head":{"label":"DinCahill:dev","ref":"dev","sha":"56c97af14b5ef15f5cc5842b9681d2c342c866bc","user":{"login":"DinCahill","id":510163,"avatar_url":"https://avatars.githubusercontent.com/u/510163?v=3","gravatar_id":"","url":"https://api.github.com/users/DinCahill","html_url":"https://github.com/DinCahill","followers_url":"https://api.github.com/users/DinCahill/followers","following_url":"https://api.github.com/users/DinCahill/following{/other_user}","gists_url":"https://api.github.com/users/DinCahill/gists{/gist_id}","starred_url":"https://api.github.com/users/DinCahill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DinCahill/subscriptions","organizations_url":"https://api.github.com/users/DinCahill/orgs","repos_url":"https://api.github.com/users/DinCahill/repos","events_url":"https://api.github.com/users/DinCahill/events{/privacy}","received_events_url":"https://api.github.com/users/DinCahill/received_events","type":"User","site_admin":false},"repo":{"id":47868090,"name":"znc","full_name":"DinCahill/znc","owner":{"login":"DinCahill","id":510163,"avatar_url":"https://avatars.githubusercontent.com/u/510163?v=3","gravatar_id":"","url":"https://api.github.com/users/DinCahill","html_url":"https://github.com/DinCahill","followers_url":"https://api.github.com/users/DinCahill/followers","following_url":"https://api.github.com/users/DinCahill/following{/other_user}","gists_url":"https://api.github.com/users/DinCahill/gists{/gist_id}","starred_url":"https://api.github.com/users/DinCahill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DinCahill/subscriptions","organizations_url":"https://api.github.com/users/DinCahill/orgs","repos_url":"https://api.github.com/users/DinCahill/repos","events_url":"https://api.github.com/users/DinCahill/events{/privacy}","received_events_url":"https://api.github.com/users/DinCahill/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DinCahill/znc","description":"Official repository for the ZNC IRC bouncer","fork":true,"url":"https://api.github.com/repos/DinCahill/znc","forks_url":"https://api.github.com/repos/DinCahill/znc/forks","keys_url":"https://api.github.com/repos/DinCahill/znc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DinCahill/znc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DinCahill/znc/teams","hooks_url":"https://api.github.com/repos/DinCahill/znc/hooks","issue_events_url":"https://api.github.com/repos/DinCahill/znc/issues/events{/number}","events_url":"https://api.github.com/repos/DinCahill/znc/events","assignees_url":"https://api.github.com/repos/DinCahill/znc/assignees{/user}","branches_url":"https://api.github.com/repos/DinCahill/znc/branches{/branch}","tags_url":"https://api.github.com/repos/DinCahill/znc/tags","blobs_url":"https://api.github.com/repos/DinCahill/znc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DinCahill/znc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DinCahill/znc/git/refs{/sha}","trees_url":"https://api.github.com/repos/DinCahill/znc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DinCahill/znc/statuses/{sha}","languages_url":"https://api.github.com/repos/DinCahill/znc/languages","stargazers_url":"https://api.github.com/repos/DinCahill/znc/stargazers","contributors_url":"https://api.github.com/repos/DinCahill/znc/contributors","subscribers_url":"https://api.github.com/repos/DinCahill/znc/subscribers","subscription_url":"https://api.github.com/repos/DinCahill/znc/subscription","commits_url":"https://api.github.com/repos/DinCahill/znc/commits{/sha}","git_commits_url":"https://api.github.com/repos/DinCahill/znc/git/commits{/sha}","comments_url":"https://api.github.com/repos/DinCahill/znc/comments{/number}","issue_comment_url":"https://api.github.com/repos/DinCahill/znc/issues/comments{/number}","contents_url":"https://api.github.com/repos/DinCahill/znc/contents/{+path}","compare_url":"https://api.github.com/repos/DinCahill/znc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DinCahill/znc/merges","archive_url":"https://api.github.com/repos/DinCahill/znc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DinCahill/znc/downloads","issues_url":"https://api.github.com/repos/DinCahill/znc/issues{/number}","pulls_url":"https://api.github.com/repos/DinCahill/znc/pulls{/number}","milestones_url":"https://api.github.com/repos/DinCahill/znc/milestones{/number}","notifications_url":"https://api.github.com/repos/DinCahill/znc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DinCahill/znc/labels{/name}","releases_url":"https://api.github.com/repos/DinCahill/znc/releases{/id}","created_at":"2015-12-12T06:50:06Z","updated_at":"2015-12-12T06:50:08Z","pushed_at":"2015-12-13T12:23:49Z","git_url":"git://github.com/DinCahill/znc.git","ssh_url":"git@github.com:DinCahill/znc.git","clone_url":"https://github.com/DinCahill/znc.git","svn_url":"https://github.com/DinCahill/znc","homepage":"http://znc.in/","size":14595,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"master"}},"base":{"label":"znc:master","ref":"master","sha":"16a8c777370ffb6fe661b0f0aa5ff4f35f26a249","user":{"login":"znc","id":179272,"avatar_url":"https://avatars.githubusercontent.com/u/179272?v=3","gravatar_id":"","url":"https://api.github.com/users/znc","html_url":"https://github.com/znc","followers_url":"https://api.github.com/users/znc/followers","following_url":"https://api.github.com/users/znc/following{/other_user}","gists_url":"https://api.github.com/users/znc/gists{/gist_id}","starred_url":"https://api.github.com/users/znc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/znc/subscriptions","organizations_url":"https://api.github.com/users/znc/orgs","repos_url":"https://api.github.com/users/znc/repos","events_url":"https://api.github.com/users/znc/events{/privacy}","received_events_url":"https://api.github.com/users/znc/received_events","type":"Organization","site_admin":false},"repo":{"id":465681,"name":"znc","full_name":"znc/znc","owner":{"login":"znc","id":179272,"avatar_url":"https://avatars.githubusercontent.com/u/179272?v=3","gravatar_id":"","url":"https://api.github.com/users/znc","html_url":"https://github.com/znc","followers_url":"https://api.github.com/users/znc/followers","following_url":"https://api.github.com/users/znc/following{/other_user}","gists_url":"https://api.github.com/users/znc/gists{/gist_id}","starred_url":"https://api.github.com/users/znc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/znc/subscriptions","organizations_url":"https://api.github.com/users/znc/orgs","repos_url":"https://api.github.com/users/znc/repos","events_url":"https://api.github.com/users/znc/events{/privacy}","received_events_url":"https://api.github.com/users/znc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/znc/znc","description":"Official repository for the ZNC IRC bouncer","fork":false,"url":"https://api.github.com/repos/znc/znc","forks_url":"https://api.github.com/repos/znc/znc/forks","keys_url":"https://api.github.com/repos/znc/znc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/znc/znc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/znc/znc/teams","hooks_url":"https://api.github.com/repos/znc/znc/hooks","issue_events_url":"https://api.github.com/repos/znc/znc/issues/events{/number}","events_url":"https://api.github.com/repos/znc/znc/events","assignees_url":"https://api.github.com/repos/znc/znc/assignees{/user}","branches_url":"https://api.github.com/repos/znc/znc/branches{/branch}","tags_url":"https://api.github.com/repos/znc/znc/tags","blobs_url":"https://api.github.com/repos/znc/znc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/znc/znc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/znc/znc/git/refs{/sha}","trees_url":"https://api.github.com/repos/znc/znc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/znc/znc/statuses/{sha}","languages_url":"https://api.github.com/repos/znc/znc/languages","stargazers_url":"https://api.github.com/repos/znc/znc/stargazers","contributors_url":"https://api.github.com/repos/znc/znc/contributors","subscribers_url":"https://api.github.com/repos/znc/znc/subscribers","subscription_url":"https://api.github.com/repos/znc/znc/subscription","commits_url":"https://api.github.com/repos/znc/znc/commits{/sha}","git_commits_url":"https://api.github.com/repos/znc/znc/git/commits{/sha}","comments_url":"https://api.github.com/repos/znc/znc/comments{/number}","issue_comment_url":"https://api.github.com/repos/znc/znc/issues/comments{/number}","contents_url":"https://api.github.com/repos/znc/znc/contents/{+path}","compare_url":"https://api.github.com/repos/znc/znc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/znc/znc/merges","archive_url":"https://api.github.com/repos/znc/znc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/znc/znc/downloads","issues_url":"https://api.github.com/repos/znc/znc/issues{/number}","pulls_url":"https://api.github.com/repos/znc/znc/pulls{/number}","milestones_url":"https://api.github.com/repos/znc/znc/milestones{/number}","notifications_url":"https://api.github.com/repos/znc/znc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/znc/znc/labels{/name}","releases_url":"https://api.github.com/repos/znc/znc/releases{/id}","created_at":"2010-01-09T23:44:05Z","updated_at":"2015-12-11T19:54:54Z","pushed_at":"2015-12-13T12:23:50Z","git_url":"git://github.com/znc/znc.git","ssh_url":"git@github.com:znc/znc.git","clone_url":"https://github.com/znc/znc.git","svn_url":"https://github.com/znc/znc","homepage":"http://znc.in/","size":15440,"stargazers_count":1098,"watchers_count":1098,"language":"C++","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":268,"mirror_url":null,"open_issues_count":244,"forks":268,"open_issues":244,"watchers":1098,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/znc/znc/pulls/1205"},"html":{"href":"https://github.com/znc/znc/pull/1205"},"issue":{"href":"https://api.github.com/repos/znc/znc/issues/1205"},"comments":{"href":"https://api.github.com/repos/znc/znc/issues/1205/comments"},"review_comments":{"href":"https://api.github.com/repos/znc/znc/pulls/1205/comments"},"review_comment":{"href":"https://api.github.com/repos/znc/znc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/znc/znc/pulls/1205/commits"},"statuses":{"href":"https://api.github.com/repos/znc/znc/statuses/56c97af14b5ef15f5cc5842b9681d2c342c866bc"}}}}