Skip to content

Commit

Permalink
Allow configuration of the server port that the client will connect to
Browse files Browse the repository at this point in the history
(bbackupd and bbackupquery).

Redesign ConfigurationVerify to use classes instead of structs.

Use port 22011 instead of 2201 during tests, to reduce the chances of 
conflicting with a running bbstored or other process.

Ignore autogen_* in svn:ignore everywhere instead of individual per-file 
ignores.
  • Loading branch information
qris committed Mar 28, 2008
1 parent 4fca88e commit 732bdbd
Show file tree
Hide file tree
Showing 19 changed files with 353 additions and 158 deletions.
37 changes: 37 additions & 0 deletions .hgignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.svn
BoxConfig.h
BoxConfig.h.in
BoxPlatform.pm
BoxPortsAndFiles.h
ExceptionCodes.txt
Makefile
_main.cpp
_t
_t-gdb
aclocal.m4
autogen_*
autom4te.cache
bbackupd-config
bbackupd.conf
bbstored-certs
bbstored-config
config.log
config.status
configure
debug
extcheck1.pl
extcheck2.pl
local
makebuildenv.pl
makedistribution.pl
makedocumentation.pl
makeexception.pl
makeparcels.pl
makeprotocol.pl
notifyscript.pl
parcels
raidfile-config
release
runtest.pl
syncallowscript.pl
testbackupstorefix.pl
5 changes: 4 additions & 1 deletion bin/bbackupd/BackupClientContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ BackupClientContext::BackupClientContext
BackupDaemon &rDaemon,
TLSContext &rTLSContext,
const std::string &rHostname,
int Port,
int32_t AccountNumber,
bool ExtendedLogging,
bool ExtendedLogToFile,
Expand All @@ -52,6 +53,7 @@ BackupClientContext::BackupClientContext
: mrDaemon(rDaemon),
mrTLSContext(rTLSContext),
mHostname(rHostname),
mPort(Port),
mAccountNumber(AccountNumber),
mpSocket(0),
mpConnection(0),
Expand Down Expand Up @@ -129,7 +131,8 @@ BackupProtocolClient &BackupClientContext::GetConnection()
mHostname << "'...");

// Connect!
mpSocket->Open(mrTLSContext, Socket::TypeINET, mHostname.c_str(), BOX_PORT_BBSTORED);
mpSocket->Open(mrTLSContext, Socket::TypeINET,
mHostname.c_str(), mPort);

// And create a procotol object
mpConnection = new BackupProtocolClient(*mpSocket);
Expand Down
2 changes: 2 additions & 0 deletions bin/bbackupd/BackupClientContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class BackupClientContext : public DiffTimer
BackupDaemon &rDaemon,
TLSContext &rTLSContext,
const std::string &rHostname,
int32_t Port,
int32_t AccountNumber,
bool ExtendedLogging,
bool ExtendedLogToFile,
Expand Down Expand Up @@ -201,6 +202,7 @@ class BackupClientContext : public DiffTimer
BackupDaemon &mrDaemon;
TLSContext &mrTLSContext;
std::string mHostname;
int mPort;
int32_t mAccountNumber;
SocketStreamTLS *mpSocket;
BackupProtocolClient *mpConnection;
Expand Down
1 change: 1 addition & 0 deletions bin/bbackupd/BackupDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,7 @@ void BackupDaemon::Run2()
*this,
tlsContext,
conf.GetKeyValue("StoreHostname"),
conf.GetKeyValueInt("StorePort"),
conf.GetKeyValueInt("AccountNumber"),
conf.GetKeyValueBool("ExtendedLogging"),
conf.KeyExists("ExtendedLogFile"),
Expand Down
4 changes: 3 additions & 1 deletion bin/bbackupquery/bbackupquery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ int main(int argc, const char *argv[])
// 2. Connect to server
if(!quiet) BOX_INFO("Connecting to store...");
SocketStreamTLS socket;
socket.Open(tlsContext, Socket::TypeINET, conf.GetKeyValue("StoreHostname").c_str(), BOX_PORT_BBSTORED);
socket.Open(tlsContext, Socket::TypeINET,
conf.GetKeyValue("StoreHostname").c_str(),
conf.GetKeyValueInt("StorePort"));

