Commit 2ec00224 authored by jan.koester's avatar jan.koester
Browse files

test

parent 8a795385
Loading
Loading
Loading
Loading
Loading
+14 −1
Changes for plugin/dns/dns.cpp: 14 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -24,6 +24,19 @@ namespace fenrirds {
namespace dnsz = dsdb::dns;

namespace {
    /* a GUID in its text form: the first three fields are little endian */
    std::string guidText(const uint8_t g[16]) {
        static const int order[16] = {3,2,1,0, 5,4, 7,6, 8,9, 10,11,12,13,14,15};
        static const char *hx = "0123456789abcdef";
        std::string o;
        for (int i = 0; i < 16; ++i) {
            if (i == 4 || i == 6 || i == 8 || i == 10) o += '-';
            o += hx[g[order[i]] >> 4];
            o += hx[g[order[i]] & 15];
        }
        return o;
    }

    std::string lower(std::string s) {
        std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) { return std::tolower(c); });
        while (!s.empty() && s.back() == '.')
@@ -326,7 +339,7 @@ void DnsServer::rebuild() {
            srv("_kpasswd._udp." + d, 464);
            /* the locator asks by domain GUID when it knows it (Netlogon does) */
            rpc::DomainInfo di = rpc::primaryDomain();
            if (di.ok && dsdb::lower(di.dnsName) == dsdb::lower(d))
            if (di.ok && lower(di.dnsName) == lower(d))
                srv("_ldap._tcp." + guidText(di.guid) + ".domains._msdcs." + d, 389);
        }
        /* the DC's PTR in a reverse zone that covers its address */