Replace #define IPV6 with <config defaultbind="ipv6">, and autodetect if not specified

This commit is contained in:
Daniel De Graaf 2010-02-23 12:44:26 -06:00
parent cb8baf3da9
commit f222755ccf
9 changed files with 49 additions and 59 deletions

11
configure vendored
View File

@ -220,11 +220,6 @@ if (defined $opt_noports)
{
$config{USE_PORTS} = "n";
}
$config{IPV6} = "y"; # IPv6 support
if (defined $opt_noipv6)
{
$config{IPV6} = "n";
}
$config{_SOMAXCONN} = SOMAXCONN; # Max connections in accept queue
$config{OSNAME} = $^O; # Operating System Name
$config{IS_DARWIN} = "NO"; # Is OSX?
@ -634,9 +629,6 @@ should NOT be used. You should probably specify a newer compiler.\n\n";
}
}
yesno('IPV6',"Would you like to build InspIRCd with IPv6 support?\nYou can still use IPv4 addresses in your port bindings.\n\nEnable IPv6?");
print "\n";
$config{USE_FREEBSD_BASE_SSL} = "n";
$config{USE_FREEBSD_PORTS_SSL} = "n";
if ($config{HAS_OPENSSL_PORT} ne "")
@ -953,9 +945,6 @@ print FILEHANDLE "#define MAXBUF " . ($config{MAXBUF}+2) . "\n";
if ($config{HAS_STDINT} eq "true") {
print FILEHANDLE "#define HAS_STDINT\n";
}
if ($config{IPV6} =~ /y/i) {
print FILEHANDLE "#define IPV6\n";
}
if ($config{HAS_EVENTFD} eq 'true') {
print FILEHANDLE "#define HAS_EVENTFD\n";
}

View File

@ -555,10 +555,15 @@
# in channel will be sent a NOTICE about it.
announcets="yes"
# allowmismatched: Setting this option to yes will allow servers to link even
# if they don't have the same VF_OPTCOMMON modules loaded. Setting this to
# yes may introduce some desyncs and weirdness.
allowmismatched="no"
# allowmismatched: Setting this option to yes will allow servers to link even
# if they don't have the same VF_OPTCOMMON modules loaded. Setting this to
# yes may introduce some desyncs and weirdness.
allowmismatched="no"
# defaultbind: Sets the default for <bind> tags without an address. Choices are
# ipv4 or ipv6; if not specified, IPv6 will be used if your system has support,
# falling back to IPv4 otherwise.
defaultbind="auto"
# hostintopic: If enabled, channels will show the host of the topicsetter
# in the topic. If set to no, it will only show the nick of the topicsetter.

View File

@ -205,6 +205,9 @@ class CoreExport ServerConfig
/** True if this configuration is valid enough to run with */
bool valid;
/** Bind to IPv6 by default */
bool WildcardIPv6;
/** Used to indicate who we announce invites to on a channel */
enum InviteAnnounceState { INVITE_ANNOUNCE_NONE, INVITE_ANNOUNCE_ALL, INVITE_ANNOUNCE_OPS, INVITE_ANNOUNCE_DYNAMIC };

View File

@ -213,7 +213,6 @@ sub dumphash()
print "\e[0mModule path:\e[1;32m\t\t\t$main::config{MODULE_DIR}\e[0m\n";
print "\e[0mGCC Version Found:\e[1;32m\t\t$main::config{GCCVER}.$main::config{GCCMINOR}\e[0m\n";
print "\e[0mCompiler program:\e[1;32m\t\t$main::config{CC}\e[0m\n";
print "\e[0mIPv6 Support:\e[1;32m\t\t\t$main::config{IPV6}\e[0m\n";
print "\e[0mGnuTLS Support:\e[1;32m\t\t\t$main::config{USE_GNUTLS}\e[0m\n";
print "\e[0mOpenSSL Support:\e[1;32m\t\t$main::config{USE_OPENSSL}\e[0m\n\n";
print "\e[1;32mImportant note: The maximum length values are now configured in the\e[0m\n";

View File

