Return TRUE if host represents a host name */
| 734 | |
| 735 | /* Return TRUE if host represents a host name */ |
| 736 | PROXY_DECLARE(int) ap_proxy_is_hostname(struct dirconn_entry *This, apr_pool_t *p) |
| 737 | { |
| 738 | struct apr_sockaddr_t *addr; |
| 739 | char *host = This->name; |
| 740 | int i; |
| 741 | |
| 742 | /* Host names must not start with a '.' */ |
| 743 | if (host[0] == '.') { |
| 744 | return 0; |
| 745 | } |
| 746 | /* rfc1035 says DNS names must consist of "[-a-zA-Z0-9]" and '.' */ |
| 747 | for (i = 0; apr_isalnum(host[i]) || host[i] == '-' || host[i] == '.'; ++i); |
| 748 | |
| 749 | if (host[i] != '\0' || apr_sockaddr_info_get(&addr, host, APR_UNSPEC, 0, 0, p) != APR_SUCCESS) { |
| 750 | return 0; |
| 751 | } |
| 752 | |
| 753 | This->hostaddr = addr; |
| 754 | |
| 755 | /* Strip trailing dots */ |
| 756 | for (i = strlen(host) - 1; i > 0 && host[i] == '.'; --i) { |
| 757 | host[i] = '\0'; |
| 758 | } |
| 759 | |
| 760 | This->matcher = proxy_match_hostname; |
| 761 | return 1; |
| 762 | } |
| 763 | |
| 764 | /* Return TRUE if host "host" is equal to host2 "host2" */ |
| 765 | static int proxy_match_hostname(struct dirconn_entry *This, request_rec *r) |