编程语言
首页 > 编程语言> > LLMNR(链路本地多播名称解析)Java响应器

LLMNR(链路本地多播名称解析)Java响应器

作者:互联网

你知道LLMNR响应者是否存在Java库吗?我找了jmDns库,但它似乎只为Bonjour服务设计.

如果不是,我可以制作UDP响应器,但是存在用于解析/写入DNS记录的库?

解决方法:

我不知道Java LLMNR响应器(*),但是对于解析/写入DNS记录的库的第二个问题,有dnsjava.

Record[] records = new Lookup("stackoverflow.com", Type.A).run();
for (Record record : records) {
    ARecord a = (ARecord) record;
    System.out.println("Host " + a.getName() + " has address " + a.getAddress().getHostAddress());
}
byte[] ip = {(byte)192, (byte)168, (byte)0, (byte)10};
Name zone = Name.fromString("dyn.test.example.");
Name host = Name.fromString("host", zone);
InetAddress address = InetAddress.getByAddress(ip);
ARecord r = new ARecord(host, DClass.IN, 3600, address);
System.out.println(new sun.misc.HexDumpEncoder().encode(r.toWireCanonical()));

(是的,我使用Sun-private API打印十六进制转储,起诉我)

结果:

Host stackoverflow.com. has address 151.101.193.69
Host stackoverflow.com. has address 151.101.129.69
Host stackoverflow.com. has address 151.101.1.69
Host stackoverflow.com. has address 151.101.65.69
0000: 04 68 6F 73 74 03 64 79   6E 04 74 65 73 74 07 65  .host.dyn.test.e
0010: 78 61 6D 70 6C 65 00 00   01 00 01 00 00 0E 10 00  xample..........
0020: 04 C0 A8 00 0A 

(*)或者mdnsjava? (使用dnsjava).无论如何,你可能想要在你接受之前等待赏金到期,以防有人提出完整的答案.此外,通常对图书馆建议的请求被认为是偏离主题的,但这是一个罕见的主题,我发现这很有趣,我希望这不会被关闭.

标签:java,dns,mdns
来源: https://codeday.me/bug/20190711/1429352.html