@ -22,7 +22,7 @@ ServerConfig::ServerConfig()
{
WhoWasGroupSize = WhoWasMaxGroups = WhoWasMaxKeep = 0;
NoUserDns = OperSpyWhois = HideBans = HideSplits = UndernetMsgPrefix = NameOnlyModes = false;
CycleHosts = InvBypassModes = true;
WildcardIPv6 = CycleHosts = InvBypassModes = true;
dns_timeout = 5;
MaxTargets = 20;
NetBufferSize = 10240;
@ -526,6 +526,24 @@ void ServerConfig::Fill()
if (!sid.empty() && !ServerInstance->IsSID(sid))
throw CoreException(sid + " is not a valid server ID. A server ID must be 3 characters long, with the first character a digit and the next two characters a digit or letter.");
std::string defbind = options->getString("defaultbind");
if (assign(defbind) == "ipv4")
{
WildcardIPv6 = false;
}
else if (assign(defbind) == "ipv6")
{
WildcardIPv6 = true;
}
else
{
WildcardIPv6 = true;
int socktest = socket(AF_INET6, SOCK_STREAM, 0);
if (socktest < 0)
WildcardIPv6 = false;
else
close(socktest);
}
ConfigTagList tags = ConfTags("uline");
for(ConfigIter i = tags.first; i != tags.second; ++i)
{

View File

@ -11,8 +11,6 @@
* ---------------------------------------------------
*/
/* $Core */
#include "inspircd.h"
#include "socket.h"
#include "socketengine.h"

View File

@ -124,10 +124,6 @@ void TreeSocket::SendCapabilities(int phase)
WriteLine("CAPAB CHANMODES :" + BuildModeList(MODETYPE_CHANNEL));
WriteLine("CAPAB USERMODES :" + BuildModeList(MODETYPE_USER));
int ip6 = 0;
#ifdef IPV6
ip6 = 1;
#endif
std::string extra;
/* Do we have sha256 available? If so, we send a challenge */
if (Utils->ChallengeResponse && (ServerInstance->Modules->Find("m_sha256.so")))
@ -146,7 +142,6 @@ void TreeSocket::SendCapabilities(int phase)
" MAXKICK="+ConvToStr(ServerInstance->Config->Limits.MaxKick)+
" MAXGECOS="+ConvToStr(ServerInstance->Config->Limits.MaxGecos)+
" MAXAWAY="+ConvToStr(ServerInstance->Config->Limits.MaxAway)+
" IP6NATIVE="+ConvToStr(ip6)+
" IP6SUPPORT=1"+
" PROTOCOL="+ConvToStr(ProtocolVersion)+extra+
" PREFIX="+ServerInstance->Modes->BuildPrefixes()+

View File

@ -145,13 +145,16 @@ bool irc::sockets::aptosa(const std::string& addr, int port, irc::sockets::socka
memset(&sa, 0, sizeof(sa));
if (addr.empty() || addr.c_str()[0] == '*')
{
#ifdef IPV6
sa.in6.sin6_family = AF_INET6;
sa.in6.sin6_port = htons(port);
#else
sa.in4.sin_family = AF_INET;
sa.in4.sin_port = htons(port);
#endif
if (ServerInstance->Config->WildcardIPv6)
{
sa.in6.sin6_family = AF_INET6;
sa.in6.sin6_port = htons(port);
}
else
{
sa.in4.sin_family = AF_INET;
sa.in4.sin_port = htons(port);
}
return true;
}
else if (inet_pton(AF_INET, addr.c_str(), &sa.in4.sin_addr) > 0)
@ -210,35 +213,17 @@ std::string irc::sockets::sockaddrs::str() const
char buffer[MAXBUF];
if (sa.sa_family == AF_INET)
{
#ifndef IPV6
if (in4.sin_addr.s_addr == 0)
{
sprintf(buffer, "*:%u", ntohs(in4.sin_port));
}
else
#endif
{
const uint8_t* bits = reinterpret_cast<const uint8_t*>(&in4.sin_addr);
sprintf(buffer, "%d.%d.%d.%d:%u", bits[0], bits[1], bits[2], bits[3], ntohs(in4.sin_port));
}
const uint8_t* bits = reinterpret_cast<const uint8_t*>(&in4.sin_addr);
sprintf(buffer, "%d.%d.%d.%d:%u", bits[0], bits[1], bits[2], bits[3], ntohs(in4.sin_port));
}
else if (sa.sa_family == AF_INET6)
{
#ifdef IPV6
if (!memcmp(all_zero, &in6.sin6_addr, 16))
{
sprintf(buffer, "*:%u", ntohs(in6.sin6_port));
}
else
#endif
{
buffer[0] = '[';
if (!inet_ntop(AF_INET6, &in6.sin6_addr, buffer+1, MAXBUF - 10))
return "<unknown>"; // should never happen, buffer is large enough
int len = strlen(buffer);
// no need for snprintf, buffer has at least 9 chars left, max short len = 5
sprintf(buffer + len, "]:%u", ntohs(in6.sin6_port));
}
buffer[0] = '[';
if (!inet_ntop(AF_INET6, &in6.sin6_addr, buffer+1, MAXBUF - 10))
return "<unknown>"; // should never happen, buffer is large enough
int len = strlen(buffer);
// no need for snprintf, buffer has at least 9 chars left, max short len = 5
sprintf(buffer + len, "]:%u", ntohs(in6.sin6_port));
}
else
return "<unknown>";

View File

@ -353,8 +353,6 @@ void Run()
fprintf(f, "/* Auto generated by configure, do not modify! */\n");
fprintf(f, "#ifndef __CONFIGURATION_AUTO__\n");
fprintf(f, "#define __CONFIGURATION_AUTO__\n\n");
if (ipv6)
fprintf(f, "#define IPV6 1\n\n");
fprintf(f, "#define CONFIG_FILE \"%s/inspircd.conf\"\n", config_file);
fprintf(f, "#define MOD_PATH \"%s\"\n", mod_path);