Search in sources :

Example 1 with ConfigurationException

use of io.kamax.mxisd.exception.ConfigurationException in project mxisd by kamax-io.

the class ClientDnsOverwrite method transform.

public URIBuilder transform(URI initial) {
    URIBuilder builder = new URIBuilder(initial);
    Entry mapping = mappings.get(initial.getHost());
    if (mapping == null) {
        throw new InternalServerError("No DNS client override for " + initial.getHost());
    }
    try {
        URL target = new URL(mapping.getValue());
        builder.setScheme(target.getProtocol());
        builder.setHost(target.getHost());
        if (target.getPort() != -1) {
            builder.setPort(target.getPort());
        }
        return builder;
    } catch (MalformedURLException e) {
        log.warn("Skipping DNS overwrite entry {} due to invalid value [{}]: {}", mapping.getName(), mapping.getValue(), e.getMessage());
        throw new ConfigurationException("Invalid DNS overwrite entry in homeserver client: " + mapping.getName(), e.getMessage());
    }
}
Also used : Entry(io.kamax.mxisd.config.DnsOverwriteConfig.Entry) MalformedURLException(java.net.MalformedURLException) ConfigurationException(io.kamax.mxisd.exception.ConfigurationException) InternalServerError(io.kamax.mxisd.exception.InternalServerError) URL(java.net.URL) URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 2 with ConfigurationException

use of io.kamax.mxisd.exception.ConfigurationException in project mxisd by kamax-io.

the class RecursivePriorityLookupStrategy method build.

@PostConstruct
private void build() throws UnknownHostException {
    try {
        log.info("Found {} providers", providers.size());
        providers.forEach(p -> log.info("\t- {}", p.getClass().getName()));
        providers.sort((o1, o2) -> Integer.compare(o2.getPriority(), o1.getPriority()));
        log.info("Recursive lookup enabled: {}", cfg.isEnabled());
        for (String cidr : cfg.getAllowedCidr()) {
            log.info("{} is allowed for recursion", cidr);
            allowedCidr.add(new CIDRUtils(cidr));
        }
    } catch (UnknownHostException e) {
        throw new ConfigurationException("lookup.recursive.allowedCidrs", "Allowed CIDRs");
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) CIDRUtils(edazdarevic.commons.net.CIDRUtils) ConfigurationException(io.kamax.mxisd.exception.ConfigurationException) PostConstruct(javax.annotation.PostConstruct)

Aggregations

ConfigurationException (io.kamax.mxisd.exception.ConfigurationException)2 CIDRUtils (edazdarevic.commons.net.CIDRUtils)1 Entry (io.kamax.mxisd.config.DnsOverwriteConfig.Entry)1 InternalServerError (io.kamax.mxisd.exception.InternalServerError)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 UnknownHostException (java.net.UnknownHostException)1 PostConstruct (javax.annotation.PostConstruct)1 URIBuilder (org.apache.http.client.utils.URIBuilder)1