Allow clients to specify an ID via PASS or USER

- PASS [user[@identifier][/network]:]password
- USER user[@identifier][/network] ...

NOTE: There's a slight ambiguosity with the '@' character, which happens
to be a valid character in usernames, but also acts as a marker for the
identifier. Therefore, '@' is considered as part of the username if it's
followed by non-word characters (as in an email address), otherwise as
a marker for an identifier.

This is only an enabler for #343. The rest can be done with modules:
- managing client ID specific playback buffers
- filtering channels based on the client ID

The reason this should be part of ZNC core is that only global modules
have access to OnUnknownUserRaw(), which is needed to capture USER/PASS.
First of all, the aforementioned modules shouldn't be global. Furthermore,
it would be possible to have only one module that parsed and removed the
client ID so that ZNC core woulnd't choke.
This commit is contained in:
J-P Nurmi
2014-09-28 01:17:03 +02:00
parent 5365dc462c
commit 8d77faa260
4 changed files with 145 additions and 21 deletions
+9
View File
@@ -112,6 +112,7 @@ public:
CString GetNick(bool bAllowIRCNick = true) const;
CString GetNickMask() const;
CString GetIdentifier() const { return m_sIdentifier; }
bool HasNamesx() const { return m_bNamesx; }
bool HasUHNames() const { return m_bUHNames; }
bool IsAway() const { return m_bAway; }
@@ -119,6 +120,8 @@ public:
bool HasBatch() const { return m_bBatch; }
bool HasSelfMessage() const { return m_bSelfMessage; }
static bool IsValidIdentifier(const CString& sIdentifier);
void UserCommand(CString& sLine);
void UserPortCommand(CString& sLine);
void StatusCTCP(const CString& sCommand);
@@ -157,6 +160,9 @@ public:
private:
void HandleCap(const CString& sLine);
void RespondCap(const CString& sResponse);
void ParsePass(const CString& sAuthLine);
void ParseUser(const CString& sAuthLine);
void ParseIdentifier(const CString& sAuthLine);
protected:
bool m_bGotPass;
@@ -175,8 +181,11 @@ protected:
CString m_sPass;
CString m_sUser;
CString m_sNetwork;
CString m_sIdentifier;
std::shared_ptr<CAuthBase> m_spAuth;
SCString m_ssAcceptedCaps;
friend class ClientTest;
};
#endif // !_CLIENT_H