summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2011-12-12 23:36:25 +0000
committerChris Wilson <chris+github@qwirx.com>2011-12-12 23:36:25 +0000
commit20a8c39aa25d454a3fa142f125003ad242d73ea0 (patch)
treecfb6d937c300f04e455de1845d18f62e594ce713
parent4220d1bde508875d96036f04a1c62fab4742733b (diff)
Log the account name with connections, disconnections and statistics, requested by Pete Jalajas.
-rw-r--r--bin/bbstored/BackupStoreDaemon.cpp14
-rw-r--r--bin/bbstored/BackupStoreDaemon.h3
-rw-r--r--lib/backupstore/BackupCommands.cpp15
-rw-r--r--lib/backupstore/BackupStoreContext.h10
4 files changed, 28 insertions, 14 deletions
diff --git a/bin/bbstored/BackupStoreDaemon.cpp b/bin/bbstored/BackupStoreDaemon.cpp
index 2bf0073c..71976e6e 100644
--- a/bin/bbstored/BackupStoreDaemon.cpp
+++ b/bin/bbstored/BackupStoreDaemon.cpp
@@ -317,6 +317,8 @@ void BackupStoreDaemon::Connection2(SocketStreamTLS &rStream)
if(::sscanf(clientCommonName.c_str(), "BACKUP-%x", &id) != 1)
{
// Bad! Disconnect immediately
+ BOX_WARNING("Failed login: invalid client common name: " <<
+ clientCommonName);
return;
}
@@ -353,18 +355,20 @@ void BackupStoreDaemon::Connection2(SocketStreamTLS &rStream)
}
catch(...)
{
- LogConnectionStats(clientCommonName.c_str(), rStream);
+ LogConnectionStats(id, context.GetAccountName(), rStream);
throw;
}
- LogConnectionStats(clientCommonName.c_str(), rStream);
+ LogConnectionStats(id, context.GetAccountName(), rStream);
context.CleanUp();
}
-void BackupStoreDaemon::LogConnectionStats(const char *commonName,
- const SocketStreamTLS &s)
+void BackupStoreDaemon::LogConnectionStats(uint32_t accountId,
+ const std::string& accountName, const SocketStreamTLS &s)
{
// Log the amount of data transferred
- BOX_NOTICE("Connection statistics for " << commonName << ":"
+ BOX_NOTICE("Connection statistics for " <<
+ BOX_FORMAT_ACCOUNT(accountId) << " "
+ "(name=" << accountName << "):"
" IN=" << s.GetBytesRead() <<
" OUT=" << s.GetBytesWritten() <<
" NET_IN=" << (s.GetBytesRead() - s.GetBytesWritten()) <<
diff --git a/bin/bbstored/BackupStoreDaemon.h b/bin/bbstored/BackupStoreDaemon.h
index 49af5b81..d86e9dc4 100644
--- a/bin/bbstored/BackupStoreDaemon.h
+++ b/bin/bbstored/BackupStoreDaemon.h
@@ -63,7 +63,8 @@ protected:
// Housekeeping functions
void HousekeepingProcess();
- void LogConnectionStats(const char *commonName, const SocketStreamTLS &s);
+ void LogConnectionStats(uint32_t accountId,
+ const std::string& accountName, const SocketStreamTLS &s);
public:
// HousekeepingInterface implementation
diff --git a/lib/backupstore/BackupCommands.cpp b/lib/backupstore/BackupCommands.cpp
index 9552d831..b2a42eb7 100644
--- a/lib/backupstore/BackupCommands.cpp
+++ b/lib/backupstore/BackupCommands.cpp
@@ -89,16 +89,16 @@ std::auto_ptr<BackupProtocolMessage> BackupProtocolLogin::DoCommand(BackupProtoc
if(mClientID != rContext.GetClientID())
{
BOX_WARNING("Failed login from client ID " <<
- BOX_FORMAT_ACCOUNT(mClientID) <<
- ": wrong certificate for this account");
+ BOX_FORMAT_ACCOUNT(mClientID) << ": "
+ "wrong certificate for this account");
return PROTOCOL_ERROR(Err_BadLogin);
}
if(!rContext.GetClientHasAccount())
{
BOX_WARNING("Failed login from client ID " <<
- BOX_FORMAT_ACCOUNT(mClientID) <<
- ": no such account on this server");
+ BOX_FORMAT_ACCOUNT(mClientID) << ": "
+ "no such account on this server");
return PROTOCOL_ERROR(Err_BadLogin);
}
@@ -128,8 +128,8 @@ std::auto_ptr<BackupProtocolMessage> BackupProtocolLogin::DoCommand(BackupProtoc
// Log login
BOX_NOTICE("Login from Client ID " <<
- BOX_FORMAT_ACCOUNT(mClientID) <<
- " " <<
+ BOX_FORMAT_ACCOUNT(mClientID) << " "
+ "(name=" << rContext.GetAccountName() << "): " <<
(((mFlags & Flags_ReadOnly) != Flags_ReadOnly)
?"Read/Write":"Read-only"));
@@ -152,7 +152,8 @@ std::auto_ptr<BackupProtocolMessage> BackupProtocolLogin::DoCommand(BackupProtoc
std::auto_ptr<BackupProtocolMessage> BackupProtocolFinished::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
{
BOX_NOTICE("Session finished for Client ID " <<
- BOX_FORMAT_ACCOUNT(rContext.GetClientID()));
+ BOX_FORMAT_ACCOUNT(rContext.GetClientID()) << " "
+ "(name=" << rContext.GetAccountName() << ")");
// Let the context know about it
rContext.ReceivedFinishCommand();
diff --git a/lib/backupstore/BackupStoreContext.h b/lib/backupstore/BackupStoreContext.h
index edd5d198..7388f753 100644
--- a/lib/backupstore/BackupStoreContext.h
+++ b/lib/backupstore/BackupStoreContext.h
@@ -15,6 +15,7 @@
#include <memory>
#include "autogen_BackupProtocol.h"
+#include "BackupStoreInfo.h"
#include "BackupStoreRefCountDatabase.h"
#include "NamedLock.h"
#include "Message.h"
@@ -22,7 +23,6 @@
class BackupStoreDirectory;
class BackupStoreFilename;
-class BackupStoreInfo;
class IOStream;
class BackupProtocolMessage;
class StreamableMemBlock;
@@ -80,6 +80,14 @@ public:
void LoadStoreInfo();
void SaveStoreInfo(bool AllowDelay = true);
const BackupStoreInfo &GetBackupStoreInfo() const;
+ const std::string GetAccountName()
+ {
+ if(!mapStoreInfo.get())
+ {
+ return "Unknown";
+ }
+ return mapStoreInfo->GetAccountName();
+ }
// Client marker
int64_t GetClientStoreMarker();