diff options
author | Eddy Pedroni <epedroni@pm.me> | 2025-08-21 14:24:55 +0200 |
---|---|---|
committer | Eddy Pedroni <epedroni@pm.me> | 2025-08-21 14:24:55 +0200 |
commit | 7f1179f01ed200240856e35038da0993f84ec312 (patch) | |
tree | 1a9ea6442c70183f2df06198ceab90a5f71b520e /daemon/src/config.cpp | |
parent | ce3b2eb271aa68fef345701188fc9f77abee99c8 (diff) |
More robust config parsing
Diffstat (limited to 'daemon/src/config.cpp')
-rw-r--r-- | daemon/src/config.cpp | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/daemon/src/config.cpp b/daemon/src/config.cpp index b88fd0f..b711d52 100644 --- a/daemon/src/config.cpp +++ b/daemon/src/config.cpp @@ -87,13 +87,24 @@ add_to_routes(Device_Id const & from_device, Route_Table & rt, toml::table & rou { for (auto&& [name, mt] : string2type) { - rt[from_device][mt].push_back(cm.get_sender(to_device)); + if (auto sender = cm.get_sender(to_device)) + { + rt[from_device][mt].push_back(sender.value()); + } } } else { - Message_Type mt = string2type.at(type.as_string()->get()); - rt[from_device][mt].push_back(cm.get_sender(to_device)); + if (!string2type.contains(type.as_string()->get())) + { + continue; + } + + if (auto sender = cm.get_sender(to_device)) + { + Message_Type const mt = string2type.at(type.as_string()->get()); + rt[from_device][mt].push_back(sender.value()); + } } } } @@ -113,6 +124,10 @@ add_type_routes(Device_Map const & device_map, Device_Id const & from_device, Ro } for (auto & device : *devices) { + if (!string2type.contains(type)) + { + continue; + } Message_Type mt = string2type.at(type); std::string to_device = device.as_string()->get(); if (to_device == "all") @@ -120,12 +135,18 @@ add_type_routes(Device_Map const & device_map, Device_Id const & from_device, Ro for (auto&& [name, id] : device_map) { if (id == from_device) continue; - rt[from_device][mt].push_back(cm.get_sender(id)); + if (auto sender = cm.get_sender(id)) + { + rt[from_device][mt].push_back(sender.value()); + } } } else { - rt[from_device][mt].push_back(cm.get_sender(to_device)); + if (auto sender = cm.get_sender(to_device)) + { + rt[from_device][mt].push_back(sender.value()); + } } } } |