class DnsUtil {

	public static Optional<Integer> getPort(String server) throws InterruptedException, ExecutionException {
		Objects.requireNonNull(server);

		DnsQuestion question = new DefaultDnsQuestion(server, DnsRecordType.SRV);
		DnsResponse response = RESOLVER.query(question).get().content();
		DnsRawRecord record = response.recordAt(DnsSection.ANSWER);
		if (record == null)
			return Optional.empty();

		ByteBuf buffer = record.content();

		// Skip priority
		buffer.readShort();

		// Skip weight
		buffer.readShort();

		// Read port
		int port = buffer.readShort();
		if (!ValidationUtil.port(port))
			return Optional.empty();

		return Optional.of(port);
	}

	private  DnsUtil();

}