diff options
author | Peter Powell <petpow@saberuk.com> | 2016-11-12 16:04:16 +0000 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2016-11-12 22:31:15 +0000 |
commit | 0b8a13ab51551f4a6a67f7f52a22256d6e15ba90 (patch) | |
tree | edc7ed15201b0a46f70d00b9f011f6cd96e5c532 /src | |
parent | 1457c8738c707bddde4bb73fafcb618c24be9abe (diff) |
Allow listeners to be able to listen on unavailable addresses.
Diffstat (limited to 'src')
-rw-r--r-- | src/listensocket.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/listensocket.cpp b/src/listensocket.cpp index 13aebf75f..d09f5e624 100644 --- a/src/listensocket.cpp +++ b/src/listensocket.cpp @@ -54,6 +54,20 @@ ListenSocket::ListenSocket(ConfigTag* tag, const irc::sockets::sockaddrs& bind_t } #endif + if (tag->getBool("free")) + { + socklen_t enable = 1; +#if defined IP_FREEBIND // Linux 2.4+ + setsockopt(fd, SOL_IP, IP_FREEBIND, &enable, sizeof(enable)); +#elif defined IP_BINDANY // FreeBSD + setsockopt(fd, IPPROTO_IP, IP_BINDANY, &enable, sizeof(enable)); +#elif defined SO_BINDANY // NetBSD/OpenBSD + setsockopt(fd, SOL_SOCKET, SO_BINDANY, &enable, sizeof(enable)); +#else + (void)enable; +#endif + } + SocketEngine::SetReuse(fd); int rv = SocketEngine::Bind(this->fd, bind_to); if (rv >= 0) |