package dns;
import org.xbill.DNS.MXRecord;
import org.xbill.DNS.Record;
public class ResolveDns {
private String domain;
public ResolveDns(String domain){
this.domain = domain;
}
// mx查询
void mxQuery(){
Record[] records;
records = new DomainNameResolve().domainNameResolve(domain, 15);
for (Record mx: records){
System.out.println(mx);
aQuery(mx); // 查询A记录
}
}
// A记录查询
void aQuery(Record mx){
MXRecord mxRecord = (MXRecord)mx;
Record[] aquery = new DomainNameResolve().domainNameResolve(mxRecord.getTarget().toString(), 1);
for (Record ipaddress: aquery){
System.out.println(ipaddress);
}
}
// txt查询
void txtQuery(){
Record[] records;
records = new DomainNameResolve().domainNameResolve(domain, 16);
for(Record spf: records){
System.out.println(spf);
}
}
}