http: We can bind to localhost if we do it right, apparently.
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				Build Tilde Friends / Build-All (push) Has been cancelled
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	Build Tilde Friends / Build-All (push) Has been cancelled
				
			This commit is contained in:
		
							
								
								
									
										19
									
								
								src/http.c
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								src/http.c
									
									
									
									
									
								
							| @@ -716,10 +716,7 @@ int tf_http_listen(tf_http_t* http, int port, bool local_only, tf_tls_context_t* | ||||
|  | ||||
| 	if (r == 0) | ||||
| 	{ | ||||
| 		if (tf_util_is_mobile()) | ||||
| 		{ | ||||
| 			local_only = false; | ||||
| 		} | ||||
| 		bool use_ipv6 = !tf_util_is_mobile(); | ||||
|  | ||||
| #if defined(__HAIKU__) | ||||
| 		/* | ||||
| @@ -727,19 +724,21 @@ int tf_http_listen(tf_http_t* http, int port, bool local_only, tf_tls_context_t* | ||||
| 		** becomes unusable.  Since we probably want localhost only | ||||
| 		** on this single-user OS, let's just assume IPv4. | ||||
| 		*/ | ||||
| 		struct sockaddr_in addr = { | ||||
| 		use_ipv6 = false; | ||||
| #endif | ||||
|  | ||||
| 		struct sockaddr_in addr4 = { | ||||
| 			.sin_family = AF_INET, | ||||
| 			.sin_addr = { .s_addr = local_only ? INADDR_LOOPBACK : INADDR_ANY }, | ||||
| 			.sin_addr = { .s_addr = local_only ? htonl(INADDR_LOOPBACK) : htonl(INADDR_ANY) }, | ||||
| 			.sin_port = ntohs(port), | ||||
| 		}; | ||||
| #else | ||||
| 		struct sockaddr_in6 addr = { | ||||
| 		struct sockaddr_in6 addr6 = { | ||||
| 			.sin6_family = AF_INET6, | ||||
| 			.sin6_addr = local_only ? (struct in6_addr)IN6ADDR_LOOPBACK_INIT : (struct in6_addr)IN6ADDR_ANY_INIT, | ||||
| 			.sin6_port = ntohs(port), | ||||
| 		}; | ||||
| #endif | ||||
| 		r = uv_tcp_bind(&listener->tcp, (struct sockaddr*)&addr, 0); | ||||
| 		struct sockaddr* addr = use_ipv6 ? (struct sockaddr*)&addr6 : (struct sockaddr*)&addr4; | ||||
| 		r = uv_tcp_bind(&listener->tcp, addr, 0); | ||||
| 		if (r) | ||||
| 		{ | ||||
| 			tf_printf("%s:%d: uv_tcp_bind: %s\n", __FILE__, __LINE__, uv_strerror(r)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user