From 429b973af669230e2a81fc83d74bdd56b88549c8 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 15 Jun 2022 12:19:23 +0100 Subject: Add a basic function for templating strings. --- src/modules/m_dnsbl.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/modules/m_dnsbl.cpp') diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index cbeac201b..ee4d07f6a 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -154,7 +154,7 @@ public: + tag->source.str()); } - reason = tag->getString("reason", "Your IP (%ip%) has been blacklisted by a DNSBL.", 1, ServerInstance->Config->Limits.MaxLine); + reason = tag->getString("reason", "Your IP (%ip%) has been blacklisted by the %dnsbl% DNSBL.", 1, ServerInstance->Config->Limits.MaxLine); timeout = static_cast(tag->getDuration("timeout", 0, 1, 60)); markident = tag->getString("ident"); markhost = tag->getString("host"); @@ -264,14 +264,11 @@ public: if (match) { - std::string reason = ConfEntry->reason; - std::string::size_type x = reason.find("%ip%"); - while (x != std::string::npos) - { - reason.erase(x, 4); - reason.insert(x, them->GetIPString()); - x = reason.find("%ip%"); - } + const std::string reason = Template::Replace(ConfEntry->reason, { + { "dnsbl", ConfEntry->name }, + { "ip", them->GetIPString() }, + { "result", ConvToStr(result) }, + }); ConfEntry->stats_hits++; -- cgit v1.3.1-10-gc9f91