Browse Source

[trac551] Implement finding correct wildcard node

Michal 'vorner' Vaner 14 years ago
parent
commit
a463f3d1b7
1 changed files with 21 additions and 0 deletions
  1. 21 0
      src/lib/datasrc/memory_datasrc.cc

+ 21 - 0
src/lib/datasrc/memory_datasrc.cc

@@ -387,6 +387,27 @@ struct MemoryZone::MemoryZoneImpl {
                 if (state.zonecut_node_ != NULL) {
                     return (FindResult(DELEGATION, state.rrset_));
                 }
+                /*
+                 * No redirection anywhere. Let's try if it is a wildcard.
+                 */
+                if (node->getFlag(DOMAINFLAG_WILD)) {
+                    Name wildcard(Name("*").concatenate(name.split(1)));
+                    switch (domains_.find(wildcard, &node))
+                    {
+                        case DomainTree::EXACTMATCH:
+                            // This is the node we want.
+                            break;
+                        default:
+                            // This wildcard is not here. It means we want
+                            // something like a.b.wildcard.example.org
+                            // and have only *.wildcard.example.org and
+                            // we don't want that.
+                            return (FindResult(NXDOMAIN, ConstRRsetPtr()));
+                    }
+                    // If we got here, we have the wildcard node. Jump to
+                    // EXACTMATCH
+                    break;
+                }
                 // TODO: we should also cover empty non-terminal cases, which
                 // will require non trivial code and is deferred for later
                 // development.  For now, we regard any partial match that