diff options
-rw-r--r-- | source3/include/proto.h | 1 | ||||
-rw-r--r-- | source3/lib/util_sock.c | 79 |
2 files changed, 0 insertions, 80 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 4477246fbb..13b1350624 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -619,7 +619,6 @@ struct tevent_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx, int timeout); NTSTATUS open_socket_out_defer_recv(struct tevent_req *req, int *pfd); int open_udp_socket(const char *host, int port); -const char *get_peer_name(int fd, bool force_lookup); const char *get_peer_addr(int fd, char *addr, size_t addr_len); struct tsocket_address; diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 509e7b7d3a..a35ae97eba 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -1023,85 +1023,6 @@ static void store_nc(const struct name_addr_pair *nc) } /******************************************************************* - Return the DNS name of the remote end of a socket. -******************************************************************/ - -const char *get_peer_name(int fd, bool force_lookup) -{ - struct name_addr_pair nc; - char addr_buf[INET6_ADDRSTRLEN]; - struct sockaddr_storage ss; - socklen_t length = sizeof(ss); - const char *p; - int ret; - char name_buf[MAX_DNS_NAME_LENGTH]; - char tmp_name[MAX_DNS_NAME_LENGTH]; - - /* reverse lookups can be *very* expensive, and in many - situations won't work because many networks don't link dhcp - with dns. To avoid the delay we avoid the lookup if - possible */ - if (!lp_hostname_lookups() && (force_lookup == false)) { - length = sizeof(nc.ss); - nc.name = get_peer_addr_internal(fd, addr_buf, sizeof(addr_buf), - (struct sockaddr *)&nc.ss, &length); - store_nc(&nc); - lookup_nc(&nc); - return nc.name ? nc.name : "UNKNOWN"; - } - - lookup_nc(&nc); - - memset(&ss, '\0', sizeof(ss)); - p = get_peer_addr_internal(fd, addr_buf, sizeof(addr_buf), (struct sockaddr *)&ss, &length); - - /* it might be the same as the last one - save some DNS work */ - if (sockaddr_equal((struct sockaddr *)&ss, (struct sockaddr *)&nc.ss)) { - return nc.name ? nc.name : "UNKNOWN"; - } - - /* Not the same. We need to lookup. */ - if (fd == -1) { - return "UNKNOWN"; - } - - /* Look up the remote host name. */ - ret = sys_getnameinfo((struct sockaddr *)&ss, - length, - name_buf, - sizeof(name_buf), - NULL, - 0, - 0); - - if (ret) { - DEBUG(1,("get_peer_name: getnameinfo failed " - "for %s with error %s\n", - p, - gai_strerror(ret))); - strlcpy(name_buf, p, sizeof(name_buf)); - } else { - if (!matchname(name_buf, (struct sockaddr *)&ss, length)) { - DEBUG(0,("Matchname failed on %s %s\n",name_buf,p)); - strlcpy(name_buf,"UNKNOWN",sizeof(name_buf)); - } - } - - strlcpy(tmp_name, name_buf, sizeof(tmp_name)); - alpha_strcpy(name_buf, tmp_name, "_-.", sizeof(name_buf)); - if (strstr(name_buf,"..")) { - strlcpy(name_buf, "UNKNOWN", sizeof(name_buf)); - } - - nc.name = name_buf; - nc.ss = ss; - - store_nc(&nc); - lookup_nc(&nc); - return nc.name ? nc.name : "UNKNOWN"; -} - -/******************************************************************* Return the IP addr of the remote end of a socket as a string. ******************************************************************/ |