Re: Expose DNS Servers via public API

2017-03-30 Thread Norman Maurer
Nice!


This works :)
Norman
> On 30. Mar 2017, at 17:27, Alan Bateman  wrote:
> 
> On 30/03/2017 15:59, Norman Maurer wrote:
> 
>> Thats why I tried to kick-off the topic :) Thanks for the quick reply btw…. 
>> So is this list the right place for this discussion ?
>> 
> I just checked the docs for the JNDI-DNS provider [1] and it documents that 
> the provider updates the java.naming.provider.url property with the 
> configuration when it isn't initially specified. So I think this will do what 
> you want:
> 
> Hashtable env = new Hashtable<>();
> env.put(Context.INITIAL_CONTEXT_FACTORY, 
> "com.sun.jndi.dns.DnsContextFactory");
> env.put("java.naming.provider.url", "dns://");
> DirContext ctx = new InitialDirContext(env);
> String dnsUrls = (String) 
> ctx.getEnvironment().get("java.naming.provider.url"));
> 
> -Alan
> 
> [1] http://docs.oracle.com/javase/8/docs/technotes/guides/jndi/jndi-dns.html



Re: Expose DNS Servers via public API

2017-03-30 Thread Alan Bateman

On 30/03/2017 15:59, Norman Maurer wrote:

Thats why I tried to kick-off the topic :) Thanks for the quick reply 
btw…. So is this list the right place for this discussion ?


I just checked the docs for the JNDI-DNS provider [1] and it documents 
that the provider updates the java.naming.provider.url property with the 
configuration when it isn't initially specified. So I think this will do 
what you want:


Hashtable env = new Hashtable<>();
env.put(Context.INITIAL_CONTEXT_FACTORY, 
"com.sun.jndi.dns.DnsContextFactory");

env.put("java.naming.provider.url", "dns://");
DirContext ctx = new InitialDirContext(env);
String dnsUrls = (String) 
ctx.getEnvironment().get("java.naming.provider.url"));


-Alan

[1] http://docs.oracle.com/javase/8/docs/technotes/guides/jndi/jndi-dns.html


Re: Expose DNS Servers via public API

2017-03-30 Thread Norman Maurer

> On 30. Mar 2017, at 16:58, Alan Bateman  wrote:
> 
> On 30/03/2017 15:36, Norman Maurer wrote:
>> Hi there,
>> 
>> I am not sure if this is the correct list for the question but as relate to 
>> network I will just try. If its the wrong list please tell me which one 
>> would be better fitted.
>> 
>> Is there reason why not expose the DNS Servers configured on a system. These 
>> are exposed in sun.net.dns.ResolverConfiguration but not exposed in any 
>> public way. Be able to access these would help people that want to do a 
>> custom dns lookup (for example non-blocking) like what we do in netty.
>> If this is something that would be considered I can come up with a patch for 
>> it.
>> 
> One could imagine introducing an API in java.net that exposes more of the 
> networking configuration but I think would require debate as to whether it's 
> the right thing to do or not (esp. as the existing networking APIs are 
> abstracted from whether resolution is done via DNS, host files, ..).
> 
> An alternative might to see if it is exposed by the JNDI-DNS provider (the 
> primary user of ResolverConfiguration and the reason it was created). It 
> might already be exposed in the environment.
> 
> -Alan

Thats why I tried to kick-off the topic :) Thanks for the quick reply btw…. So 
is this list the right place for this discussion ?



Re: Expose DNS Servers via public API

2017-03-30 Thread Alan Bateman

On 30/03/2017 15:36, Norman Maurer wrote:


Hi there,

I am not sure if this is the correct list for the question but as 
relate to network I will just try. If its the wrong list please tell 
me which one would be better fitted.


Is there reason why not expose the DNS Servers configured on a system. 
These are exposed in sun.net.dns.ResolverConfiguration but not exposed 
in any public way. Be able to access these would help people that want 
to do a custom dns lookup (for example non-blocking) like what we do 
in netty.
If this is something that would be considered I can come up with a 
patch for it.


One could imagine introducing an API in java.net that exposes more of 
the networking configuration but I think would require debate as to 
whether it's the right thing to do or not (esp. as the existing 
networking APIs are abstracted from whether resolution is done via DNS, 
host files, ..).


An alternative might to see if it is exposed by the JNDI-DNS provider 
(the primary user of ResolverConfiguration and the reason it was 
created). It might already be exposed in the environment.


-Alan


Expose DNS Servers via public API

2017-03-30 Thread Norman Maurer
Hi there,

I am not sure if this is the correct list for the question but as relate to 
network I will just try. If its the wrong list please tell me which one would 
be better fitted.

Is there reason why not expose the DNS Servers configured on a system. These 
are exposed in sun.net.dns.ResolverConfiguration but not exposed in any public 
way. Be able to access these would help people that want to do a custom dns 
lookup (for example non-blocking) like what we do in netty.
If this is something that would be considered I can come up with a patch for it.

Bye,
Norman