Ignore node specific maps when no node is specified

In some contexts, we do a channel lookup without a node.  This is
especially true in LogReader when we are looking to register a mutation
callback for a message.  In this case, we were matching node specific
maps when we shouldn't be.  The end result is that subscribing to `/aos`
was resolving to `/pi2/aos` since that was the first remap found.

Change-Id: I428a01d24c7576ad9588b48ffbfb245d4bd98994
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/configuration.cc b/aos/configuration.cc
index 68984d5..cfc53a5 100644
--- a/aos/configuration.cc
+++ b/aos/configuration.cc
@@ -1149,9 +1149,12 @@
     // Now handle node specific maps.
     const flatbuffers::String *const match_source_node_string =
         match->source_node();
-    if (node != nullptr && match_source_node_string != nullptr &&
-        match_source_node_string->string_view() !=
-            node->name()->string_view()) {
+    if (match_source_node_string != nullptr &&
+        // We have a node and it matches.
+        ((node != nullptr && match_source_node_string->string_view() !=
+                                 node->name()->string_view()) ||
+         // Or we don't have a node so we can't match.
+         node == nullptr)) {
       continue;
     }
 
@@ -1240,9 +1243,12 @@
     // Now handle node specific maps.
     const flatbuffers::String *const match_source_node_string =
         match->source_node();
-    if (node && match_source_node_string &&
-        match_source_node_string->string_view() !=
-            node->name()->string_view()) {
+    if (match_source_node_string &&
+        // We've got a node and it matches.
+        ((node && match_source_node_string->string_view() !=
+                      node->name()->string_view()) ||
+         // Or we don't have a node, so we can't match.
+         node == nullptr)) {
       continue;
     }
 
diff --git a/aos/configuration_test.cc b/aos/configuration_test.cc
index 64b286e..da96402 100644
--- a/aos/configuration_test.cc
+++ b/aos/configuration_test.cc
@@ -240,6 +240,9 @@
   EXPECT_THAT(GetChannel(config, "/batman", ".aos.bar", "app1", pi1),
               aos::testing::FlatbufferEq(ExpectedMultinodeLocation()));
 
+  // Tests that node specific maps get ignored
+  EXPECT_EQ(GetChannel(config, "/batman", ".aos.bar", "", nullptr), nullptr);
+
   // Tests that a root map/rename fails with a node specific map for the wrong
   // node.
   EXPECT_EQ(GetChannel(config, "/batman", ".aos.bar", "app1", pi2), nullptr);