Skip to content
Browse files

Make certauth accept a optional argument of the key when you add a key

  • Loading branch information...
1 parent 66e2507 commit 1c0edff722cfd2f782a51267a3b488d0f55aaf5e @kylef kylef committed May 24, 2011
Showing with 10 additions and 5 deletions.
  1. +10 −5 modules/certauth.cpp
View
15 modules/certauth.cpp
@@ -17,7 +17,8 @@ class CSSLClientCertMod : public CGlobalModule {
public:
GLOBALMODCONSTRUCTOR(CSSLClientCertMod) {
AddHelpCommand();
- AddCommand("Add", static_cast<CModCommand::ModCmdFunc>(&CSSLClientCertMod::HandleAddCommand));
+ AddCommand("Add", static_cast<CModCommand::ModCmdFunc>(&CSSLClientCertMod::HandleAddCommand),
+ "[pubkey]", "If pubkey is not provided will use the current key");
AddCommand("Del", static_cast<CModCommand::ModCmdFunc>(&CSSLClientCertMod::HandleDelCommand),
"id");
AddCommand("List", static_cast<CModCommand::ModCmdFunc>(&CSSLClientCertMod::HandleListCommand));
@@ -129,17 +130,21 @@ class CSSLClientCertMod : public CGlobalModule {
}
void HandleAddCommand(const CString& sLine) {
- CString sPubKey = GetKey(m_pClient);
+ CString sPubKey = sLine.Token(1);
if (sPubKey.empty()) {
- PutModule("You are not connected with any valid public key");
+ sPubKey = GetKey(m_pClient);
+ }
+
+ if (sPubKey.empty()) {
+ PutModule("You did not supply a public key or connect with one.");
} else {
pair<SCString::iterator, bool> res = m_PubKeys[m_pUser->GetUserName()].insert(sPubKey);
if (res.second) {
- PutModule("Added your current public key to the list");
+ PutModule("'" + sPubKey + "' added.");
Save();
} else {
- PutModule("Your key was already added");
+ PutModule("The key '" + sPubKey + "' is already added.");
}
}
}

0 comments on commit 1c0edff

Please sign in to comment.
Something went wrong with that request. Please try again.