Author: poeml Date: Fri Nov 5 20:20:00 2010 New Revision: 8197 URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=8197&view=rev Log: mod_mirrorbrain: - When running behind a proxy, prefix detection (for containment in network prefixes of mirrors) did not work because mod_mirrorbrain only saw the connecting IP address, and didn't look at an address passed via HTTP headers from the proxy. This is fixed. (AS, country and continent comparisons already did this.) Modified: trunk/mod_mirrorbrain/mod_mirrorbrain.c Modified: trunk/mod_mirrorbrain/mod_mirrorbrain.c URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mod_mirrorbrain/mod_mirrorbrain.c?rev=8197&r1=8196&r2=8197&view=diff ============================================================================== --- trunk/mod_mirrorbrain/mod_mirrorbrain.c (original) +++ trunk/mod_mirrorbrain/mod_mirrorbrain.c Fri Nov 5 20:20:00 2010 _at_@ -1152,6 +1152,7 @@ char *filename = NULL; char *realfile = NULL; const char *clientip = NULL; + apr_sockaddr_t *clientaddr; const char *query_country = NULL; char *query_asn = NULL; char fakefile = 0, newmirror = 0, only_hash = 0; _at_@ -1238,7 +1239,6 @@ form_lookup = APR_RETRIEVE_OPTIONAL_FN(form_value); if (form_lookup && r->args) { if (form_lookup(r, "fakefile")) fakefile = 1; - clientip = form_lookup(r, "clientip"); query_country = form_lookup(r, "country"); query_asn = (char *) form_lookup(r, "as"); if (form_lookup(r, "newmirror")) newmirror = 1; _at_@ -1286,22 +1286,15 @@ } } - if (clientip) { - debugLog(r, cfg, "obsolete clientip address parameter: '%s'", clientip); - ap_set_content_type(r, "text/html; charset=UTF-8"); - ap_rputs(DOCTYPE_XHTML_1_0T - "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" - "<head>\n" - " <title>Sorry</title>\n", r); - ap_rputs("</head>\n<body>\n\n", r); - ap_rprintf(r, "<p>\n<kbd>clientip</kbd> is no longer supported as query parameter. " - "Please use <kbd>country=xy</kbd> instead, where <kbd>xy</kbd> is a two-letter " - "<a href=\"http://en.wikipedia.org/wiki/ISO_3166-1\">" - "ISO 3166 country code</a>.\n</p>\n"); - ap_rputs("\n\n</body>\n</html>\n", r); - return OK; - } else - clientip = apr_pstrdup(r->pool, r->connection->remote_ip); + /* We might be running as a backend which sees client IPs only through HTTP + * headers */ + clientip = apr_table_get(r->subprocess_env, "GEOIP_ADDR"); + rv = apr_sockaddr_info_get(&clientaddr, clientip, APR_UNSPEC, 0, 0, r->pool); + if(APR_STATUS_IS_EINVAL(rv) || (rv != APR_SUCCESS)) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "[mod_mirrorbrain] " + "Error in parsing GEOIP_ADDR value '%s'", clientip); + } + debugLog(r, cfg, "clientip: %s", clientip); /* These checks apply only if the server response is not faked for testing */ if (fakefile) { _at_@ -1899,8 +1892,9 @@ /* same prefix? */ else if (new->ipsub - && apr_ipsubnet_test(new->ipsub, r->connection->remote_addr)) { + && apr_ipsubnet_test(new->ipsub, clientaddr)) { *(void **)apr_array_push(mirrors_same_prefix) = new; + debugLog(r, cfg, "Mirror '%s' in same prefix (%s)", new->identifier, new->prefix); } /* same AS? */ _______________________________________________ mirrorbrain-commits mailing list Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/ Note: To remove yourself from this list, send a mail with the content unsubscribe to the address mirrorbrain-commits-request_at_mirrorbrain.orgReceived on Fri Nov 05 2010 - 19:20:02 GMT
This archive was generated by hypermail 2.3.0 : Mon Feb 20 2012 - 23:47:04 GMT