本文整理汇总了Java中de.measite.minidns.record.SRV类的典型用法代码示例。如果您正苦于以下问题:Java SRV类的具体用法?Java SRV怎么用?Java SRV使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SRV类属于de.measite.minidns.record包,在下文中一共展示了SRV类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveSrv
import de.measite.minidns.record.SRV; //导入依赖的package包/类
private static List<Result> resolveSrv(String domain, final boolean directTls) throws IOException {
if (Thread.currentThread().isInterrupted()) {
return Collections.emptyList();
}
DNSName dnsName = DNSName.from((directTls ? DIRECT_TLS_SERVICE : STARTTLS_SERICE)+"._tcp."+domain);
ResolverResult<SRV> result = resolveWithFallback(dnsName,SRV.class);
List<Result> results = new ArrayList<>();
for(SRV record : result.getAnswersOrEmptySet()) {
final boolean addedIPv4 = results.addAll(resolveIp(record,A.class,result.isAuthenticData(),directTls));
results.addAll(resolveIp(record,AAAA.class,result.isAuthenticData(),directTls));
if (!addedIPv4 && !Thread.currentThread().isInterrupted()) {
Result resolverResult = Result.fromRecord(record, directTls);
resolverResult.authenticated = resolverResult.isAuthenticated();
results.add(resolverResult);
}
}
return results;
}
示例2: resolveIp
import de.measite.minidns.record.SRV; //导入依赖的package包/类
private static <D extends InternetAddressRR> List<Result> resolveIp(SRV srv, Class<D> type, boolean authenticated, boolean directTls) {
if (Thread.currentThread().isInterrupted()) {
return Collections.emptyList();
}
List<Result> list = new ArrayList<>();
try {
ResolverResult<D> results = resolveWithFallback(srv.name,type, authenticated);
for (D record : results.getAnswersOrEmptySet()) {
Result resolverResult = Result.fromRecord(srv, directTls);
resolverResult.authenticated = results.isAuthenticData() && authenticated;
resolverResult.ip = record.getInetAddress();
list.add(resolverResult);
}
} catch (Throwable t) {
Log.d(Config.LOGTAG,Resolver.class.getSimpleName()+": error resolving "+type.getSimpleName()+" "+t.getMessage());
}
return list;
}
示例3: resolveSrv
import de.measite.minidns.record.SRV; //导入依赖的package包/类
private static List<Result> resolveSrv(String domain, final boolean directTls) throws IOException {
if (Thread.currentThread().isInterrupted()) {
return Collections.emptyList();
}
DNSName dnsName = DNSName.from((directTls ? DIRECT_TLS_SERVICE : STARTTLS_SERICE) + "._tcp." + domain);
ResolverResult<SRV> result = resolveWithFallback(dnsName, SRV.class);
List<Result> results = new ArrayList<>();
for (SRV record : result.getAnswersOrEmptySet()) {
final boolean addedIPv4 = results.addAll(resolveIp(record, A.class, result.isAuthenticData(), directTls));
results.addAll(resolveIp(record, AAAA.class, result.isAuthenticData(), directTls));
if (!addedIPv4 && !Thread.currentThread().isInterrupted()) {
Result resolverResult = Result.fromRecord(record, directTls);
resolverResult.authenticated = resolverResult.isAuthenticated();
results.add(resolverResult);
}
}
return results;
}
示例4: resolveIp
import de.measite.minidns.record.SRV; //导入依赖的package包/类
private static <D extends InternetAddressRR> List<Result> resolveIp(SRV srv, Class<D> type, boolean authenticated, boolean directTls) {
if (Thread.currentThread().isInterrupted()) {
return Collections.emptyList();
}
List<Result> list = new ArrayList<>();
try {
ResolverResult<D> results = resolveWithFallback(srv.name, type, authenticated);
for (D record : results.getAnswersOrEmptySet()) {
Result resolverResult = Result.fromRecord(srv, directTls);
resolverResult.authenticated = results.isAuthenticData() && authenticated;
resolverResult.ip = record.getInetAddress();
list.add(resolverResult);
}
} catch (Throwable t) {
Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": error resolving " + type.getSimpleName() + " " + t.getMessage());
}
return list;
}
示例5: resolveSrv
import de.measite.minidns.record.SRV; //导入依赖的package包/类
private static List<Result> resolveSrv(String domain, final boolean directTls) throws IOException {
if (Thread.currentThread().isInterrupted()) {
return Collections.emptyList();
}
DNSName dnsName = DNSName.from((directTls ? DIRECT_TLS_SERVICE : STARTTLS_SERICE) + "._tcp." + domain);
ResolverResult<SRV> result = resolveWithFallback(dnsName, SRV.class);
List<Result> results = new ArrayList<>();
for (SRV record : result.getAnswersOrEmptySet()) {
final boolean addedIPv4 = results.addAll(resolveIp(record, A.class, result.isAuthenticData(), directTls));
results.addAll(resolveIp(record, AAAA.class, result.isAuthenticData(), directTls));
if (!addedIPv4 && !Thread.currentThread().isInterrupted()) {
Result resolverResult = Result.fromRecord(record, directTls);
resolverResult.authenticated = resolverResult.isAuthenticated();
results.add(resolverResult);
}
}
return results;
}
示例6: resolveIp
import de.measite.minidns.record.SRV; //导入依赖的package包/类
private static <D extends InternetAddressRR> List<Result> resolveIp(SRV srv, Class<D> type, boolean authenticated, boolean directTls) {
if (Thread.currentThread().isInterrupted()) {
return Collections.emptyList();
}
List<Result> list = new ArrayList<>();
try {
ResolverResult<D> results = resolveWithFallback(srv.name, type, authenticated);
for (D record : results.getAnswersOrEmptySet()) {
Result resolverResult = Result.fromRecord(srv, directTls);
resolverResult.authenticated = results.isAuthenticData() && authenticated;
resolverResult.ip = record.getInetAddress();
list.add(resolverResult);
}
} catch (Throwable t) {
Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": error resolving " + type.getSimpleName() + " " + t.getMessage());
}
return list;
}
示例7: fromRecord
import de.measite.minidns.record.SRV; //导入依赖的package包/类
public static Result fromRecord(SRV srv, boolean directTls) {
Result result = new Result();
result.port = srv.port;
result.hostname = srv.name;
result.directTls = directTls;
result.priority = srv.priority;
return result;
}
示例8: lookupSRVRecords
import de.measite.minidns.record.SRV; //导入依赖的package包/类
@Override
public List<SRVRecord> lookupSRVRecords(String name) {
List<SRVRecord> res = new LinkedList<SRVRecord>();
DNSMessage message = client.query(name, TYPE.SRV, CLASS.IN);
if (message == null) {
return res;
}
for (Record record : message.getAnswers()) {
SRV srv = (SRV) record.getPayload();
res.add(new SRVRecord(srv.getName(), srv.getPort(), srv.getPriority(), srv.getWeight()));
}
return res;
}
示例9: fromRecord
import de.measite.minidns.record.SRV; //导入依赖的package包/类
public static Result fromRecord(SRV srv, boolean directTls) {
Result result = new Result();
result.port = srv.port;
result.hostname = srv.name;
result.directTls = directTls;
result.priority = srv.priority;
return result;
}
示例10: fillSrvMaps
import de.measite.minidns.record.SRV; //导入依赖的package包/类
private static void fillSrvMaps(final String qname, final InetAddress dnsServer, final Map<Integer, List<TlsSrv>> priorities, final Map<String, List<String>> ips4, final Map<String, List<String>> ips6, final boolean tls) throws IOException {
final DNSMessage message = client.query(qname, TYPE.SRV, CLASS.IN, dnsServer.getHostAddress());
for (Record[] rrset : new Record[][] { message.getAnswers(), message.getAdditionalResourceRecords() }) {
for (Record rr : rrset) {
Data d = rr.getPayload();
if (d instanceof SRV && NameUtil.idnEquals(qname, rr.getName())) {
SRV srv = (SRV) d;
if (!priorities.containsKey(srv.getPriority())) {
priorities.put(srv.getPriority(),new ArrayList<TlsSrv>());
}
priorities.get(srv.getPriority()).add(new TlsSrv(srv, tls));
}
if (d instanceof A) {
A a = (A) d;
if (!ips4.containsKey(rr.getName())) {
ips4.put(rr.getName(), new ArrayList<String>());
}
ips4.get(rr.getName()).add(a.toString());
}
if (d instanceof AAAA) {
AAAA aaaa = (AAAA) d;
if (!ips6.containsKey(rr.getName())) {
ips6.put(rr.getName(), new ArrayList<String>());
}
ips6.get(rr.getName()).add("[" + aaaa.toString() + "]");
}
}
}
}
示例11: TlsSrv
import de.measite.minidns.record.SRV; //导入依赖的package包/类
public TlsSrv(SRV srv, boolean tls) {
this.srv = srv;
this.tls = tls;
}
示例12: parse
import de.measite.minidns.record.SRV; //导入依赖的package包/类
/**
* Parse a given record based on the full message data and the current
* stream position.
* @param dis The DataInputStream positioned at the first record byte.
* @param data The full message data.
* @throws IOException In case of malformed replies.
*/
public void parse(DataInputStream dis, byte[] data) throws IOException {
this.name = NameUtil.parse(dis, data);
this.type = TYPE.getType(dis.readUnsignedShort());
int clazzValue = dis.readUnsignedShort();
this.clazz = CLASS.getClass(clazzValue & 0x7fff);
this.unicastQuery = (clazzValue & 0x8000) > 0;
if (this.clazz == null) {
LOGGER.log(Level.FINE, "Unknown class " + clazzValue);
}
this.ttl = (((long)dis.readUnsignedShort()) << 32) +
dis.readUnsignedShort();
int payloadLength = dis.readUnsignedShort();
switch (this.type) {
case SRV:
this.payloadData = new SRV();
break;
case AAAA:
this.payloadData = new AAAA();
break;
case A:
this.payloadData = new A();
break;
case NS:
this.payloadData = new NS();
break;
case CNAME:
this.payloadData = new CNAME();
break;
case PTR:
this.payloadData = new PTR();
break;
case TXT:
this.payloadData = new TXT();
break;
default:
LOGGER.log(Level.FINE, "Unparsed type " + type);
this.payloadData = null;
for (int i = 0; i < payloadLength; i++) {
dis.readByte();
}
break;
}
if (this.payloadData != null) {
this.payloadData.parse(dis, data, payloadLength);
}
}