From 118c2aa7306fba7481e619ef916e5ecc05577695 Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Tue, 22 Feb 2011 00:32:30 +0200 Subject: Fixed interface binding on IPv4 only systems. --- setup.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'setup.cpp') diff --git a/setup.cpp b/setup.cpp index 08edcb4..4b47520 100644 --- a/setup.cpp +++ b/setup.cpp @@ -191,23 +191,24 @@ namespace { bool Setup::CheckServerIps() { if ( m_serverIps.empty() ) { - bool bindv6only = false; FILE* f = fopen("/proc/sys/net/ipv6/bindv6only", "r"); if (f) { + bool bindv6only = false; int c = fgetc(f); if (c != EOF) { bindv6only = c - '0'; } fclose(f); f = NULL; + esyslog( "[live] INFO: bindv6only=%d", bindv6only); + // add a default IPv6 listener address + m_serverIps.push_back( "::" ); + // skip the default IPv4 listener address if IPv6 one will be binded also to v4 + if (!bindv6only) + return true; } - esyslog( "[live] INFO: bindv6only=%d", bindv6only); - cerr << "INFO: bindv6only=" << bindv6only << endl; - // add a default IPv4 listener address if default IPv6 one - // will be binded only to v6 - if (bindv6only) - m_serverIps.push_back( "0.0.0.0" ); - m_serverIps.push_back( "::" ); + // add a default IPv4 listener address + m_serverIps.push_back( "0.0.0.0" ); // we assume these are ok :) return true; } -- cgit v1.2.3