// 3. Make a protocol, and handshake
if(!quiet) BOX_INFO("Handshake with store...");
Expand Down
89 changes: 52 additions & 37 deletions lib/backupclient/BackupDaemonConfigVerify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@

static const ConfigurationVerifyKey backuplocationkeys[] =
{
{"ExcludeFile", 0, ConfigTest_MultiValueAllowed, 0},
{"ExcludeFilesRegex", 0, ConfigTest_MultiValueAllowed, 0},
{"ExcludeDir", 0, ConfigTest_MultiValueAllowed, 0},
{"ExcludeDirsRegex", 0, ConfigTest_MultiValueAllowed, 0},
{"AlwaysIncludeFile", 0, ConfigTest_MultiValueAllowed, 0},
{"AlwaysIncludeFilesRegex", 0, ConfigTest_MultiValueAllowed, 0},
{"AlwaysIncludeDir", 0, ConfigTest_MultiValueAllowed, 0},
{"AlwaysIncludeDirsRegex", 0, ConfigTest_MultiValueAllowed, 0},
{"Path", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0}
ConfigurationVerifyKey("ExcludeFile", ConfigTest_MultiValueAllowed),
ConfigurationVerifyKey("ExcludeFilesRegex", ConfigTest_MultiValueAllowed),
ConfigurationVerifyKey("ExcludeDir", ConfigTest_MultiValueAllowed),
ConfigurationVerifyKey("ExcludeDirsRegex", ConfigTest_MultiValueAllowed),
ConfigurationVerifyKey("AlwaysIncludeFile", ConfigTest_MultiValueAllowed),
ConfigurationVerifyKey("AlwaysIncludeFilesRegex", ConfigTest_MultiValueAllowed),
ConfigurationVerifyKey("AlwaysIncludeDir", ConfigTest_MultiValueAllowed),
ConfigurationVerifyKey("AlwaysIncludeDirsRegex", ConfigTest_MultiValueAllowed),
ConfigurationVerifyKey("Path", ConfigTest_Exists | ConfigTest_LastEntry)
};

static const ConfigurationVerify backuplocations[] =
Expand Down Expand Up @@ -64,39 +64,54 @@ static const ConfigurationVerify verifyserver[] =

