X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_ircv3_sts.cpp;h=86ea159c185a92c0f206cdf961245e2db3a6aa51;hb=98b470674b740faf83507214a8d41f63eec279a5;hp=f3b936b4189e43e29cfca5de19ed39c2449d0981;hpb=36040be2952186d56a6646ee7d972aaafdd4e31a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_ircv3_sts.cpp b/src/modules/m_ircv3_sts.cpp index f3b936b41..86ea159c1 100644 --- a/src/modules/m_ircv3_sts.cpp +++ b/src/modules/m_ircv3_sts.cpp @@ -1,8 +1,7 @@ /* * InspIRCd -- Internet Relay Chat Daemon * - * Copyright (C) 2015 Attila Molnar - * Copyright (C) 2017 Peter Powell + * Copyright (C) 2017-2019 Sadie Powell * * This file is part of InspIRCd. InspIRCd is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public @@ -35,6 +34,10 @@ class STSCap : public Cap::Capability if (GetProtocol(user) == Cap::CAP_LEGACY) return false; + // Don't send the cap to clients in a class which has STS disabled. + if (!user->GetClass()->config->getBool("usests", true)) + return false; + // Plaintext listeners have their own policy. SSLIOHook* sslhook = SSLIOHook::IsSSL(&user->eh); if (!sslhook) @@ -67,6 +70,7 @@ class STSCap : public Cap::Capability STSCap(Module* mod) : Cap::Capability(mod, "sts") { + DisableAutoRegister(); } ~STSCap() @@ -130,7 +134,7 @@ class ModuleIRCv3STS : public Module for (std::vector::const_iterator iter = ServerInstance->ports.begin(); iter != ServerInstance->ports.end(); ++iter) { ListenSocket* ls = *iter; - + // Is this listener on the right port? unsigned int saport = ls->bind_sa.port(); if (saport != port) @@ -163,18 +167,21 @@ class ModuleIRCv3STS : public Module if (host.empty()) throw ModuleException(" must contain a hostname, at " + tag->getTagLocation()); - unsigned int port = tag->getInt("port", 0, 0, UINT16_MAX); + unsigned int port = tag->getUInt("port", 0, 0, UINT16_MAX); if (!HasValidSSLPort(port)) throw ModuleException(" must be a TLS port, at " + tag->getTagLocation()); - unsigned long duration = tag->getDuration("duration", 60*60*24*30*2, 0, LONG_MAX); + unsigned long duration = tag->getDuration("duration", 60*60*24*30*2); bool preload = tag->getBool("preload"); cap.SetPolicy(host, duration, port, preload); + + if (!cap.IsRegistered()) + ServerInstance->Modules->AddService(cap); } Version GetVersion() CXX11_OVERRIDE { - return Version("Provides IRCv3 Strict Transport Security policy advertisement", VF_OPTCOMMON); + return Version("Provides IRCv3 Strict Transport Security policy advertisement", VF_OPTCOMMON|VF_VENDOR); } };