{"action":"created","comment":{"url":"https://api.github.com/repos/tempesta-tech/tempesta/pulls/comments/67399515","id":67399515,"diff_hunk":"@@ -521,6 +555,176 @@ tfw_cleanup_locache(TfwCfgSpec *cs)\n \t__tfw_cleanup_locache();\n }\n \n+/*\n+ *  Match the ip address against the ACL list.\n+ */\n+static bool\n+tfw_capuacl_lookup(TfwVhost *vhost, TfwAddr *addr)\n+{\n+\tint i;\n+\tstruct in6_addr *inaddr = &addr->v6.sin6_addr;\n+\n+\tfor (i = 0; i < vhost->capuacl_sz; ++i) {\n+\t\tstruct in6_addr *acl_inaddr = &vhost->capuacl[i].v6.sin6_addr;\n+\t\tif (ipv6_prefix_equal(inaddr, acl_inaddr, addr->in6_prefix))\n+\t\t\treturn true;\n+\t}\n+\treturn false;\n+}\n+\n+/*\n+ * Parse an IP address in CIDR format. Try to parse it as an IPv4\n+ * address first. If successful, convert the IPv4 address to IPv6\n+ * address. Otherwise, try to parse it as an IPv6 address.\n+ * Returns a pointer to the next character after the parsed string\n+ * if the result is positive. Returns NULL in case of an error.\n+ */\n+static const char *\n+tfw_capuacl_parse_addr(const char *arg, TfwAddr *addr)\n+{\n+\tchar delim = '/';\n+\tTfwAddr tmpaddr = {};\n+\tconst char *pptr;\n+\t__be32 *v4_saddr = &tmpaddr.v4.sin_addr.s_addr;\n+\tstruct in6_addr *v6_inaddr = &tmpaddr.v6.sin6_addr;\n+\n+\tif (in4_pton(arg, -1, (u8 *)v4_saddr, delim, &pptr)) {\n+\t\tipv6_addr_set_v4mapped(*v4_saddr, v6_inaddr);\n+\t\ttmpaddr.family = AF_INET;\n+\t\tgoto done;\n+\t}\n+\tif (*arg == '[') {\n+\t\targ++;\n+\t\tdelim = ']';\n+\t}\n+\tif (!in6_pton(arg, -1, (u8 *)&v6_inaddr->s6_addr, delim, &pptr))\n+\t\treturn NULL;\n+\ttmpaddr.family = AF_INET6;\n+\tif (*pptr == ']')\n+\t\t++pptr;\n+done:\n+\tif (*pptr == '/')\n+\t\t++pptr;\n+\n+\t*addr = tmpaddr;\n+\treturn pptr;\n+}\n+\n+/*\n+ * Parse an IP address in CIDR format specified in the cache_purge_acl\n+ * directive. That include an IPv4 or IPv6 address, and a potential\n+ * address prefix specified as the number of bits after the '/' char.\n+ * Returns zero if the result is positive.\n+ * Returns a negative error number in case of an error.\n+ */\n+static int\n+tfw_capuacl_parse_value(const char *arg, TfwAddr *addr)\n+{\n+\tu8 prefix;\n+\tconst char *pptr;\n+\n+\tif ((pptr = tfw_capuacl_parse_addr(arg, addr)) == NULL)\n+\t\treturn -EINVAL;\n+\n+\t/* Parse a possible prefix length. */\n+\tif (*pptr == '\\0') {\n+\t\taddr->in6_prefix = 128;\n+\t\treturn 0;\n+\t}\n+\tif (kstrtou8(pptr, 10, &prefix) || (prefix == 0))\n+\t\treturn -EINVAL;\n+\tif (addr->family == AF_INET) {\n+\t\tif (prefix > 32)\n+\t\t\treturn -EINVAL;\n+\t\tprefix += 128 - 32;\n+\t\taddr->family = AF_INET6;\n+\t} else if (prefix > 128) {\n+\t\treturn -EINVAL;\n+\t}\n+\taddr->in6_prefix = prefix;\n+\n+\treturn 0;\n+}","path":"tempesta_fw/vhost.c","position":153,"original_position":153,"commit_id":"55268c0c0cc5ca9053121dd0a7065558234a2951","original_commit_id":"55268c0c0cc5ca9053121dd0a7065558234a2951","user":{"login":"krizhanovsky","id":884694,"avatar_url":"https://avatars.githubusercontent.com/u/884694?v=3","gravatar_id":"","url":"https://api.github.com/users/krizhanovsky","html_url":"https://github.com/krizhanovsky","followers_url":"https://api.github.com/users/krizhanovsky/followers","following_url":"https://api.github.com/users/krizhanovsky/following{/other_user}","gists_url":"https://api.github.com/users/krizhanovsky/gists{/gist_id}","starred_url":"https://api.github.com/users/krizhanovsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krizhanovsky/subscriptions","organizations_url":"https://api.github.com/users/krizhanovsky/orgs","repos_url":"https://api.github.com/users/krizhanovsky/repos","events_url":"https://api.github.com/users/krizhanovsky/events{/privacy}","received_events_url":"https://api.github.com/users/krizhanovsky/received_events","type":"User","site_admin":false},"body":"The two functions above accept `const char` and `TfwAddr`, so it seems it's better to move them to addr.[ch] and rename them such that they parse netmasks becomes clear.","created_at":"2016-06-16T18:31:14Z","updated_at":"2016-06-16T18:31:14Z","html_url":"https://github.com/tempesta-tech/tempesta/pull/558#discussion_r67399515","pull_request_url":"https://api.github.com/repos/tempesta-tech/tempesta/pulls/558","_links":{"self":{"href":"https://api.github.com/repos/tempesta-tech/tempesta/pulls/comments/67399515"},"html":{"href":"https://github.com/tempesta-tech/tempesta/pull/558#discussion_r67399515"},"pull_request":{"href":"https://api.github.com/repos/tempesta-tech/tempesta/pulls/558"}}},"pull_request":{"url":"https://api.github.com/repos/tempesta-tech/tempesta/pulls/558","id":73914400,"html_url":"https://github.com/tempesta-tech/tempesta/pull/558","diff_url":"https://github.com/tempesta-tech/tempesta/pull/558.diff","patch_url":"https://github.com/tempesta-tech/tempesta/pull/558.patch","issue_url":"https://api.github.com/repos/tempesta-tech/tempesta/issues/558","number":558,"state":"open","locked":false,"title":"Implement manual cache purging using HTTP PURGE method. (#501)","user":{"login":"keshonok","id":6352580,"avatar_url":"https://avatars.githubusercontent.com/u/6352580?v=3","gravatar_id":"","url":"https://api.github.com/users/keshonok","html_url":"https://github.com/keshonok","followers_url":"https://api.github.com/users/keshonok/followers","following_url":"https://api.github.com/users/keshonok/following{/other_user}","gists_url":"https://api.github.com/users/keshonok/gists{/gist_id}","starred_url":"https://api.github.com/users/keshonok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keshonok/subscriptions","organizations_url":"https://api.github.com/users/keshonok/orgs","repos_url":"https://api.github.com/users/keshonok/repos","events_url":"https://api.github.com/users/keshonok/events{/privacy}","received_events_url":"https://api.github.com/users/keshonok/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-06-15T13:47:55Z","updated_at":"2016-06-16T18:31:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"87a907264844870dcc50f7d232330f598bb16f14","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tempesta-tech/tempesta/pulls/558/commits","review_comments_url":"https://api.github.com/repos/tempesta-tech/tempesta/pulls/558/comments","review_comment_url":"https://api.github.com/repos/tempesta-tech/tempesta/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tempesta-tech/tempesta/issues/558/comments","statuses_url":"https://api.github.com/repos/tempesta-tech/tempesta/statuses/55268c0c0cc5ca9053121dd0a7065558234a2951","head":{"label":"tempesta-tech:ab-cache-purge","ref":"ab-cache-purge","sha":"55268c0c0cc5ca9053121dd0a7065558234a2951","user":{"login":"tempesta-tech","id":10939672,"avatar_url":"https://avatars.githubusercontent.com/u/10939672?v=3","gravatar_id":"","url":"https://api.github.com/users/tempesta-tech","html_url":"https://github.com/tempesta-tech","followers_url":"https://api.github.com/users/tempesta-tech/followers","following_url":"https://api.github.com/users/tempesta-tech/following{/other_user}","gists_url":"https://api.github.com/users/tempesta-tech/gists{/gist_id}","starred_url":"https://api.github.com/users/tempesta-tech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tempesta-tech/subscriptions","organizations_url":"https://api.github.com/users/tempesta-tech/orgs","repos_url":"https://api.github.com/users/tempesta-tech/repos","events_url":"https://api.github.com/users/tempesta-tech/events{/privacy}","received_events_url":"https://api.github.com/users/tempesta-tech/received_events","type":"Organization","site_admin":false},"repo":{"id":23121600,"name":"tempesta","full_name":"tempesta-tech/tempesta","owner":{"login":"tempesta-tech","id":10939672,"avatar_url":"https://avatars.githubusercontent.com/u/10939672?v=3","gravatar_id":"","url":"https://api.github.com/users/tempesta-tech","html_url":"https://github.com/tempesta-tech","followers_url":"https://api.github.com/users/tempesta-tech/followers","following_url":"https://api.github.com/users/tempesta-tech/following{/other_user}","gists_url":"https://api.github.com/users/tempesta-tech/gists{/gist_id}","starred_url":"https://api.github.com/users/tempesta-tech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tempesta-tech/subscriptions","organizations_url":"https://api.github.com/users/tempesta-tech/orgs","repos_url":"https://api.github.com/users/tempesta-tech/repos","events_url":"https://api.github.com/users/tempesta-tech/events{/privacy}","received_events_url":"https://api.github.com/users/tempesta-tech/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tempesta-tech/tempesta","description":"High performance HTTP accelerator and firewall for WAF and DDoS prevention","fork":false,"url":"https://api.github.com/repos/tempesta-tech/tempesta","forks_url":"https://api.github.com/repos/tempesta-tech/tempesta/forks","keys_url":"https://api.github.com/repos/tempesta-tech/tempesta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tempesta-tech/tempesta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tempesta-tech/tempesta/teams","hooks_url":"https://api.github.com/repos/tempesta-tech/tempesta/hooks","issue_events_url":"https://api.github.com/repos/tempesta-tech/tempesta/issues/events{/number}","events_url":"https://api.github.com/repos/tempesta-tech/tempesta/events","assignees_url":"https://api.github.com/repos/tempesta-tech/tempesta/assignees{/user}","branches_url":"https://api.github.com/repos/tempesta-tech/tempesta/branches{/branch}","tags_url":"https://api.github.com/repos/tempesta-tech/tempesta/tags","blobs_url":"https://api.github.com/repos/tempesta-tech/tempesta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tempesta-tech/tempesta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tempesta-tech/tempesta/git/refs{/sha}","trees_url":"https://api.github.com/repos/tempesta-tech/tempesta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tempesta-tech/tempesta/statuses/{sha}","languages_url":"https://api.github.com/repos/tempesta-tech/tempesta/languages","stargazers_url":"https://api.github.com/repos/tempesta-tech/tempesta/stargazers","contributors_url":"https://api.github.com/repos/tempesta-tech/tempesta/contributors","subscribers_url":"https://api.github.com/repos/tempesta-tech/tempesta/subscribers","subscription_url":"https://api.github.com/repos/tempesta-tech/tempesta/subscription","commits_url":"https://api.github.com/repos/tempesta-tech/tempesta/commits{/sha}","git_commits_url":"https://api.github.com/repos/tempesta-tech/tempesta/git/commits{/sha}","comments_url":"https://api.github.com/repos/tempesta-tech/tempesta/comments{/number}","issue_comment_url":"https://api.github.com/repos/tempesta-tech/tempesta/issues/comments{/number}","contents_url":"https://api.github.com/repos/tempesta-tech/tempesta/contents/{+path}","compare_url":"https://api.github.com/repos/tempesta-tech/tempesta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tempesta-tech/tempesta/merges","archive_url":"https://api.github.com/repos/tempesta-tech/tempesta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tempesta-tech/tempesta/downloads","issues_url":"https://api.github.com/repos/tempesta-tech/tempesta/issues{/number}","pulls_url":"https://api.github.com/repos/tempesta-tech/tempesta/pulls{/number}","milestones_url":"https://api.github.com/repos/tempesta-tech/tempesta/milestones{/number}","notifications_url":"https://api.github.com/repos/tempesta-tech/tempesta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tempesta-tech/tempesta/labels{/name}","releases_url":"https://api.github.com/repos/tempesta-tech/tempesta/releases{/id}","deployments_url":"https://api.github.com/repos/tempesta-tech/tempesta/deployments","created_at":"2014-08-19T18:44:05Z","updated_at":"2016-06-02T17:30:57Z","pushed_at":"2016-06-16T16:09:51Z","git_url":"git://github.com/tempesta-tech/tempesta.git","ssh_url":"git@github.com:tempesta-tech/tempesta.git","clone_url":"https://github.com/tempesta-tech/tempesta.git","svn_url":"https://github.com/tempesta-tech/tempesta","homepage":"","size":6779,"stargazers_count":110,"watchers_count":110,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":102,"forks":24,"open_issues":102,"watchers":110,"default_branch":"master"}},"base":{"label":"tempesta-tech:master","ref":"master","sha":"cd11f7ac2d07048d81d2adf8776a1f15c2e0e478","user":{"login":"tempesta-tech","id":10939672,"avatar_url":"https://avatars.githubusercontent.com/u/10939672?v=3","gravatar_id":"","url":"https://api.github.com/users/tempesta-tech","html_url":"https://github.com/tempesta-tech","followers_url":"https://api.github.com/users/tempesta-tech/followers","following_url":"https://api.github.com/users/tempesta-tech/following{/other_user}","gists_url":"https://api.github.com/users/tempesta-tech/gists{/gist_id}","starred_url":"https://api.github.com/users/tempesta-tech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tempesta-tech/subscriptions","organizations_url":"https://api.github.com/users/tempesta-tech/orgs","repos_url":"https://api.github.com/users/tempesta-tech/repos","events_url":"https://api.github.com/users/tempesta-tech/events{/privacy}","received_events_url":"https://api.github.com/users/tempesta-tech/received_events","type":"Organization","site_admin":false},"repo":{"id":23121600,"name":"tempesta","full_name":"tempesta-tech/tempesta","owner":{"login":"tempesta-tech","id":10939672,"avatar_url":"https://avatars.githubusercontent.com/u/10939672?v=3","gravatar_id":"","url":"https://api.github.com/users/tempesta-tech","html_url":"https://github.com/tempesta-tech","followers_url":"https://api.github.com/users/tempesta-tech/followers","following_url":"https://api.github.com/users/tempesta-tech/following{/other_user}","gists_url":"https://api.github.com/users/tempesta-tech/gists{/gist_id}","starred_url":"https://api.github.com/users/tempesta-tech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tempesta-tech/subscriptions","organizations_url":"https://api.github.com/users/tempesta-tech/orgs","repos_url":"https://api.github.com/users/tempesta-tech/repos","events_url":"https://api.github.com/users/tempesta-tech/events{/privacy}","received_events_url":"https://api.github.com/users/tempesta-tech/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tempesta-tech/tempesta","description":"High performance HTTP accelerator and firewall for WAF and DDoS prevention","fork":false,"url":"https://api.github.com/repos/tempesta-tech/tempesta","forks_url":"https://api.github.com/repos/tempesta-tech/tempesta/forks","keys_url":"https://api.github.com/repos/tempesta-tech/tempesta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tempesta-tech/tempesta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tempesta-tech/tempesta/teams","hooks_url":"https://api.github.com/repos/tempesta-tech/tempesta/hooks","issue_events_url":"https://api.github.com/repos/tempesta-tech/tempesta/issues/events{/number}","events_url":"https://api.github.com/repos/tempesta-tech/tempesta/events","assignees_url":"https://api.github.com/repos/tempesta-tech/tempesta/assignees{/user}","branches_url":"https://api.github.com/repos/tempesta-tech/tempesta/branches{/branch}","tags_url":"https://api.github.com/repos/tempesta-tech/tempesta/tags","blobs_url":"https://api.github.com/repos/tempesta-tech/tempesta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tempesta-tech/tempesta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tempesta-tech/tempesta/git/refs{/sha}","trees_url":"https://api.github.com/repos/tempesta-tech/tempesta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tempesta-tech/tempesta/statuses/{sha}","languages_url":"https://api.github.com/repos/tempesta-tech/tempesta/languages","stargazers_url":"https://api.github.com/repos/tempesta-tech/tempesta/stargazers","contributors_url":"https://api.github.com/repos/tempesta-tech/tempesta/contributors","subscribers_url":"https://api.github.com/repos/tempesta-tech/tempesta/subscribers","subscription_url":"https://api.github.com/repos/tempesta-tech/tempesta/subscription","commits_url":"https://api.github.com/repos/tempesta-tech/tempesta/commits{/sha}","git_commits_url":"https://api.github.com/repos/tempesta-tech/tempesta/git/commits{/sha}","comments_url":"https://api.github.com/repos/tempesta-tech/tempesta/comments{/number}","issue_comment_url":"https://api.github.com/repos/tempesta-tech/tempesta/issues/comments{/number}","contents_url":"https://api.github.com/repos/tempesta-tech/tempesta/contents/{+path}","compare_url":"https://api.github.com/repos/tempesta-tech/tempesta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tempesta-tech/tempesta/merges","archive_url":"https://api.github.com/repos/tempesta-tech/tempesta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tempesta-tech/tempesta/downloads","issues_url":"https://api.github.com/repos/tempesta-tech/tempesta/issues{/number}","pulls_url":"https://api.github.com/repos/tempesta-tech/tempesta/pulls{/number}","milestones_url":"https://api.github.com/repos/tempesta-tech/tempesta/milestones{/number}","notifications_url":"https://api.github.com/repos/tempesta-tech/tempesta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tempesta-tech/tempesta/labels{/name}","releases_url":"https://api.github.com/repos/tempesta-tech/tempesta/releases{/id}","deployments_url":"https://api.github.com/repos/tempesta-tech/tempesta/deployments","created_at":"2014-08-19T18:44:05Z","updated_at":"2016-06-02T17:30:57Z","pushed_at":"2016-06-16T16:09:51Z","git_url":"git://github.com/tempesta-tech/tempesta.git","ssh_url":"git@github.com:tempesta-tech/tempesta.git","clone_url":"https://github.com/tempesta-tech/tempesta.git","svn_url":"https://github.com/tempesta-tech/tempesta","homepage":"","size":6779,"stargazers_count":110,"watchers_count":110,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":102,"forks":24,"open_issues":102,"watchers":110,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tempesta-tech/tempesta/pulls/558"},"html":{"href":"https://github.com/tempesta-tech/tempesta/pull/558"},"issue":{"href":"https://api.github.com/repos/tempesta-tech/tempesta/issues/558"},"comments":{"href":"https://api.github.com/repos/tempesta-tech/tempesta/issues/558/comments"},"review_comments":{"href":"https://api.github.com/repos/tempesta-tech/tempesta/pulls/558/comments"},"review_comment":{"href":"https://api.github.com/repos/tempesta-tech/tempesta/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tempesta-tech/tempesta/pulls/558/commits"},"statuses":{"href":"https://api.github.com/repos/tempesta-tech/tempesta/statuses/55268c0c0cc5ca9053121dd0a7065558234a2951"}}}}
{"actor":{"display_login":"krizhanovsky"}}