Преглед изворни кода

Bind to IPv4 on OpenBSD when using wildcard

OpenBSD does not support binding on both IPv4 and IPv6 using the same socket

(cherry picked from commit 619e7a2c8ba19d0dc45467e29d9d9aa8b3506ac8)
Fabio Alessandrelli пре 8 година
родитељ
комит
86de0bd081
2 измењених фајлова са 8 додато и 0 уклоњено
  1. 4 0
      drivers/unix/packet_peer_udp_posix.cpp
  2. 4 0
      drivers/unix/tcp_server_posix.cpp

+ 4 - 0
drivers/unix/packet_peer_udp_posix.cpp

@@ -127,7 +127,11 @@ Error PacketPeerUDPPosix::listen(int p_port, IP_Address p_bind_address, int p_re
 	ERR_FAIL_COND_V(sockfd != -1, ERR_ALREADY_IN_USE);
 	ERR_FAIL_COND_V(sockfd != -1, ERR_ALREADY_IN_USE);
 	ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
 	ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
 
 
+#ifdef __OpenBSD__
+	sock_type = IP::TYPE_IPV4; // OpenBSD does not support dual stacking, fallback to IPv4 only.
+#else
 	sock_type = IP::TYPE_ANY;
 	sock_type = IP::TYPE_ANY;
+#endif
 
 
 	if (p_bind_address.is_valid())
 	if (p_bind_address.is_valid())
 		sock_type = p_bind_address.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6;
 		sock_type = p_bind_address.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6;

+ 4 - 0
drivers/unix/tcp_server_posix.cpp

@@ -74,7 +74,11 @@ Error TCPServerPosix::listen(uint16_t p_port, const IP_Address p_bind_address) {
 	ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
 	ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
 
 
 	int sockfd;
 	int sockfd;
+#ifdef __OpenBSD__
+	sock_type = IP::TYPE_IPV4; // OpenBSD does not support dual stacking, fallback to IPv4 only.
+#else
 	sock_type = IP::TYPE_ANY;
 	sock_type = IP::TYPE_ANY;
+#endif
 
 
 	// If the bind address is valid use its type as the socket type
 	// If the bind address is valid use its type as the socket type
 	if (p_bind_address.is_valid())
 	if (p_bind_address.is_valid())