dns使用xbill在Java中解析SRV记录。正确的查询字符串?
我正在尝试使用org获取SRV记录。xbill。我的域的java DNS
我目前在我的域(例如:example.com)上有以下设置:
记录:
HostName: ramuh
IP Address/URL: 1.1.1.1 // the public ip of my computer
Record Type: A (Address)
我创建了以下SRV记录:
_SERVICE : _rdp
_PROTOCOL : _tcp
PRIORITIY : 1
WEIGHT : 1
PORT : 5000
TARGET : ramuh.example.com
我正在使用的查询字符串:
_rdp._tcp.ramuh.example.com
我希望能够获得ramuh的SRV记录。实例com
所以我可以建立:
拉姆。实例com:5000(然后自动转换为1.1.1.1:5000,不是从我这边)
当前使用此代码(s是需要返回SRV记录列表的输入域):
String s = "ramuh.example.com"; // the inputted string, I need to obtain the Port to be added to this
ArrayList<String> ret = new ArrayList<String>();
String query = "_rdp._tcp." + s;
try{
Record[] records = new Lookup(query,Type.SRV).run(); // returning null
if(records!= null && records.length>0) {
for(Record r : records){
SRVRecord srv = (SRVRecord)r;
String hostname = srv.getTarget().toString().replaceFirst("\\.$","");
int port = srv.getPort();
ret.add(hostname+":"+port);
}
return ret;
}
else{
return null;
}
}catch(TextParseException e){
return null;
}
new Lookup()返回null,因此我假设传递的查询字符串无效。我需要对查询字符串或SRV记录进行哪些更改才能使其正常工作
使用namescape作为域
谢谢
# 1 楼答案
查询不必与SRV记录中的目标匹配,而是与您正在使用的域匹配
所以查询应该是
_rdp._tcp.example.com
这可以通过在MXToolbox's SRV lookup上进行测试来验证,但是使用org将不起作用。xbill。DSN。查找
查找问题已简化为另一个问题:23935847