Search in sources :

Example 1 with Entry

use of io.kamax.mxisd.config.DnsOverwriteConfig.Entry 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)

Aggregations

Entry (io.kamax.mxisd.config.DnsOverwriteConfig.Entry)1 ConfigurationException (io.kamax.mxisd.exception.ConfigurationException)1 InternalServerError (io.kamax.mxisd.exception.InternalServerError)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 URIBuilder (org.apache.http.client.utils.URIBuilder)1