summaryrefslogtreecommitdiffstats
path: root/src/openvpn/socket.c
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2014-03-21 14:18:39 +0100
committerGert Doering <gert@greenie.muc.de>2014-03-23 20:20:21 +0100
commit45184804c477aed2ae91ce23d6606da1bfccbaa7 (patch)
tree4619aa1b9f1c0ce50cf941b5ab307803cf37315b /src/openvpn/socket.c
parente719a0535345db8f0781c0b80408ca5417597469 (diff)
downloadopenvpn-45184804c477aed2ae91ce23d6606da1bfccbaa7.tar.gz
openvpn-45184804c477aed2ae91ce23d6606da1bfccbaa7.tar.xz
openvpn-45184804c477aed2ae91ce23d6606da1bfccbaa7.zip
Fix for server selecting address family
Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <1395407925-25518-7-git-send-email-arne@rfc2549.org> URL: http://article.gmane.org/gmane.network.openvpn.devel/8371 Signed-off-by: Gert Doering <gert@greenie.muc.de>
Diffstat (limited to 'src/openvpn/socket.c')
-rw-r--r--src/openvpn/socket.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c
index 0903afb..21aeac2 100644
--- a/src/openvpn/socket.c
+++ b/src/openvpn/socket.c
@@ -1512,21 +1512,10 @@ create_new_socket (struct link_socket* sock)
/* clear destination set by set_actual_address */
CLEAR(sock->info.lsa->actual.dest);
}
-
- /*
- * Create the socket early if socket should be bound
- */
- if (sock->bind_local)
- {
- create_socket (sock);
-
- if (sock->bind_local)
- bind_local(sock);
- }
-
}
+
/* bind socket if necessary */
void
link_socket_init_phase1 (struct link_socket *sock,
@@ -1949,6 +1938,17 @@ link_socket_init_phase2 (struct link_socket *sock,
/* If socket has not already been created create it now */
if (sock->sd == SOCKET_UNDEFINED)
{
+ /* If we have no --remote and have still not figured out the
+ * protocol family to use we will use the first of the bind */
+ if (sock->bind_local && sock->info.lsa->bind_local
+ && !sock->info.lsa->actual.ai_family && !sock->remote_host)
+ {
+ msg (M_WARN, "Could not determine IPv4/IPv6 protocol. Using %s",
+ addr_family_name(sock->info.lsa->bind_local->ai_family));
+ set_actual_address(&sock->info.lsa->actual, sock->info.lsa->bind_local);
+
+ }
+
if (sock->info.lsa->actual.ai_family)
{
create_socket (sock);