| 822 | #define MAX_IP_STR_LEN (46) |
| 823 | |
| 824 | PROXY_DECLARE(int) ap_proxy_checkproxyblock2(request_rec *r, proxy_server_conf *conf, |
| 825 | const char *hostname, apr_sockaddr_t *addr) |
| 826 | { |
| 827 | int j; |
| 828 | |
| 829 | /* XXX FIXME: conf->noproxies->elts is part of an opaque structure */ |
| 830 | for (j = 0; j < conf->noproxies->nelts; j++) { |
| 831 | struct noproxy_entry *npent = (struct noproxy_entry *) conf->noproxies->elts; |
| 832 | struct apr_sockaddr_t *conf_addr; |
| 833 | |
| 834 | ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r, |
| 835 | "checking remote machine [%s] against [%s]", |
| 836 | hostname, npent[j].name); |
| 837 | if (ap_strstr_c(hostname, npent[j].name) || npent[j].name[0] == '*') { |
| 838 | ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(00916) |
| 839 | "connect to remote machine %s blocked: name %s " |
| 840 | "matched", hostname, npent[j].name); |
| 841 | return HTTP_FORBIDDEN; |
| 842 | } |
| 843 | |
| 844 | /* No IP address checks if no IP address was passed in, |
| 845 | * i.e. the forward address proxy case, where this server does |
| 846 | * not resolve the hostname. */ |
| 847 | if (!addr) |
| 848 | continue; |
| 849 | |
| 850 | for (conf_addr = npent[j].addr; conf_addr; conf_addr = conf_addr->next) { |
| 851 | char caddr[MAX_IP_STR_LEN], uaddr[MAX_IP_STR_LEN]; |
| 852 | apr_sockaddr_t *uri_addr; |
| 853 | |
| 854 | if (apr_sockaddr_ip_getbuf(caddr, sizeof caddr, conf_addr)) |
| 855 | continue; |
| 856 | |
| 857 | for (uri_addr = addr; uri_addr; uri_addr = uri_addr->next) { |
| 858 | if (apr_sockaddr_ip_getbuf(uaddr, sizeof uaddr, uri_addr)) |
| 859 | continue; |
| 860 | ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r, |
| 861 | "ProxyBlock comparing %s and %s", caddr, uaddr); |
| 862 | if (!strcmp(caddr, uaddr)) { |
| 863 | ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(00917) |
| 864 | "connect to remote machine %s blocked: " |
| 865 | "IP %s matched", hostname, caddr); |
| 866 | return HTTP_FORBIDDEN; |
| 867 | } |
| 868 | } |
| 869 | } |
| 870 | } |
| 871 | |
| 872 | return OK; |
| 873 | } |
| 874 | |
| 875 | /* set up the minimal filter set */ |
| 876 | PROXY_DECLARE(int) ap_proxy_pre_http_request(conn_rec *c, request_rec *r) |
no test coverage detected