Browse Source

- check_self matches TLS connections.

Jan Janak 22 years ago
parent
commit
3e4e785294
2 changed files with 22 additions and 9 deletions
  1. 18 9
      forward.c
  2. 4 0
      name_alias.h

+ 18 - 9
forward.c

@@ -233,27 +233,36 @@ int check_self(str* host, unsigned short port)
 					host->len, host->s,
 					sock_info[r].name.len, sock_info[r].name.s
 			);
-		if  ((port)&&(sock_info[r].port_no!=port)) continue;
+		if (port) {
+			DBG("check_self - checking if port %d matches port %d\n", sock_info[r].port_no, port);
+#ifdef USE_TLS
+			if  ((sock_info[r].port_no!=port) && (tls_info[r].port_no!=port)) {
+#else
+			if (sock_info[r].port_no!=port) {
+#endif
+				continue;
+			}
+		}
 		if ( (host->len==sock_info[r].name.len) && 
-	#ifdef USE_IPV6
+#ifdef USE_IPV6
 			(strncasecmp(host->s, sock_info[r].name.s,
-								 sock_info[r].name.len)==0) /*slower*/
-	#else
+				     sock_info[r].name.len)==0) /*slower*/
+#else
 			(memcmp(host->s, sock_info[r].name.s, 
-								sock_info[r].name.len)==0)
-	#endif
+				sock_info[r].name.len)==0)
+#endif
 			)
 			break;
 	/* check if host == ip address */
 		if ( 	(!sock_info[r].is_ip) &&
 				(host->len==sock_info[r].address_str.len) && 
-	#ifdef USE_IPV6
+#ifdef USE_IPV6
 			(strncasecmp(host->s, sock_info[r].address_str.s,
 								 sock_info[r].address_str.len)==0) /*slower*/
-	#else
+#else
 			(memcmp(host->s, sock_info[r].address_str.s, 
 								sock_info[r].address_str.len)==0)
-	#endif
+#endif
 			)
 			break;
 	}

+ 4 - 0
name_alias.h

@@ -56,7 +56,11 @@ static inline int grep_aliases(char* name, int len, unsigned short port)
 	struct  host_alias* a;
 	
 	for(a=aliases;a;a=a->next)
+#ifdef USE_TLS
+		if ((a->alias.len==len) && ((a->port==0) || (port==0) || (port==tls_port_no) ||
+#else
 		if ((a->alias.len==len) && ((a->port==0) || (port==0) || 
+#endif
 				(a->port==port)) && (strncasecmp(a->alias.s, name, len)==0))
 			return 1;
 	return 0;