mirror of
https://github.com/znc/znc.git
synced 2026-07-03 08:21:57 +02:00
Implement CAP between clients and znc
Right now, znc doesn't support any capabilities, but the general protocol works. This also has the plus point that it stops direct CAP commands between the IRCd and clients. That's a good thing because different clients might not support the same CAPs and thus znc would have to translate between them. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2022 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
+31
-2
@@ -126,10 +126,16 @@ void CClient::ReadLine(const CString& sData) {
|
||||
|
||||
return; // Don't forward this msg. ZNC has already registered us.
|
||||
}
|
||||
} else if (sCommand.Equals("CAP")) {
|
||||
HandleCap(sLine);
|
||||
|
||||
// Don't let the client talk to the server directly about CAP,
|
||||
// we don't want anything enabled that znc does not support.
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_pUser) {
|
||||
// Only NICK, USER and PASS are allowed before login
|
||||
// Only CAP, NICK, USER and PASS are allowed before login
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -588,7 +594,7 @@ bool CClient::SendMotd() {
|
||||
}
|
||||
|
||||
void CClient::AuthUser() {
|
||||
if (!m_bGotNick || !m_bGotUser)
|
||||
if (!m_bGotNick || !m_bGotUser || m_bInCap || IsAttached())
|
||||
return;
|
||||
|
||||
m_spAuth = new CClientAuth(this, m_sUser, m_sPass);
|
||||
@@ -771,3 +777,26 @@ CString CClient::GetNickMask() const {
|
||||
|
||||
return GetNick() + "!" + m_pUser->GetIdent() + "@" + sHost;
|
||||
}
|
||||
|
||||
void CClient::RespondCap(const CString& sResponse)
|
||||
{
|
||||
PutClient(":irc.znc.in CAP " + GetNick() + " " + sResponse);
|
||||
}
|
||||
|
||||
void CClient::HandleCap(const CString& sLine)
|
||||
{
|
||||
CString sSubCmd = sLine.Token(1);
|
||||
|
||||
if (sSubCmd.Equals("LS")) {
|
||||
RespondCap("LS :");
|
||||
m_bInCap = true;
|
||||
} else if (sSubCmd.Equals("END")) {
|
||||
m_bInCap = false;
|
||||
AuthUser();
|
||||
} else if (sSubCmd.Equals("REQ")) {
|
||||
// No capabilities supported for now
|
||||
RespondCap("NAK :" + sLine.Token(2, true).TrimPrefix_n(":"));
|
||||
} else if (sSubCmd.Equals("LIST")) {
|
||||
RespondCap("LIST :");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user