Add support for multiple hostnames for a given node
This will be useful both on a roboRIO and to allow encoding the team
number in the hostnames on the Pis.
Change-Id: I3975785240d7502bc3922c92e9faad4bdadda0d9
diff --git a/aos/configuration.cc b/aos/configuration.cc
index 2d4b867..1ca28ad 100644
--- a/aos/configuration.cc
+++ b/aos/configuration.cc
@@ -362,7 +362,7 @@
// Check that if there is a node list, all the source nodes are filled out and
// valid, and all the destination nodes are valid (and not the source). This
// is a basic consistency check.
- if (result.message().has_nodes()) {
+ if (result.message().has_nodes() && config.message().has_channels()) {
for (const Channel *c : *config.message().channels()) {
CHECK(c->has_source_node()) << ": Channel " << FlatbufferToJson(c)
<< " is missing \"source_node\"";
@@ -597,9 +597,16 @@
const Node *GetNodeFromHostname(const Configuration *config,
std::string_view hostname) {
for (const Node *node : *config->nodes()) {
- if (node->hostname()->string_view() == hostname) {
+ if (node->has_hostname() && node->hostname()->string_view() == hostname) {
return node;
}
+ if (node->has_hostnames()) {
+ for (const auto &candidate : *node->hostnames()) {
+ if (candidate->string_view() == hostname) {
+ return node;
+ }
+ }
+ }
}
return nullptr;
}