class ConfigurableUDPSource {

    static void setupServer(Map config) {
        MAX_UDP_DATA = config.get("maxPacketSize") instanceof Integer ? (int) config.get("maxPacketSize") : 1024;
        LISTENING_PORT = config.get("defaultBindPort") instanceof Integer ? (int) config.get("defaultBindPort") :
                3141;
        
        if (config.get("targetServer") instanceof String) {
            targetVantiqServer = (String) config.get("targetServer") ;
        } else {
            throw new RuntimeException("Missing VANTIQ server in config file. Please place in 'targetServer'.");
        }
        
        if (config.get("authToken") instanceof String) {
            authToken = (String) config.get("authToken") ;
        } else {
            throw new RuntimeException("Missing authentication token in config file. Please place in 'authToken'.");
        }

        if (config.get("defaultBindAddress") instanceof String) {
            try {
                String address = (String) config.get("defaultBindAddress");
                LISTENING_ADDRESS = InetAddress.getByName(address);
            } catch (UnknownHostException e) {
                log.error("Given default bind address could not be found. Trying to find local address");
            }
        }
        // There was no valid defaultBindAddress use the default of localhost
        if (LISTENING_ADDRESS == null) {
            try {
                LISTENING_ADDRESS = InetAddress.getLocalHost();
            } catch (UnknownHostException e) {
                throw new RuntimeException("Could not find a valid local address for the default bind address.",e);
            }
        }
    }

}