--- nginx-0.7.67-orig/src/mail/ngx_mail_auth_http_module.c	2010-08-16 18:17:52.000000000 +0200
+++ nginx-0.7.67/src/mail/ngx_mail_auth_http_module.c	2010-08-16 19:06:46.000000000 +0200
@@ -456,9 +456,9 @@
     u_char              *p;
     time_t               timer;
     size_t               len, size;
-    ngx_int_t            rc, port, n;
+    ngx_int_t            rc, n;
     ngx_peer_addr_t     *peer;
-    struct sockaddr_in  *sin;
+    ngx_url_t           u;
 
     ngx_log_debug0(NGX_LOG_DEBUG_MAIL, s->connection->log, 0,
                    "mail auth http process headers");
@@ -771,63 +771,43 @@
                 return;
             }
 
-            /* AF_INET only */
+	    ngx_memzero(&u, sizeof(ngx_url_t));
 
-            sin = ngx_pcalloc(s->connection->pool, sizeof(struct sockaddr_in));
-            if (sin == NULL) {
-                ngx_destroy_pool(ctx->pool);
-                ngx_mail_session_internal_server_error(s);
-                return;
-            }
-
-            sin->sin_family = AF_INET;
-
-            port = ngx_atoi(ctx->port.data, ctx->port.len);
-            if (port == NGX_ERROR || port < 1 || port > 65536) {
-                ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
-                              "auth http server %V sent invalid server "
-                              "port:\"%V\"",
-                              ctx->peer.name, &ctx->port);
-                ngx_destroy_pool(ctx->pool);
-                ngx_mail_session_internal_server_error(s);
-                return;
-            }
+	    u.url.len = ctx->addr.len;
+	    u.url.data = ngx_pcalloc(s->connection->pool, ctx->addr.len);
+	    if (u.url.data == NULL) {
+	      ngx_destroy_pool(ctx->pool);
+	      ngx_mail_session_internal_server_error(s);
+	      return;
+	    }
+
+            ngx_memcpy(u.url.data, ctx->addr.data, ctx->addr.len);
+
+	    u.listen = 1;
+
+	    if (ngx_parse_url(s->connection->pool, &u) != NGX_OK) {
+	      if (u.err) {
+		ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
+				   "auth http server %V sent invalid \"listen\" url: %V",
+			      ctx->peer.name, &u.url);
+	      }
+	      ngx_mail_session_internal_server_error(s);
+	      return;
+	    }
 
-            sin->sin_port = htons((in_port_t) port);
+            peer->sockaddr = (struct sockaddr *)u.sockaddr;
+            peer->socklen = u.socklen;
 
-            ctx->addr.data[ctx->addr.len] = '\0';
-            sin->sin_addr.s_addr = inet_addr((char *) ctx->addr.data);
-            if (sin->sin_addr.s_addr == INADDR_NONE) {
-                ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
-                              "auth http server %V sent invalid server "
-                              "address:\"%V\"",
-                              ctx->peer.name, &ctx->addr);
-                ngx_destroy_pool(ctx->pool);
-                ngx_mail_session_internal_server_error(s);
-                return;
-            }
-
-            peer->sockaddr = (struct sockaddr *) sin;
-            peer->socklen = sizeof(struct sockaddr_in);
+            peer->name.len = u.url.len;
 
-            len = ctx->addr.len + 1 + ctx->port.len;
-
-            peer->name.len = len;
-
-            peer->name.data = ngx_pnalloc(s->connection->pool, len);
+            peer->name.data = ngx_pnalloc(s->connection->pool, peer->name.len);
             if (peer->name.data == NULL) {
                 ngx_destroy_pool(ctx->pool);
                 ngx_mail_session_internal_server_error(s);
                 return;
             }
 
-            len = ctx->addr.len;
-
-            ngx_memcpy(peer->name.data, ctx->addr.data, len);
-
-            peer->name.data[len++] = ':';
-
-            ngx_memcpy(peer->name.data + len, ctx->port.data, ctx->port.len);
+            ngx_memcpy(peer->name.data, u.url.data, peer->name.len);
 
             ngx_destroy_pool(ctx->pool);
             ngx_mail_proxy_init(s, peer);
