diff options
author | Adam <Adam@anope.org> | 2016-12-19 19:03:10 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2016-12-19 19:03:10 -0500 |
commit | 438103199485f0e0e80289874f6f5cf70f8a76e3 (patch) | |
tree | d43b33c3d423ae1e2f373b04dee43f96ccacaffe /modules/m_sasl.cpp | |
parent | b3010c3c6b2a938c28ff10ab67f09528f0c91896 (diff) |
m_sasl: log hostname/ip, if provided
Diffstat (limited to 'modules/m_sasl.cpp')
-rw-r--r-- | modules/m_sasl.cpp | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/modules/m_sasl.cpp b/modules/m_sasl.cpp index e1f55bcc9..3dff6c41f 100644 --- a/modules/m_sasl.cpp +++ b/modules/m_sasl.cpp @@ -55,7 +55,7 @@ class Plain : public Mechanism return; } - SASL::IdentifyRequest *req = new SASL::IdentifyRequest(this->owner, m.source, acc, pass); + SASL::IdentifyRequest *req = new SASL::IdentifyRequest(this->owner, m.source, acc, pass, sess->hostname, sess->ip); FOREACH_MOD(OnCheckAuthentication, (NULL, req)); req->Dispatch(); } @@ -104,16 +104,20 @@ class External : public Mechanism return; } + Anope::string user = "A user"; + if (!mysess->hostname.empty() && !mysess->ip.empty()) + user = mysess->hostname + " (" + mysess->ip + ")"; + NickCore *nc = certs->FindAccountFromCert(mysess->cert); if (!nc || nc->HasExt("NS_SUSPENDED")) { - Log(Config->GetClient("NickServ"), "sasl") << "A user failed to identify using certificate " << mysess->cert << " using SASL EXTERNAL"; + Log(Config->GetClient("NickServ"), "sasl") << user << " failed to identify using certificate " << mysess->cert << " using SASL EXTERNAL"; sasl->Fail(sess); delete sess; return; } - Log(Config->GetClient("NickServ"), "sasl") << "A user identified to account " << nc->display << " using SASL EXTERNAL"; + Log(Config->GetClient("NickServ"), "sasl") << user << " identified to account " << nc->display << " using SASL EXTERNAL"; sasl->Succeed(sess, nc); delete sess; } @@ -160,8 +164,21 @@ class SASLService : public SASL::Service, public Timer return; } - if (!session) - session = mech->CreateSession(m.source); + Anope::string hostname, ip; + if (session) + { + // Copy over host/ip to mech-specific session + hostname = session->hostname; + ip = session->ip; + delete session; + } + + session = mech->CreateSession(m.source); + if (session) + { + session->hostname = hostname; + session->ip = ip; + } } else if (m.type == "D") { @@ -169,6 +186,13 @@ class SASLService : public SASL::Service, public Timer sessions.erase(m.source); return; } + else if (m.type == "H") + { + if (!session) + session = new Session(NULL, m.source); + session->hostname = m.data; + session->ip = m.ext; + } if (session && session->mech) session->mech->ProcessMessage(session, m); @@ -261,7 +285,7 @@ class SASLService : public SASL::Service, public Timer Session *s = it->second; ++it; - if (!s || !s->mech || s->created + 60 < Anope::CurTime) + if (!s || s->created + 60 < Anope::CurTime) { delete s; sessions.erase(key); |