diff -N -r -u oer+MySQL-dist/misc.c oer+MySQL-dist-ipv6/misc.c
--- oer+MySQL-dist/misc.c	2002-11-12 22:44:10.000000000 +0200
+++ oer+MySQL-dist-ipv6/misc.c	2002-12-22 15:28:44.000000000 +0200
@@ -758,26 +758,32 @@
         int c2;
         char *ptr;
 
-	/* we require at least X.Y */
-	if(strlen(line) < 3) {
-		return 0;
-	}
-	/* we require a domain and a TLD */
-        if((ptr = index(line, '.')) == NULL) {
+        /* we require at least X.Y or ::1 */
+        if(strlen(line) < 3) {
                 return 0;
         }
-	/* the domain and TLD separator can't be the
-	   first nor the last character */
-        if(ptr == line || ptr == (line + (strlen(line) - 1))) {
+        /* we require either an ipv4-address, a domain and a TLD, or an ipv6-address */
+        if((ptr = index(line, '.')) == NULL && (ptr = index(line, ':')) == NULL) {
                 return 0;
         }
-        c = *(ptr - 1);
-        c2 = *(ptr + 1);
-	/* we want both X and Y to be printable */
-        if(!isgraph(c) || !isgraph(c2)) {
-		return 0;
-	}
-	return 1;
+
+		/* don't do any further tests for ipv6-addresses for now */
+		if((ptr = index(line, ':')) == NULL) {
+			ptr = index(line, '.');
+			/* the domain and TLD separator can't be the
+			   first nor the last character */
+			if(ptr == line || ptr == (line + (strlen(line) - 1))) {
+                return 0;
+			}
+
+			c = *(ptr - 1);
+			c2 = *(ptr + 1);
+			/* we want both X and Y to be printable */
+			if(!isgraph(c) || !isgraph(c2)) {
+                return 0;
+			}
+		}
+        return 1;
 }
 
 int completeban(char *from, char *to, int tlength)
diff -N -r -u oer+MySQL-dist/network.c oer+MySQL-dist-ipv6/network.c
--- oer+MySQL-dist/network.c	2002-11-14 10:59:48.000000000 +0200
+++ oer+MySQL-dist-ipv6/network.c	2002-12-22 15:27:39.000000000 +0200
@@ -183,8 +183,9 @@
 
 int serverconnection()
 {
-	struct hostent *hptr;
-	struct sockaddr_in servaddr;
+	struct addrinfo hints, *addrinfo;
+	int ai_error;
+	char servport[6];
 #ifdef DEBUG
         oer_debug(OER_DEBUG_NOISE, "serverconnection()\n");
 #endif
@@ -194,45 +195,32 @@
 			return OER_SERVERCONNECTION_ALREADY_CONNECTED;
 		}
 	}
