Skip to content

Commit d58fd5a

Browse files
committed
Don't send buffers to unknown clients
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.
1 parent fe0f368 commit d58fd5a

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

clientbuffer.cpp

+28-18
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,14 @@ CModule::EModRet CClientBufferMod::OnChanBufferStarting(CChan& chan, CClient& cl
163163
return HALTCORE;
164164

165165
const CString& identifier = client.GetIdentifier();
166-
if (HasClient(identifier)) {
167-
// let "Buffer Playback..." message through?
168-
const CBuffer& buffer = chan.GetBuffer();
169-
if (!buffer.IsEmpty() && HasSeenTimestamp(identifier, chan.GetName(), GetTimestamp(buffer)))
170-
return HALTCORE;
171-
}
166+
if (!HasClient(identifier))
167+
return HALTCORE;
168+
169+
// let "Buffer Playback..." message through?
170+
const CBuffer& buffer = chan.GetBuffer();
171+
if (!buffer.IsEmpty() && HasSeenTimestamp(identifier, chan.GetName(), GetTimestamp(buffer)))
172+
return HALTCORE;
173+
172174
return CONTINUE;
173175
}
174176

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

180182
const CString& identifier = client.GetIdentifier();
181-
if (HasClient(identifier)) {
182-
// let "Buffer Complete" message through?
183-
const CBuffer& buffer = chan.GetBuffer();
184-
if (!buffer.IsEmpty() && !UpdateTimestamp(identifier, chan.GetName(), GetTimestamp(buffer)))
185-
return HALTCORE;
186-
}
183+
if (!HasClient(identifier))
184+
return HALTCORE;
185+
186+
// let "Buffer Complete" message through?
187+
const CBuffer& buffer = chan.GetBuffer();
188+
if (!buffer.IsEmpty() && !UpdateTimestamp(identifier, chan.GetName(), GetTimestamp(buffer)))
189+
return HALTCORE;
190+
187191
return CONTINUE;
188192
}
189193

190194
CModule::EModRet CClientBufferMod::OnChanBufferPlayLine2(CChan& chan, CClient& client, CString& line, const timeval& tv)
191195
{
192196
const CString& identifier = client.GetIdentifier();
193-
if (HasClient(identifier) && HasSeenTimestamp(identifier, chan.GetName(), tv))
197+
if (!HasClient(identifier))
198+
return HALTCORE;
199+
200+
if (HasSeenTimestamp(identifier, chan.GetName(), tv))
194201
return HALTCORE;
202+
195203
return CONTINUE;
196204
}
197205

198206
CModule::EModRet CClientBufferMod::OnPrivBufferPlayLine2(CClient& client, CString& line, const timeval& tv)
199207
{
200208
const CString& identifier = client.GetIdentifier();
201-
if (HasClient(identifier)) {
202-
CNick nick; CString cmd, target;
203-
if (ParseMessage(line, nick, cmd, target) && !UpdateTimestamp(identifier, target, tv))
204-
return HALTCORE;
205-
}
209+
if (!HasClient(identifier))
210+
return HALTCORE;
211+
212+
CNick nick; CString cmd, target;
213+
if (ParseMessage(line, nick, cmd, target) && !UpdateTimestamp(identifier, target, tv))
214+
return HALTCORE;
215+
206216
return CONTINUE;
207217
}
208218

0 commit comments

Comments
 (0)