, commands(this)
, currmembid(0)
, eventprov(this, "event/server")
+ , sslapi(this)
, DNS(this, "DNS")
+ , tagevprov(this, "event/messagetag")
, loopCall(false)
{
}
void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y)
{
- bool ipvalid = true;
-
if (InspIRCd::Match(ServerInstance->Config->ServerName, x->Name, ascii_case_insensitive_map))
{
ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Not connecting to myself.");
return;
}
+ irc::sockets::sockaddrs sa;
#ifndef _WIN32
if (x->IPAddr.find('/') != std::string::npos)
{
struct stat sb;
- if (stat(x->IPAddr.c_str(), &sb) == -1 || !S_ISSOCK(sb.st_mode))
- ipvalid = false;
- }
-#endif
- if (x->IPAddr.find(':') != std::string::npos)
- {
- in6_addr n;
- if (inet_pton(AF_INET6, x->IPAddr.c_str(), &n) < 1)
- ipvalid = false;
+ if (stat(x->IPAddr.c_str(), &sb) == -1 || !S_ISSOCK(sb.st_mode) || !irc::sockets::untosa(x->IPAddr, sa))
+ {
+ // We don't use the family() != AF_UNSPEC check below for UNIX sockets as
+ // that results in a DNS lookup.
+ ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s is not a UNIX socket!",
+ x->Name.c_str(), x->IPAddr.c_str());
+ return;
+ }
}
else
+#endif
{
- in_addr n;
- if (inet_pton(AF_INET, x->IPAddr.c_str(),&n) < 1)
- ipvalid = false;
+ // If this fails then the IP sa will be AF_UNSPEC.
+ irc::sockets::aptosa(x->IPAddr, x->Port, sa);
}
-
+
/* Do we already have an IP? If so, no need to resolve it. */
- if (ipvalid)
+ if (sa.family() != AF_UNSPEC)
{
// Create a TreeServer object that will start connecting immediately in the background
- TreeSocket* newsocket = new TreeSocket(x, y, x->IPAddr);
+ TreeSocket* newsocket = new TreeSocket(x, y, sa);
if (newsocket->GetFd() > -1)
{
/* Handled automatically on success */
// If it's empty it might be that the server is still syncing (full version hasn't arrived yet)
// or the server is a 2.0 server and does not send a full version.
bool showfull = ((user->IsOper()) && (!found->GetFullVersion().empty()));
- const std::string& Version = (showfull ? found->GetFullVersion() : found->GetVersion());
- user->WriteNumeric(RPL_VERSION, Version);
+
+ Numeric::Numeric numeric(RPL_VERSION);
+ irc::tokenstream tokens(showfull ? found->GetFullVersion() : found->GetVersion());
+ for (std::string token; tokens.GetTrailing(token); )
+ numeric.push(token);
+ user->WriteNumeric(numeric);
}
else
{
if (!IS_LOCAL(d))
{
CmdBuilder params(user, message_type);
+ params.push_tags(details.tags_out);
params.push_back(d->uuid);
params.push_last(details.text);
params.Unicast(d);
}
else if (target.type == MessageTarget::TYPE_CHANNEL)
{
- Utils->SendChannelMessage(user->uuid, target.Get<Channel>(), details.text, target.status, details.exemptions, message_type);
+ Utils->SendChannelMessage(user->uuid, target.Get<Channel>(), details.text, target.status, details.tags_out, details.exemptions, message_type);
}
else if (target.type == MessageTarget::TYPE_SERVER)
{
const std::string* serverglob = target.Get<std::string>();
CmdBuilder par(user, message_type);
+ par.push_tags(details.tags_out);
par.push_back(*serverglob);
par.push_last(details.text);
par.Broadcast();
if (user->quitting)
return;
+ // Create the lazy ssl_cert metadata for this user if not already created.
+ if (sslapi)
+ sslapi->GetCertificate(user);
+
CommandUID::Builder(user).Broadcast();
if (user->IsOper())
void ModuleSpanningTree::OnPreRehash(User* user, const std::string ¶meter)
{
- if (loopCall)
- return; // Don't generate a REHASH here if we're in the middle of processing a message that generated this one
-
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "OnPreRehash called with param %s", parameter.c_str());
// Send out to other servers