-	if((mystate->sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-		oer_debug(OER_DEBUG_ERROR, "serverconnection->socket() failed: %s\n", strerror(errno));
-		return OER_SERVERCONNECTION_ERR_SOCKET;
-	}
-	memset(&servaddr, 0, sizeof(struct sockaddr_in));
-	servaddr.sin_family = AF_INET;
-	servaddr.sin_addr.s_addr = INADDR_ANY;
 	/* get system hostname */
-        if(gethostname(mystate->host, HOSTLEN) < 0) {
-                oer_debug(OER_DEBUG_ERROR, "serverconnection->gethostname() failed: %s\n", strerror(errno));
-                close(mystate->sockfd);
-                return OER_SERVERCONNECTION_ERR_GETHOSTNAME;
-        }
-        if(strlen(mystate->vhost)) {
-                /* override with virtual host */
-                strncpy(mystate->host, mystate->vhost, HOSTLEN);
-        }
-	if((hptr = (struct hostent *) gethostbyname(mystate->host)) == NULL) {
-#ifndef _NO_H_ERRNO
-		oer_debug(OER_DEBUG_ERROR, "serverconnection->gethostbyname() for %s failed (h_errono = %d)\n", mystate->host, h_errno);
-		if(h_errno == TRY_AGAIN) {
-			oer_debug(OER_DEBUG_ERROR, "serverconnection->gethostbyname() non-fatal error\n");
-			close(mystate->sockfd);
+	if(gethostname(mystate->host, HOSTLEN) < 0) {
+		oer_debug(OER_DEBUG_ERROR, "serverconnection->gethostname() failed: %s\n", strerror(errno));
+		close(mystate->sockfd);
+		return OER_SERVERCONNECTION_ERR_GETHOSTNAME;
+	}
+	if(strlen(mystate->vhost)) {
+		/* override with virtual host */
+		strncpy(mystate->host, mystate->vhost, HOSTLEN);
+	}
+	if((ai_error = getaddrinfo(mystate->host, 0, 0, &addrinfo)) != 0) {
+		oer_debug(OER_DEBUG_ERROR, "serverconnection->getaddrinfo() for %s failed: %s\n", mystate->host, gai_strerror(ai_error));
+		if(ai_error == EAI_AGAIN) {
+			oer_debug(OER_DEBUG_ERROR, "serverconnection->getaddrinfo() non-fatal error\n");
 			return OER_SERVERCONNECTION_ERR_GETHOSTBYNAME_RETRY;
 		} else {
-			close(mystate->sockfd);
 			return OER_SERVERCONNECTION_ERR_GETHOSTBYNAME;
 		}
-#else
-		/* i'm feeling lucky, and lazy too :) */
-		oer_debug(OER_DEBUG_ERROR, "serverconnection->gethostbyname() unknown error\n");
-		close(mystate->sockfd);
-		return OER_SERVERCONNECTION_ERR_GETHOSTBYNAME_RETRY;
-#endif
 	}
-	memcpy((char *) &servaddr.sin_addr, hptr->h_addr, hptr->h_length);
+	if((mystate->sockfd = socket(addrinfo->ai_family, SOCK_STREAM, 0)) < 0) {
+		oer_debug(OER_DEBUG_ERROR, "serverconnection->socket() failed: %s\n", strerror(errno));
+		return OER_SERVERCONNECTION_ERR_SOCKET;
+	}
 	if(strlen(mystate->vhost)) {
 		/* bind is only necessary for vhost */
-		if(bind(mystate->sockfd, (struct sockaddr *) &servaddr, sizeof(struct sockaddr)) < 0) {
+		if(bind(mystate->sockfd, addrinfo->ai_addr, addrinfo->ai_addrlen) < 0) {
 			oer_debug(OER_DEBUG_ERROR, "serverconnection->bind() failed: %s (check your vhost setting)\n", strerror(errno));
 			close(mystate->sockfd);
 			return OER_SERVERCONNECTION_ERR_BIND;
@@ -245,32 +233,26 @@
 		close(mystate->sockfd);
 		return OER_SERVERCONNECTION_ERR_GETSERVER_RETRY;
 	}
-        memset(mystate->current_server->serverhost_r, 0, HOSTLEN + 1);
-	mystate->current_server->registerconnection_start = mystate->now;
+	memset(mystate->current_server->serverhost_r, 0, HOSTLEN + 1);
+        mystate->current_server->registerconnection_start = mystate->now;
 	mystate->current_server->used = 1;
 #ifdef DEBUG
 	oer_debug(OER_DEBUG_INFO, "serverconnection->using server %s port %d\n", mystate->current_server->serverhost, mystate->current_server->serverport);
 #endif
-	if((hptr = (struct hostent *) gethostbyname(mystate->current_server->serverhost)) == NULL) {
-#ifndef _NO_H_ERRNO
-		oer_debug(OER_DEBUG_ERROR, "serverconnection->gethostbyname() for %s failed (h_errno = %d)\n", mystate->current_server->serverhost, h_errno);
-		if(h_errno == NO_ADDRESS || h_errno == HOST_NOT_FOUND || h_errno == TRY_AGAIN) {
+	memset(&hints, 0, sizeof(hints));
+	hints.ai_socktype = SOCK_STREAM;
+	snprintf(servport, sizeof(servport), "%d", mystate->current_server->serverport);
+	if((ai_error = getaddrinfo(mystate->current_server->serverhost, servport, &hints, &addrinfo)) != 0) {
+		oer_debug(OER_DEBUG_ERROR, "serverconnection->getaddrinfo() for %s failed: %s\n", mystate->current_server->serverhost, gai_strerror(ai_error));
+		if(ai_error == EAI_NONAME || ai_error == EAI_NODATA || ai_error == EAI_AGAIN) {
 #ifdef DEBUG
 			oer_debug(OER_DEBUG_INFO, "serverconnection->switching to next server if available\n");
 #endif
 			close(mystate->sockfd);
 			return OER_SERVERCONNECTION_ERR_GETHOSTBYNAME_RETRY;
 		}
-#else
-		/* i'm feeling lucky, and lazy too :) */
-		oer_debug(OER_DEBUG_ERROR, "serverconnection->gethostbyname() unknown error\n");
-		close(mystate->sockfd);
-		return OER_SERVERCONNECTION_ERR_GETHOSTBYNAME_RETRY;
-#endif
-        }
-	memcpy(&servaddr.sin_addr, hptr->h_addr_list[0], sizeof(struct in_addr));
-	servaddr.sin_port = htons(mystate->current_server->serverport);
-	if(connect(mystate->sockfd, (struct sockaddr *) &servaddr, sizeof(struct sockaddr_in)) < 0) {
+	}
+	if(connect(mystate->sockfd, addrinfo->ai_addr, addrinfo->ai_addrlen) < 0) {
 		oer_debug(OER_DEBUG_ERROR, "serverconnection->connect() failed: %s (%d)\n", strerror(errno), errno);
 		if(errno == ECONNREFUSED || errno == ETIMEDOUT || errno == ENETUNREACH || errno == EHOSTUNREACH) {
 #ifdef DEBUG
@@ -283,11 +265,12 @@
 		close(mystate->sockfd);
 		return OER_SERVERCONNECTION_ERR_CONNECT;
 	}
+	freeaddrinfo(addrinfo);
 	proxysetup();
 	mystate->current_server->connected = 1;
+        mystate->current_server->rx = 0;
+        mystate->current_server->tx = 0;
 	mystate->current_server->linkup = mystate->now;
-	mystate->current_server->rx = 0;
-	mystate->current_server->tx = 0;
 	return OER_SERVERCONNECTION_EVERYTHING_OK;
 }
 