static const ConfigurationVerifyKey verifyrootkeys[] =
{
{"AccountNumber", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},

{"UpdateStoreInterval", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
{"MinimumFileAge", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
{"MaxUploadWait", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
{"MaxFileTimeInFuture", "172800", ConfigTest_IsInt, 0}, // file is uploaded if the file is this much in the future (2 days default)

{"AutomaticBackup", "yes", ConfigTest_IsBool, 0},
ConfigurationVerifyKey("AccountNumber",
ConfigTest_Exists | ConfigTest_IsInt),
ConfigurationVerifyKey("UpdateStoreInterval",
ConfigTest_Exists | ConfigTest_IsInt),
ConfigurationVerifyKey("MinimumFileAge",
ConfigTest_Exists | ConfigTest_IsInt),
ConfigurationVerifyKey("MaxUploadWait",
ConfigTest_Exists | ConfigTest_IsInt),
ConfigurationVerifyKey("MaxFileTimeInFuture", ConfigTest_IsInt, 172800),
// file is uploaded if the file is this much in the future
// (2 days default)
ConfigurationVerifyKey("AutomaticBackup", ConfigTest_IsBool, true),

{"SyncAllowScript", 0, 0, 0}, // optional script to run to see if the sync should be started now
// return "now" if it's allowed, or a number of seconds if it's not

{"MaximumDiffingTime", 0, ConfigTest_IsInt, 0},
{"DeleteRedundantLocationsAfter", "172800", ConfigTest_IsInt, 0},
ConfigurationVerifyKey("SyncAllowScript", 0),
// script that returns "now" if backup is allowed now, or a number
// of seconds to wait before trying again if not

{"FileTrackingSizeThreshold", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
{"DiffingUploadSizeThreshold", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
{"StoreHostname", 0, ConfigTest_Exists, 0},
{"ExtendedLogging", "no", ConfigTest_IsBool, 0}, // extended log to syslog
{"ExtendedLogFile", NULL, 0, 0}, // extended log to a file
{"LogAllFileAccess", "no", ConfigTest_IsBool, 0},
ConfigurationVerifyKey("MaximumDiffingTime", ConfigTest_IsInt),
ConfigurationVerifyKey("DeleteRedundantLocationsAfter",
ConfigTest_IsInt, 172800),

{"CommandSocket", 0, 0, 0}, // not compulsory to have this
{"KeepAliveTime", 0, ConfigTest_IsInt, 0}, // optional
{"StoreObjectInfoFile", 0, 0, 0}, // optional
ConfigurationVerifyKey("FileTrackingSizeThreshold",
ConfigTest_Exists | ConfigTest_IsInt),
ConfigurationVerifyKey("DiffingUploadSizeThreshold",
ConfigTest_Exists | ConfigTest_IsInt),
ConfigurationVerifyKey("StoreHostname", ConfigTest_Exists),
ConfigurationVerifyKey("StorePort", ConfigTest_IsInt,
BOX_PORT_BBSTORED),
ConfigurationVerifyKey("ExtendedLogging", ConfigTest_IsBool, false),
// extended log to syslog
ConfigurationVerifyKey("ExtendedLogFile", 0),
// extended log to a file
ConfigurationVerifyKey("LogAllFileAccess", ConfigTest_IsBool, false),
ConfigurationVerifyKey("CommandSocket", 0),
// not compulsory to have this
ConfigurationVerifyKey("KeepAliveTime", ConfigTest_IsInt),
ConfigurationVerifyKey("StoreObjectInfoFile", 0),
// optional

{"NotifyScript", 0, 0, 0}, // optional script to run when backup needs attention, eg store full
ConfigurationVerifyKey("NotifyScript", 0),
// optional script to run when backup needs attention, eg store full

{"CertificateFile", 0, ConfigTest_Exists, 0},
{"PrivateKeyFile", 0, ConfigTest_Exists, 0},
{"TrustedCAsFile", 0, ConfigTest_Exists, 0},
{"KeysFile", 0, ConfigTest_Exists, 0},
{"DataDirectory", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0}
ConfigurationVerifyKey("CertificateFile", ConfigTest_Exists),
ConfigurationVerifyKey("PrivateKeyFile", ConfigTest_Exists),
ConfigurationVerifyKey("TrustedCAsFile", ConfigTest_Exists),
ConfigurationVerifyKey("KeysFile", ConfigTest_Exists),
ConfigurationVerifyKey("DataDirectory",
ConfigTest_Exists | ConfigTest_LastEntry),
};

const ConfigurationVerify BackupDaemonConfigVerify =
Expand Down
17 changes: 10 additions & 7 deletions lib/backupstore/BackupStoreConfigVerify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

static const ConfigurationVerifyKey verifyserverkeys[] =
{
SERVERTLS_VERIFY_SERVER_KEYS(0) // no default listen addresses
SERVERTLS_VERIFY_SERVER_KEYS(ConfigurationVerifyKey::NoDefaultValue)
// no default listen addresses
};

static const ConfigurationVerify verifyserver[] =
Expand All @@ -32,16 +33,18 @@ static const ConfigurationVerify verifyserver[] =

static const ConfigurationVerifyKey verifyrootkeys[] =
{
{"AccountDatabase", 0, ConfigTest_Exists, 0},
{"TimeBetweenHousekeeping", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
{"ExtendedLogging", "no", ConfigTest_IsBool, 0}, // make value "yes" to enable in config file
ConfigurationVerifyKey("AccountDatabase", ConfigTest_Exists),
ConfigurationVerifyKey("TimeBetweenHousekeeping",
ConfigTest_Exists | ConfigTest_IsInt),
ConfigurationVerifyKey("ExtendedLogging", ConfigTest_IsBool, false),
// make value "yes" to enable in config file

#ifdef WIN32
{"RaidFileConf", "", ConfigTest_LastEntry, 0}
ConfigurationVerifyKey("RaidFileConf", ConfigTest_LastEntry)
#else
{"RaidFileConf", BOX_FILE_RAIDFILE_DEFAULT_CONFIG, ConfigTest_LastEntry, 0}
ConfigurationVerifyKey("RaidFileConf", ConfigTest_LastEntry,
BOX_FILE_RAIDFILE_DEFAULT_CONFIG)
#endif

};

const ConfigurationVerify BackupConfigFileVerify =
Expand Down
Loading

0 comments on commit 732bdbd

Please sign in to comment.