Skip to content

Commit

Permalink
Updated broker to version 5.7.0.107
Browse files Browse the repository at this point in the history
* Disabled caching of SSL Sessions (not applicable for MQTT)
* Updated configuration parser to properly trim whitespaces (name and value)
* Added instance identifier to instinsic broker services (now differentiated from locally connected services)
  • Loading branch information
chrissmith-mcafee committed Feb 6, 2019
1 parent 175c5f8 commit 820b6ae
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 7 deletions.
19 changes: 17 additions & 2 deletions src/brokerlib/include/BrokerSettings.h
Expand Up @@ -20,11 +20,11 @@ class BrokerSettings
{
public:
/**
* Sets the broker GUID
* Sets the broker GUID. It also automatically resets the instance GUID.
*
* @param guid The broker GUID
*/
static void setGuid( const char* guid ) { sm_guid = guid; }
static void setGuid( const char* guid ) { sm_guid = guid; resetInstanceGuid(); }

/**
* Returns the broker GUID. If the broker GUID has not been set, an exception will be thrown.
Expand All @@ -34,6 +34,19 @@ class BrokerSettings
*/
static const char* getGuid( bool throwException = true );

/**
* Returns the broker instance GUID. If the broker instance GUID has not been set, an exception will be thrown.
*
* @param throwException Whether to throw an exception if the GUID has not been set
* @return The broker instance GUID. If the broker instance GUID has not been set, an exception will be thrown.
*/
static const char* getInstanceGuid( bool throwException = true );

/**
* Sets the broker instance GUID using the value that was set for broker GUID.
*/
static void resetInstanceGuid();

/**
* Sets the broker tenant GUID
*
Expand Down Expand Up @@ -491,6 +504,8 @@ class BrokerSettings
private:
/** The broker GUID */
static std::string sm_guid;
/** The broker instance GUID. It is essentially "<broker-guid>:<broker-guid>" */
static std::string sm_instanceGuid;
/** The broker tenant GUID */
static std::string sm_tenantGuid;
/** The broker listen port */
Expand Down
3 changes: 3 additions & 0 deletions src/brokerlib/include/Configuration.h
Expand Up @@ -14,6 +14,7 @@
#include <vector>
#include <stdexcept>
#include "StringUtil.h"
#include <boost/algorithm/string.hpp>

namespace dxl {
namespace broker {
Expand Down Expand Up @@ -173,6 +174,8 @@ class Configuration

std::string name = line.substr( 0, nameEnd );
std::string value = line.substr( valueStart );
boost::trim( name );
boost::trim( value );
setProperty( name, value );
}

Expand Down
5 changes: 4 additions & 1 deletion src/brokerlib/message/handler/src/MessageRoutingHandler.cpp
Expand Up @@ -97,7 +97,10 @@ bool MessageRoutingHandler::onInsertMessage(
( destClientGuids->find( destId ) == destClientGuids->end() ) &&
( destClientGuids->find( canonicalDestId ) == destClientGuids->end() ) &&
( !( contextFlags & DXL_FLAG_LOCAL ) ||
destClientGuids->find( BrokerSettings::getGuid() ) == destClientGuids->end() ) )
( destClientGuids->find( BrokerSettings::getGuid() ) == destClientGuids->end() &&
destClientGuids->find( BrokerSettings::getInstanceGuid() ) == destClientGuids->end() )
)
)
{
if( SL_LOG.isDebugEnabled() )
{
Expand Down
Expand Up @@ -43,7 +43,7 @@ bool ServiceRegistryRegisterRequestHandler::onStoreMessage(
BrokerSettings::getGuid() : context->getCanonicalSourceId() ) );
registerPayload.setClientInstanceGuid(
( ( context->getContextFlags() & DXL_FLAG_LOCAL ) ?
BrokerSettings::getGuid() : context->getSourceId() ) );
BrokerSettings::getInstanceGuid() : context->getSourceId() ) );
bool isManaged = (context->getContextFlags() & DXL_FLAG_MANAGED) != 0;
registerPayload.setManagedClient( isManaged );
if( !isManaged )
Expand Down
35 changes: 34 additions & 1 deletion src/brokerlib/src/BrokerSettings.cpp
Expand Up @@ -16,6 +16,9 @@ using namespace dxl::broker;
// GUID
string BrokerSettings::sm_guid;

// Instance GUID
string BrokerSettings::sm_instanceGuid;

// Tenant GUID
string BrokerSettings::sm_tenantGuid;

Expand Down Expand Up @@ -151,6 +154,35 @@ const char* BrokerSettings::getGuid( bool throwException )
return sm_guid.c_str();
}

/** {@inheritDoc} */
const char* BrokerSettings::getInstanceGuid( bool throwException )
{
if( sm_instanceGuid.empty() )
{
if( throwException )
{
throw runtime_error( "Broker instance identifier has not been set" );
}
else
{
return NULL;
}
}

return sm_instanceGuid.c_str();
}

/** {@inheritDoc} */
void BrokerSettings::resetInstanceGuid()
{
sm_instanceGuid = sm_guid;
if( !sm_instanceGuid.empty() )
{
sm_instanceGuid.append( ":" );
sm_instanceGuid.append( sm_guid );
}
}

/** {@inheritDoc} */
const char* BrokerSettings::getTenantGuid( bool throwException )
{
Expand Down Expand Up @@ -234,7 +266,8 @@ void BrokerSettings::setValuesFromConfig( const Configuration& config )
string strValue;

// Broker identifier
config.getProperty( "brokerId", sm_guid, "" );
config.getProperty( "brokerId", strValue, "" );
setGuid( strValue.c_str() );

// Logging
config.getProperty( "logFile", sm_logFilePath, "./dxlbroker.log" );
Expand Down
2 changes: 2 additions & 0 deletions src/mqtt-core/src/net.c
Expand Up @@ -453,6 +453,8 @@ int mqtt3_socket_listen(struct _mqtt3_listener *listener)
ssl_options |= SSL_OP_CIPHER_SERVER_PREFERENCE;
#endif
SSL_CTX_set_options(listener->ssl_ctx, ssl_options);
// Disable caching of sessions (DXL)
SSL_CTX_set_session_cache_mode(listener->ssl_ctx, SSL_SESS_CACHE_OFF);

#ifdef SSL_MODE_RELEASE_BUFFERS
/* Use even less memory per SSL connection. */
Expand Down
4 changes: 2 additions & 2 deletions src/version
@@ -1,5 +1,5 @@
SOMAJVER=5
SOMINVER=0
SOMINVER=7
SOSUBMINVER=0
SOBLDNUM=528
SOBLDNUM=107

0 comments on commit 820b6ae

Please sign in to comment.