307 {
309
311 VLOG(0) << "Starting bridge: " << bridgeName;
312
313 if (!bridge.getDisabled()) {
315
316 for (const auto& [fullInstanceName, broker] : bridge.getBrokerMap()) {
317 if (!broker.getDisabled()) {
319
320 VLOG(1) << " Creating broker instance: " << fullInstanceName;
321 VLOG(1) << " Broker prefix: " << broker.getPrefix();
322 VLOG(1) << " Broker client id: " << broker.getClientId();
323 VLOG(1) << " Broker disabled: " << broker.getDisabled();
324 VLOG(1) << " Broker address: " << broker.getAddress();
325 VLOG(1) << " Broker prefix: " << broker.getPrefix();
326 VLOG(1) << " Broker username: " << broker.getUsername();
327 VLOG(1) << " Broker password: " << broker.getPassword();
328 VLOG(1) << " Broker client-id: " << broker.getClientId();
329 VLOG(1) << " Broker clean session: " << broker.getCleanSession();
330 VLOG(1) << " Broker will-topic: " << broker.getWillTopic();
331 VLOG(1) << " Broker will-message: " << broker.getWillMessage();
332 VLOG(1) << " Broker will-qos: " << static_cast<int>(broker.getWillQoS());
333 VLOG(1) << " Broker will-retain: " << broker.getWillRetain();
334 VLOG(1) << " Broker loop prevention: " << broker.getLoopPrevention();
335 VLOG(1) << " Bridge disabled: " << bridge.getDisabled();
336 VLOG(1) << " Bridge prefix: " << bridge.getPrefix();
337 VLOG(1) << " Bridge Transport: " << broker.getTransport();
338 VLOG(1) << " Bridge Protocol: " << broker.getProtocol();
339 VLOG(1) << " Bridge Encryption: " << broker.getEncryption();
340
341 VLOG(1) << " Topics:";
342 const std::list<iot::mqtt::Topic>& topics = broker.getTopics();
343 for (const iot::mqtt::Topic& topic : topics) {
344 VLOG(1) << " " << topic.getName() << ":" << static_cast<uint16_t>(topic.getQoS());
345 }
346
347 const std::string& transport = broker.getTransport();
348 const std::string& protocol = broker.getProtocol();
349 const std::string& encryption = broker.getEncryption();
350
351 if (transport == "stream") {
352 if (protocol == "in") {
353 if (encryption == "legacy") {
354#if defined(CONFIG_MQTTSUITE_BRIDGE_TCP_IPV4)
356 fullInstanceName,
357 [&broker](net::in::stream::legacy::config::ConfigSocketClient* config) {
358 config->setDisableNagleAlgorithm();
359
360 config->Remote::setHost(broker.getAddress()["host"]);
361 config->Remote::setPort(broker.getAddress()["port"]);
362
363 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
364 });
365#else
366 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
367 << "' not supported.";
368#endif
369 } else if (encryption == "tls") {
370#if defined(CONFIG_MQTTSUITE_BRIDGE_TLS_IPV4)
372 fullInstanceName,
373 [&broker](net::in::stream::tls::config::ConfigSocketClient* config) {
374 config->setDisableNagleAlgorithm();
375
376 config->Remote::setHost(broker.getAddress()["host"]);
377 config->Remote::setPort(broker.getAddress()["port"]);
378
379 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
380 });
381#else
382 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
383 << "' not supported.";
384#endif
385 }
386 } else if (protocol == "in6") {
387 if (encryption == "legacy") {
388#if defined(CONFIG_MQTTSUITE_BRIDGE_TCP_IPV6)
390 fullInstanceName,
391 [&broker](net::in6::stream::legacy::config::ConfigSocketClient* config) {
392 config->setDisableNagleAlgorithm();
393
394 config->Remote::setHost(broker.getAddress()["host"]);
395 config->Remote::setPort(broker.getAddress()["port"]);
396
397 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
398 });
399#else
400 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
401 << "' not supported.";
402#endif
403 } else if (encryption == "tls") {
404#if defined(CONFIG_MQTTSUITE_BRIDGE_TLS_IPV6)
406 fullInstanceName,
407 [&broker](net::in6::stream::tls::config::ConfigSocketClient* config) {
408 config->setDisableNagleAlgorithm();
409
410 config->Remote::setHost(broker.getAddress()["host"]);
411 config->Remote::setPort(broker.getAddress()["port"]);
412
413 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
414 });
415#else
416 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
417 << "' not supported.";
418#endif
419 }
420 } else if (protocol == "un") {
421 if (encryption == "legacy") {
422#if defined(CONFIG_MQTTSUITE_BRIDGE_UNIX)
424 fullInstanceName,
425 [&broker](net::un::stream::legacy::config::ConfigSocketClient* config) {
426 config->Remote::setSunPath(broker.getAddress()["host"]);
427
428 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
429 });
430#else
431 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
432 << "' not supported.";
433#endif
434 } else if (encryption == "tls") {
435#if defined(CONFIG_MQTTSUITE_BRIDGE_UNIX_TLS)
437 fullInstanceName,
438 [&broker](net::un::stream::tls::config::ConfigSocketClient* config) {
439 config->Remote::setSunPath(broker.getAddress()["host"]);
440
441 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
442 });
443#else
444 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
445 << "' not supported.";
446#endif
447 }
448 }
449 } else if (transport == "websocket") {
450 if (protocol == "in") {
451 if (encryption == "legacy") {
452#if defined(CONFIG_MQTTSUITE_BRIDGE_TCP_IPV4) && defined(CONFIG_MQTTSUITE_BRIDGE_WS)
454 fullInstanceName,
455 [&broker](net::in::stream::legacy::config::ConfigSocketClient* config) {
456 config->setDisableNagleAlgorithm();
457
458 config->Remote::setHost(broker.getAddress()["host"]);
459 config->Remote::setPort(broker.getAddress()["port"]);
460
461 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
462 });
463#else
464 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
465 << "' not supported.";
466#endif
467 } else if (encryption == "tls") {
468#if defined(CONFIG_MQTTSUITE_BRIDGE_TLS_IPV4) && defined(CONFIG_MQTTSUITE_BRIDGE_WSS)
470 fullInstanceName,
471 [&broker](net::in::stream::tls::config::ConfigSocketClient* config) {
472 config->setDisableNagleAlgorithm();
473
474 config->Remote::setHost(broker.getAddress()["host"]);
475 config->Remote::setPort(broker.getAddress()["port"]);
476
477 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
478 });
479#else
480 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
481 << "' not supported.";
482#endif
483 }
484 } else if (protocol == "in6") {
485 if (encryption == "legacy") {
486#if defined(CONFIG_MQTTSUITE_BRIDGE_TCP_IPV6) && defined(CONFIG_MQTTSUITE_BRIDGE_WS)
488 fullInstanceName,
489 [&broker](net::in6::stream::legacy::config::ConfigSocketClient* config) {
490 config->setDisableNagleAlgorithm();
491
492 config->Remote::setHost(broker.getAddress()["host"]);
493 config->Remote::setPort(broker.getAddress()["port"]);
494
495 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
496 });
497#else
498 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
499 << "' not supported.";
500#endif
501 } else if (encryption == "tls") {
502#if defined(CONFIG_MQTTSUITE_BRIDGE_TLS_IPV6) && defined(CONFIG_MQTTSUITE_BRIDGE_WSS)
504 fullInstanceName,
505 [&broker](net::in6::stream::tls::config::ConfigSocketClient* config) {
506 config->setDisableNagleAlgorithm();
507
508 config->Remote::setHost(broker.getAddress()["host"]);
509 config->Remote::setPort(broker.getAddress()["port"]);
510
511 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
512 });
513#else
514 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
515 << "' not supported.";
516#endif
517 }
518 } else if (protocol == "un") {
519 if (encryption == "legacy") {
520#if defined(CONFIG_MQTTSUITE_BRIDGE_UNIX) && defined(CONFIG_MQTTSUITE_BRIDGE_WS)
522 fullInstanceName,
523 [&broker](net::un::stream::legacy::config::ConfigSocketClient* config) {
524 config->Remote::setSunPath(broker.getAddress()["path"]);
525
526 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
527 });
528#else
529 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
530 << "' not supported.";
531#endif
532 } else if (encryption == "tls") {
533#if defined(CONFIG_MQTTSUITE_BRIDGE_UNIX_TLS) && defined(CONFIG_MQTTSUITE_BRIDGE_WSS)
535 fullInstanceName,
536 [&broker](net::un::stream::tls::config::ConfigSocketClient* config) {
537 config->Remote::setSunPath(broker.getAddress()["path"]);
538
539 config->setDisabled(broker.getDisabled() || broker.getBridge().getDisabled());
540 });
541#else
542 VLOG(1) << " Transport '" << transport << "', protocol '" << protocol << "', encryption '" << encryption
543 << "' not supported.";
544#endif
545 }
546 }
547 } else {
548 VLOG(1) << " Transport '" << transport << "' not supported.";
549 }
550 } else {
552 }
553 }
554 } else {
556 }
557 }
558}
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)