Search in sources :

Example 1 with DNSRecord

use of de.dytanic.cloudnet.cloudflare.util.DNSRecord in project CloudNet by Dytanic.

the class CloudFlareService method bootstrap.

@Deprecated
public boolean bootstrap(Map<String, SimpledWrapperInfo> wrapperInfoMap, Map<String, ProxyGroup> groups, CloudFlareDatabase cloudFlareDatabase) {
    if (!cloudFlareConfig.isEnabled())
        return false;
    for (String id : cloudFlareDatabase.getAndRemove()) this.deleteRecord(id);
    for (String key : cloudFlareDatabase.getAll()) {
        if (!key.equalsIgnoreCase(Database.UNIQUE_NAME_KEY) && !wrapperInfoMap.containsKey(key)) {
            deleteRecord(cloudFlareDatabase.getResponse(key).getId());
        }
    }
    for (CloudFlareProxyGroup cloudFlareProxyGroup : cloudFlareConfig.getGroups()) {
        ProxyGroup proxyGroup = groups.get(cloudFlareProxyGroup.getName());
        for (String wrapper : proxyGroup.getWrapper()) {
            if (!cloudFlareDatabase.contains(wrapper)) {
                String host = wrapperInfoMap.get(wrapper).getHostName();
                DNSRecord dnsRecord = new DefaultDNSRecord(DNSType.A, wrapper + "." + cloudFlareConfig.getDomainName(), host, new Document().obj());
                if (!ipARecords.containsKey(wrapper)) {
                    PostResponse postResponse = this.createRecord(dnsRecord);
                    ipARecords.put(wrapper, postResponse);
                    cloudFlareDatabase.putPostResponse(wrapper, postResponse);
                    NetworkUtils.sleepUninterruptedly(400);
                }
            }
        }
    }
    return true;
}
Also used : ProxyGroup(de.dytanic.cloudnet.lib.server.ProxyGroup) DNSRecord(de.dytanic.cloudnet.cloudflare.util.DNSRecord) DefaultDNSRecord(de.dytanic.cloudnet.cloudflare.util.DefaultDNSRecord) DefaultDNSRecord(de.dytanic.cloudnet.cloudflare.util.DefaultDNSRecord) Document(de.dytanic.cloudnet.lib.utility.document.Document)

Aggregations

DNSRecord (de.dytanic.cloudnet.cloudflare.util.DNSRecord)1 DefaultDNSRecord (de.dytanic.cloudnet.cloudflare.util.DefaultDNSRecord)1 ProxyGroup (de.dytanic.cloudnet.lib.server.ProxyGroup)1 Document (de.dytanic.cloudnet.lib.utility.document.Document)1