Skip to content

Commit

Permalink
Don't send buffers to unknown clients
Browse files Browse the repository at this point in the history
Whenever autoadd is not enabled and an unknown client connects to ZNC,
ZNC will proceed to indiscriminately send the contents of all buffers
to the client. However, this behaviour keeps repeating each time the
clients connects again: as this module is expected to be used with
AutoClearChanBuffer and AutoClearQueryBuffer both off, the buffers
aren't cleared, and ClientBuffer does not prevent ZNC from re-sending
the buffers on each client connect.

ClientBuffer should instead prevent ZNC from sending buffer contents
to unidentified clients.

Fixes #6.
  • Loading branch information
CyberShadow committed Apr 27, 2017
1 parent fe0f368 commit d58fd5a
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions clientbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,14 @@ CModule::EModRet CClientBufferMod::OnChanBufferStarting(CChan& chan, CClient& cl
return HALTCORE;

const CString& identifier = client.GetIdentifier();
if (HasClient(identifier)) {
// let "Buffer Playback..." message through?
const CBuffer& buffer = chan.GetBuffer();
if (!buffer.IsEmpty() && HasSeenTimestamp(identifier, chan.GetName(), GetTimestamp(buffer)))
return HALTCORE;
}
if (!HasClient(identifier))
return HALTCORE;

// let "Buffer Playback..." message through?
const CBuffer& buffer = chan.GetBuffer();
if (!buffer.IsEmpty() && HasSeenTimestamp(identifier, chan.GetName(), GetTimestamp(buffer)))
return HALTCORE;

return CONTINUE;
}

Expand All @@ -178,31 +180,39 @@ CModule::EModRet CClientBufferMod::OnChanBufferEnding(CChan& chan, CClient& clie
return HALTCORE;

const CString& identifier = client.GetIdentifier();
if (HasClient(identifier)) {
// let "Buffer Complete" message through?
const CBuffer& buffer = chan.GetBuffer();
if (!buffer.IsEmpty() && !UpdateTimestamp(identifier, chan.GetName(), GetTimestamp(buffer)))
return HALTCORE;
}
if (!HasClient(identifier))
return HALTCORE;

// let "Buffer Complete" message through?
const CBuffer& buffer = chan.GetBuffer();
if (!buffer.IsEmpty() && !UpdateTimestamp(identifier, chan.GetName(), GetTimestamp(buffer)))
return HALTCORE;

return CONTINUE;
}

CModule::EModRet CClientBufferMod::OnChanBufferPlayLine2(CChan& chan, CClient& client, CString& line, const timeval& tv)
{
const CString& identifier = client.GetIdentifier();
if (HasClient(identifier) && HasSeenTimestamp(identifier, chan.GetName(), tv))
if (!HasClient(identifier))
return HALTCORE;

if (HasSeenTimestamp(identifier, chan.GetName(), tv))
return HALTCORE;

return CONTINUE;
}

CModule::EModRet CClientBufferMod::OnPrivBufferPlayLine2(CClient& client, CString& line, const timeval& tv)
{
const CString& identifier = client.GetIdentifier();
if (HasClient(identifier)) {
CNick nick; CString cmd, target;
if (ParseMessage(line, nick, cmd, target) && !UpdateTimestamp(identifier, target, tv))
return HALTCORE;
}
if (!HasClient(identifier))
return HALTCORE;

CNick nick; CString cmd, target;
if (ParseMessage(line, nick, cmd, target) && !UpdateTimestamp(identifier, target, tv))
return HALTCORE;

return CONTINUE;
}

Expand Down

0 comments on commit d58fd5a

Please sign in to comment.