Beispiel #1
0
bool TSrvIfaceMgr::delFQDN(int iface, SPtr<TIPv6Addr> dnsAddr, SPtr<TIPv6Addr> addr,
                           const std::string& name) {

    bool success = true;

#ifndef MOD_SRV_DISABLE_DNSUPDATE
    SPtr<TSrvCfgIface> cfgIface = SrvCfgMgr().getIfaceByID(iface);
    if (!cfgIface) {
        Log(Error) << "Unable find cfgIface with ifindex=" << iface << ", DDNS failed."
                   << LogEnd;
        return false;
    }

    DnsUpdateModeCfg FQDNMode = static_cast<DnsUpdateModeCfg>(cfgIface->getFQDNMode());

    SPtr<TSIGKey> key = SrvCfgMgr().getKey();

    char zoneroot[128];
    doRevDnsZoneRoot(addr->getAddr(), zoneroot, cfgIface->getRevDNSZoneRootLength());

    // that's ugly but required. Otherwise we would have to include CfgMgr.h in DNSUpdate.h
    // and that would include both poslib and Dibbler headers in one place. Universe would
    // implode then.
    TCfgMgr::DNSUpdateProtocol proto = SrvCfgMgr().getDDNSProtocol();
    DNSUpdate::DnsUpdateProtocol proto2 = DNSUpdate::DNSUPDATE_TCP;
    if (proto == TCfgMgr::DNSUPDATE_UDP)
        proto2 = DNSUpdate::DNSUPDATE_UDP;
    if (proto == TCfgMgr::DNSUPDATE_ANY)
        proto2 = DNSUpdate::DNSUPDATE_ANY;
    unsigned int timeout = SrvCfgMgr().getDDNSTimeout();

    // FQDNMode: 0 = NONE, 1 = PTR only, 2 = BOTH PTR and AAAA
    if ((FQDNMode == DNSUPDATE_MODE_PTR) || (FQDNMode == DNSUPDATE_MODE_BOTH)) {
        /* PTR cleanup */
        // Log(Notice) << "FQDN: Attempting to clean up PTR record in DNS Server "
        //            << dnsAddr->getPlain() << ", IP = " << addr->getPlain()
        //            << " and FQDN=" << name << LogEnd;
        DNSUpdate *act = new DNSUpdate(dnsAddr->getPlain(), zoneroot, name, addr->getPlain(),
                                       DNSUPDATE_PTR_CLEANUP, proto2);

	if (key) {
	    act->setTSIG(key->Name_, key->getPackedData(), key->getAlgorithmText(),
			 key->Fudge_);
	}

        int result = act->run(timeout);
        act->showResult(result);
        delete act;
        success = (result == DNSUPDATE_SUCCESS);
    }

    if (FQDNMode == DNSUPDATE_MODE_BOTH) {
        /* AAAA Cleanup */
        //Log(Notice) << "FQDN: Attempting to clean up AAAA and PTR record in DNS Server "
        //            << dnsAddr->getPlain() << ", IP = " << addr->getPlain()
        //            << " and FQDN=" << name << LogEnd;

        DNSUpdate *act = new DNSUpdate(dnsAddr->getPlain(), "", name, addr->getPlain(),
                                       DNSUPDATE_AAAA_CLEANUP, proto2);

	if (key) {
	    act->setTSIG(key->Name_, key->getPackedData(), key->getAlgorithmText(),
			 key->Fudge_);
	}

        int result = act->run(timeout);
        act->showResult(result);
        delete act;

        success = (result == DNSUPDATE_SUCCESS) && success;

    }
#else
    Log(Info) << "DNSUpdate not compiled in. Pretending success." << LogEnd;
#endif

    return success;

}
Beispiel #2
0
bool TSrvIfaceMgr::addFQDN(int iface, SPtr<TIPv6Addr> dnsAddr, SPtr<TIPv6Addr> addr,
                           const std::string& name) {

    bool success = true;

#ifndef MOD_SRV_DISABLE_DNSUPDATE
    SPtr<TSrvCfgIface> cfgIface = SrvCfgMgr().getIfaceByID(iface);
    if (!cfgIface) {
        Log(Error) << "Unable find cfgIface with ifindex=" << iface << ", DDNS failed."
                   << LogEnd;
        return false;
    }

    DnsUpdateModeCfg FQDNMode = static_cast<DnsUpdateModeCfg>(cfgIface->getFQDNMode());

    SPtr<TSIGKey> key = SrvCfgMgr().getKey();

    TCfgMgr::DNSUpdateProtocol proto = SrvCfgMgr().getDDNSProtocol();
    DNSUpdate::DnsUpdateProtocol proto2 = DNSUpdate::DNSUPDATE_TCP;
    if (proto == TCfgMgr::DNSUPDATE_UDP)
        proto2 = DNSUpdate::DNSUPDATE_UDP;
    if (proto == TCfgMgr::DNSUPDATE_ANY)
        proto2 = DNSUpdate::DNSUPDATE_ANY;
    unsigned int timeout = SrvCfgMgr().getDDNSTimeout();

    // FQDNMode: 0 = NONE, 1 = PTR only, 2 = BOTH PTR and AAAA
    if ((FQDNMode == DNSUPDATE_MODE_PTR) || (FQDNMode == DNSUPDATE_MODE_BOTH)) {
        //Test for DNS update
        char zoneroot[128];
        doRevDnsZoneRoot(addr->getAddr(), zoneroot, cfgIface->getRevDNSZoneRootLength());
        /* add PTR only */
        DnsUpdateResult result = DNSUPDATE_SKIP;
        DNSUpdate *act = new DNSUpdate(dnsAddr->getPlain(), zoneroot, name, addr->getPlain(),
                                       DNSUPDATE_PTR, proto2);
	
	if (key) {
	    act->setTSIG(key->Name_, key->getPackedData(), key->getAlgorithmText(),
			 key->Fudge_);
	}

        result = act->run(timeout);
        act->showResult(result);
        delete act;

        success = (result == DNSUPDATE_SUCCESS);
    }

    if (FQDNMode == DNSUPDATE_MODE_BOTH) {
        DnsUpdateResult result = DNSUPDATE_SKIP;
        DNSUpdate *act = new DNSUpdate(dnsAddr->getPlain(), "", name,
                                       addr->getPlain(),
                                       DNSUPDATE_AAAA, proto2);

	if (key) {
	    act->setTSIG(key->Name_, key->getPackedData(), key->getAlgorithmText(),
			 key->Fudge_);
	}

        result = act->run(timeout);
        act->showResult(result);
        delete act;
        success = (result == DNSUPDATE_SUCCESS) && success;
    }
#else
    Log(Info) << "DNSUpdate not compiled in. Pretending success." << LogEnd;
#endif

    return success;
}