| 955 | } |
| 956 | |
| 957 | AP_DECLARE(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config, |
| 958 | int type, int *str_is_ip) |
| 959 | { |
| 960 | int hostname_lookups; |
| 961 | int ignored_str_is_ip; |
| 962 | |
| 963 | if (!str_is_ip) { /* caller doesn't want to know */ |
| 964 | str_is_ip = &ignored_str_is_ip; |
| 965 | } |
| 966 | *str_is_ip = 0; |
| 967 | |
| 968 | /* If we haven't checked the host name, and we want to */ |
| 969 | if (dir_config) { |
| 970 | hostname_lookups = ((core_dir_config *)ap_get_core_module_config(dir_config)) |
| 971 | ->hostname_lookups; |
| 972 | |
| 973 | if (hostname_lookups == HOSTNAME_LOOKUP_UNSET) { |
| 974 | hostname_lookups = HOSTNAME_LOOKUP_OFF; |
| 975 | } |
| 976 | } |
| 977 | else { |
| 978 | /* the default */ |
| 979 | hostname_lookups = HOSTNAME_LOOKUP_OFF; |
| 980 | } |
| 981 | |
| 982 | if (type != REMOTE_NOLOOKUP |
| 983 | && conn->remote_host == NULL |
| 984 | && (type == REMOTE_DOUBLE_REV |
| 985 | || hostname_lookups != HOSTNAME_LOOKUP_OFF)) { |
| 986 | |
| 987 | if (apr_getnameinfo(&conn->remote_host, conn->client_addr, 0) |
| 988 | == APR_SUCCESS) { |
| 989 | ap_str_tolower(conn->remote_host); |
| 990 | |
| 991 | if (hostname_lookups == HOSTNAME_LOOKUP_DOUBLE) { |
| 992 | conn->double_reverse = do_double_reverse(conn->double_reverse, |
| 993 | conn->remote_host, |
| 994 | conn->client_addr, |
| 995 | conn->pool); |
| 996 | if (conn->double_reverse != 1) { |
| 997 | conn->remote_host = NULL; |
| 998 | } |
| 999 | } |
| 1000 | } |
| 1001 | |
| 1002 | /* if failed, set it to the NULL string to indicate error */ |
| 1003 | if (conn->remote_host == NULL) { |
| 1004 | conn->remote_host = ""; |
| 1005 | } |
| 1006 | } |
| 1007 | |
| 1008 | if (type == REMOTE_DOUBLE_REV) { |
| 1009 | conn->double_reverse = do_double_reverse(conn->double_reverse, |
| 1010 | conn->remote_host, |
| 1011 | conn->client_addr, conn->pool); |
| 1012 | if (conn->double_reverse == -1) { |
| 1013 | return NULL; |
| 1014 | } |
no test coverage detected