mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 18:49:03 -04:00
Allow listeners to be able to listen on unavailable addresses.
This commit is contained in:
parent
1457c8738c
commit
0b8a13ab51
@ -168,6 +168,12 @@
|
||||
# To change it on a running bind, you'll have to comment it out,
|
||||
# rehash, comment it in and rehash again.
|
||||
defer="0"
|
||||
|
||||
# free: When this is enabled the listener will be created regardless of
|
||||
# whether the interface that provides the bind address is available. This
|
||||
# is useful for if you are starting InspIRCd on boot when the server may
|
||||
# not have brought the network interfaces up yet.
|
||||
free="no"
|
||||
>
|
||||
|
||||
<bind address="" port="6660-6669" type="clients">
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user