[cvslog] (2003-04-09 02:01:24 UTC) Module eggdrop1.7: Change committed

cvslog cvs at tsss.org
Tue Apr 8 20:01:24 CST 2003


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.7
Commit time: 2003-04-09 02:01:24 UTC
Commited by: stdarg <stdarg at techmonkeys.org>

Modified files:
     lib/eggdrop/eggdns.c lib/eggdrop/my_socket.c
     lib/eggdrop/my_socket.h src/telnet.c

Log message:

* Support for ipv6 reverse dns

---------------------- diff included ----------------------
Index: eggdrop1.7/lib/eggdrop/eggdns.c
diff -u eggdrop1.7/lib/eggdrop/eggdns.c:1.3 eggdrop1.7/lib/eggdrop/eggdns.c:1.4
--- eggdrop1.7/lib/eggdrop/eggdns.c:1.3	Sun Feb  2 19:01:07 2003
+++ eggdrop1.7/lib/eggdrop/eggdns.c	Tue Apr  8 21:01:13 2003
@@ -305,7 +305,7 @@
 
 static int dns_make_query(const char *host, int type, char **buf, int *query_len, int (*callback)(), void *client_data)
 {
-	char *newhost = NULL;
+	char *newhost;
 	int len = 0;
 	int ns_type = 0;
 	int i;
@@ -324,10 +324,19 @@
 
 		/* We need to transform the ip address into the proper form
 		 * for reverse lookup. */
-		newhost = (char *)malloc(strlen(host) + 14);
-		reverse_ip(host, newhost);
-		strcat(newhost, ".in-addr.arpa");
-		host = newhost;
+		if (strchr(host, ':')) {
+			char temp[65];
+
+			socket_ipv6_to_dots(host, temp);
+			newhost = malloc(strlen(temp) + 10);
+			reverse_ip(temp, newhost);
+			strcat(newhost, ".in6.arpa");
+		}
+		else {
+			newhost = (char *)malloc(strlen(host) + 14);
+			reverse_ip(host, newhost);
+			strcat(newhost, ".in-addr.arpa");
+		}
 		ns_type = 12; /* PTR (reverse lookup) */
 	}
 	else {
@@ -341,15 +350,17 @@
 		if (type == DNS_IPV4) ns_type = 1; /* IPv4 */
 		else if (type == DNS_IPV6) ns_type = 28; /* IPv6 */
 		else return(-1);
+		newhost = host;
 	}
 
-	*buf = (char *)malloc(strlen(host) + 512);
+	*buf = (char *)malloc(strlen(newhost) + 512);
 	len = make_header(*buf, query_id);
-	len += cut_host(host, *buf + len);
+	len += cut_host(newhost, *buf + len);
 	(*buf)[len] = 0; len++; (*buf)[len] = ns_type; len++;
 	(*buf)[len] = 0; len++; (*buf)[len] = 1; len++;
-	if (newhost) free(newhost);
 	*query_len = len;
+
+	if (newhost != host) free(newhost);
 
 	q = calloc(1, sizeof(*q));
 	q->id = query_id;
Index: eggdrop1.7/lib/eggdrop/my_socket.c
diff -u eggdrop1.7/lib/eggdrop/my_socket.c:1.5 eggdrop1.7/lib/eggdrop/my_socket.c:1.6
--- eggdrop1.7/lib/eggdrop/my_socket.c:1.5	Tue Feb 25 04:28:21 2003
+++ eggdrop1.7/lib/eggdrop/my_socket.c	Tue Apr  8 21:01:13 2003
@@ -267,3 +267,28 @@
 	*longip = htonl(addr.s_addr);
 	return(0);
 }
+
+/* Converts shorthand ipv6 notation (123:456::789) into long dotted-decimal
+ * notation. 'dots' must be 16*4+1 = 65 bytes long. */
+int socket_ipv6_to_dots(const char *ip, char *dots)
+{
+#ifndef DO_IPV6
+	dots[0] = 0;
+	return(-1);
+#else
+	struct in6_addr buf;
+
+	dots[0] = 0;
+	if (inet_pton(AF_INET6, ip, &buf) <= 0) return(-1);
+	sprintf(dots, "%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u.%u",
+		buf.in6_u.u6_addr8[0], buf.in6_u.u6_addr8[1],
+		buf.in6_u.u6_addr8[2], buf.in6_u.u6_addr8[3],
+		buf.in6_u.u6_addr8[4], buf.in6_u.u6_addr8[5],
+		buf.in6_u.u6_addr8[6], buf.in6_u.u6_addr8[7],
+		buf.in6_u.u6_addr8[8], buf.in6_u.u6_addr8[9],
+		buf.in6_u.u6_addr8[10], buf.in6_u.u6_addr8[11],
+		buf.in6_u.u6_addr8[12], buf.in6_u.u6_addr8[13],
+		buf.in6_u.u6_addr8[14], buf.in6_u.u6_addr8[15]
+	);
+#endif
+}
Index: eggdrop1.7/lib/eggdrop/my_socket.h
diff -u eggdrop1.7/lib/eggdrop/my_socket.h:1.3 eggdrop1.7/lib/eggdrop/my_socket.h:1.4
--- eggdrop1.7/lib/eggdrop/my_socket.h:1.3	Tue Feb 25 04:28:21 2003
+++ eggdrop1.7/lib/eggdrop/my_socket.h	Tue Apr  8 21:01:13 2003
@@ -17,5 +17,6 @@
 int socket_accept(int sock, char **peer_ip, int *peer_port);
 int socket_valid_ip(const char *ip);
 int socket_ip_to_uint(const char *ip, unsigned int *longip);
+int socket_ipv6_to_dots(const char *ip, char *dots);
 
 #endif
Index: eggdrop1.7/src/telnet.c
diff -u eggdrop1.7/src/telnet.c:1.4 eggdrop1.7/src/telnet.c:1.5
--- eggdrop1.7/src/telnet.c:1.4	Mon Apr  7 02:20:11 2003
+++ eggdrop1.7/src/telnet.c	Tue Apr  8 21:01:14 2003
@@ -109,6 +109,7 @@
 	sockbuf_attach_filter(newidx, &telnet_filter, flags);
 	linemode_on(newidx);
 
+	egg_iprintf(newidx, "Hello %s/%d!\r\n", peer_ip, peer_port);
 	/* Stealth logins are where we don't say anything until we know they
 	 * are a valid user. */
 	if (core_config.telnet_stealth) {
----------------------- End of diff -----------------------


More information about the Changes mailing list