267 {
269
271 VLOG(0) << "Starting bridge: " << bridgeName;
272
273 if (!bridge.getDisabled()) {
275
276 for (const auto& [fullInstanceName, broker] : bridge.getBrokerMap()) {
277 if (!broker.getDisabled()) {
279
280 VLOG(1) << " Creating broker instance: " << fullInstanceName;
281 VLOG(1) << " Broker prefix: " << broker.getPrefix();
282 VLOG(1) << " Broker client id: " << broker.getClientId();
283 VLOG(1) << " Broker disabled: " << broker.getDisabled();
284 VLOG(1) << " Broker address: " << broker.getAddress();
285 VLOG(1) << " Broker prefix: " << broker.getPrefix();
286 VLOG(1) << " Broker username: " << broker.getUsername();
287 VLOG(1) << " Broker password: " << broker.getPassword();
288 VLOG(1) << " Broker client-id: " << broker.getClientId();
289 VLOG(1) << " Broker clean session: " << broker.getCleanSession();
290 VLOG(1) << " Broker will-topic: " << broker.getWillTopic();
291 VLOG(1) << " Broker will-message: " << broker.getWillMessage();
292 VLOG(1) << " Broker will-qos: " << static_cast<int>(broker.getWillQoS());
293 VLOG(1) << " Broker will-retain: " << broker.getWillRetain();
294 VLOG(1) << " Broker loop prevention: " << broker.getLoopPrevention();
295 VLOG(1) << " Bridge disabled: " << bridge.getDisabled();
296 VLOG(1) << " Bridge prefix: " << bridge.getPrefix();
297 VLOG(1) << " Bridge Transport: " << broker.getTransport();
298 VLOG(1) << " Bridge Protocol: " << broker.getProtocol();
299 VLOG(1) << " Bridge Encryption: " << broker.getEncryption();
300
301 VLOG(1) << " Topics:";
302 const std::list<iot::mqtt::Topic>& topics = broker.getTopics();
303 for (const iot::mqtt::Topic& topic : topics) {
304 VLOG(1) << " " << topic.getName() << ":" << static_cast<uint16_t>(topic.getQoS());
305 }
306
307 const std::string& transport = broker.getTransport();
308 const std::string& protocol = broker.getProtocol();
309 const std::string& encryption = broker.getEncryption();
310
311 if (transport == "stream") {
312 if (protocol == "in") {
313 if (encryption == "legacy") {
314#if defined(CONFIG_MQTTSUITE_BRIDGE_TCP_IPV4)
316 fullInstanceName,
317 [&broker](net::in::stream::legacy::config::ConfigSocketClient* config) {
318 config->setDisableNagleAlgorithm();
319
320 config->Remote::setHost(broker.getAddress()["host"]);
321 config->Remote::setPort(broker.getAddress()["port"]);
322
323 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
324 });
325#else
326 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
327 << "' not supported.";
328#endif
329 } else if (encryption == "tls") {
330#if defined(CONFIG_MQTTSUITE_BRIDGE_TLS_IPV4)
332 fullInstanceName,
333 [&broker](net::in::stream::tls::config::ConfigSocketClient* config) {
334 config->setDisableNagleAlgorithm();
335
336 config->Remote::setHost(broker.getAddress()["host"]);
337 config->Remote::setPort(broker.getAddress()["port"]);
338
339 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
340 });
341#else
342 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
343 << "' not supported.";
344#endif
345 }
346 } else if (protocol == "in6") {
347 if (encryption == "legacy") {
348#if defined(CONFIG_MQTTSUITE_BRIDGE_TCP_IPV6)
350 fullInstanceName,
351 [&broker](net::in6::stream::legacy::config::ConfigSocketClient* config) {
352 config->setDisableNagleAlgorithm();
353
354 config->Remote::setHost(broker.getAddress()["host"]);
355 config->Remote::setPort(broker.getAddress()["port"]);
356
357 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
358 });
359#else
360 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
361 << "' not supported.";
362#endif
363 } else if (encryption == "tls") {
364#if defined(CONFIG_MQTTSUITE_BRIDGE_TLS_IPV6)
366 fullInstanceName,
367 [&broker](net::in6::stream::tls::config::ConfigSocketClient* config) {
368 config->setDisableNagleAlgorithm();
369
370 config->Remote::setHost(broker.getAddress()["host"]);
371 config->Remote::setPort(broker.getAddress()["port"]);
372
373 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
374 });
375#else
376 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
377 << "' not supported.";
378#endif
379 }
380 } else if (protocol == "un") {
381 if (encryption == "legacy") {
382#if defined(CONFIG_MQTTSUITE_BRIDGE_UNIX)
384 fullInstanceName,
385 [&broker](net::un::stream::legacy::config::ConfigSocketClient* config) {
386 config->Remote::setSunPath(broker.getAddress()["host"]);
387
388 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
389 });
390#else
391 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
392 << "' not supported.";
393#endif
394 } else if (encryption == "tls") {
395#if defined(CONFIG_MQTTSUITE_BRIDGE_UNIX_TLS)
397 fullInstanceName,
398 [&broker](net::un::stream::tls::config::ConfigSocketClient* config) {
399 config->Remote::setSunPath(broker.getAddress()["host"]);
400
401 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
402 });
403#else
404 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
405 << "' not supported.";
406#endif
407 }
408 }
409 } else if (transport == "websocket") {
410 if (protocol == "in") {
411 if (encryption == "legacy") {
412#if defined(CONFIG_MQTTSUITE_BRIDGE_TCP_IPV4) && defined(CONFIG_MQTTSUITE_BRIDGE_WS)
414 fullInstanceName,
415 [&broker](net::in::stream::legacy::config::ConfigSocketClient* config) {
416 config->setDisableNagleAlgorithm();
417
418 config->Remote::setHost(broker.getAddress()["host"]);
419 config->Remote::setPort(broker.getAddress()["port"]);
420
421 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
422 });
423#else
424 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
425 << "' not supported.";
426#endif
427 } else if (encryption == "tls") {
428#if defined(CONFIG_MQTTSUITE_BRIDGE_TLS_IPV4) && defined(CONFIG_MQTTSUITE_BRIDGE_WSS)
430 fullInstanceName,
431 [&broker](net::in::stream::tls::config::ConfigSocketClient* config) {
432 config->setDisableNagleAlgorithm();
433
434 config->Remote::setHost(broker.getAddress()["host"]);
435 config->Remote::setPort(broker.getAddress()["port"]);
436
437 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
438 });
439#else
440 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
441 << "' not supported.";
442#endif
443 }
444 } else if (protocol == "in6") {
445 if (encryption == "legacy") {
446#if defined(CONFIG_MQTTSUITE_BRIDGE_TCP_IPV6) && defined(CONFIG_MQTTSUITE_BRIDGE_WS)
448 fullInstanceName,
449 [&broker](net::in6::stream::legacy::config::ConfigSocketClient* config) {
450 config->setDisableNagleAlgorithm();
451
452 config->Remote::setHost(broker.getAddress()["host"]);
453 config->Remote::setPort(broker.getAddress()["port"]);
454
455 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
456 });
457#else
458 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
459 << "' not supported.";
460#endif
461 } else if (encryption == "tls") {
462#if defined(CONFIG_MQTTSUITE_BRIDGE_TLS_IPV6) && defined(CONFIG_MQTTSUITE_BRIDGE_WSS)
464 fullInstanceName,
465 [&broker](net::in6::stream::tls::config::ConfigSocketClient* config) {
466 config->setDisableNagleAlgorithm();
467
468 config->Remote::setHost(broker.getAddress()["host"]);
469 config->Remote::setPort(broker.getAddress()["port"]);
470
471 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
472 });
473#else
474 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
475 << "' not supported.";
476#endif
477 }
478 } else if (protocol == "un") {
479 if (encryption == "legacy") {
480#if defined(CONFIG_MQTTSUITE_BRIDGE_UNIX) && defined(CONFIG_MQTTSUITE_BRIDGE_WS)
482 fullInstanceName,
483 [&broker](net::un::stream::legacy::config::ConfigSocketClient* config) {
484 config->Remote::setSunPath(broker.getAddress()["path"]);
485
486 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
487 });
488#else
489 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
490 << "' not supported.";
491#endif
492 } else if (encryption == "tls") {
493#if defined(CONFIG_MQTTSUITE_BRIDGE_UNIX_TLS) && defined(CONFIG_MQTTSUITE_BRIDGE_WSS)
495 fullInstanceName,
496 [&broker](net::un::stream::tls::config::ConfigSocketClient* config) {
497 config->Remote::setSunPath(broker.getAddress()["path"]);
498
499 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
500 });
501#else
502 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
503 << "' not supported.";
504#endif
505 }
506 }
507 } else {
508 VLOG(1) << " Transport '" << transport << "' not supported.";
509 }
510 } else {
512 }
513 }
514 } else {
516 }
517 }
518}
void brokerConnecting(const std::string &bridgeName, const std::string &instanceName)
void brokerDisabled(const std::string &bridgeName, const std::string &instanceName)
void bridgeDisabled(const std::string &bridgeName)
void bridgeStarting(const std::string &bridgeName)
static SocketClient< mqtt::bridge::SocketContextFactory > startClient(const std::string &instanceName, const std::function< void(typename SocketClient< mqtt::bridge::SocketContextFactory >::Config *)> &configurator)