本文整理汇总了Java中javax.jmdns.impl.DNSRecord类的典型用法代码示例。如果您正苦于以下问题:Java DNSRecord类的具体用法?Java DNSRecord怎么用?Java DNSRecord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DNSRecord类属于javax.jmdns.impl包,在下文中一共展示了DNSRecord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addAnswers
import javax.jmdns.impl.DNSRecord; //导入依赖的package包/类
@Override
protected DNSOutgoing addAnswers(DNSOutgoing out) throws IOException
{
DNSOutgoing newOut = out;
if (!_info.hasData())
{
long now = System.currentTimeMillis();
newOut = this.addAnswer(newOut, (DNSRecord) this.getDns().getCache().getDNSEntry(_info.getQualifiedName(), DNSRecordType.TYPE_SRV, DNSRecordClass.CLASS_IN), now);
newOut = this.addAnswer(newOut, (DNSRecord) this.getDns().getCache().getDNSEntry(_info.getQualifiedName(), DNSRecordType.TYPE_TXT, DNSRecordClass.CLASS_IN), now);
if (_info.getServer().length() > 0)
{
newOut = this.addAnswer(newOut, (DNSRecord) this.getDns().getCache().getDNSEntry(_info.getServer(), DNSRecordType.TYPE_A, DNSRecordClass.CLASS_IN), now);
newOut = this.addAnswer(newOut, (DNSRecord) this.getDns().getCache().getDNSEntry(_info.getServer(), DNSRecordType.TYPE_AAAA, DNSRecordClass.CLASS_IN), now);
}
}
return newOut;
}
示例2: addAnswer
import javax.jmdns.impl.DNSRecord; //导入依赖的package包/类
/**
* Add an answer if it is not suppressed.
*
* @param out
* outgoing message
* @param in
* incoming request
* @param rec
* DNS record answer
* @return outgoing message for the next answer
* @exception IOException
*/
public DNSOutgoing addAnswer(DNSOutgoing out, DNSIncoming in, DNSRecord rec) throws IOException {
DNSOutgoing newOut = out;
try {
newOut.addAnswer(in, rec);
} catch (final IOException e) {
int flags = newOut.getFlags();
boolean multicast = newOut.isMulticast();
int maxUDPPayload = newOut.getMaxUDPPayload();
int id = newOut.getId();
newOut.setFlags(flags | DNSConstants.FLAGS_TC);
newOut.setId(id);
this._jmDNSImpl.send(newOut);
newOut = new DNSOutgoing(flags, multicast, maxUDPPayload);
newOut.addAnswer(in, rec);
}
return newOut;
}
示例3: addAuthoritativeAnswer
import javax.jmdns.impl.DNSRecord; //导入依赖的package包/类
/**
* Add an authoritative answer to the message.
*
* @param out
* outgoing message
* @param rec
* DNS record answer
* @return outgoing message for the next answer
* @exception IOException
*/
public DNSOutgoing addAuthoritativeAnswer(DNSOutgoing out, DNSRecord rec) throws IOException {
DNSOutgoing newOut = out;
try {
newOut.addAuthorativeAnswer(rec);
} catch (final IOException e) {
int flags = newOut.getFlags();
boolean multicast = newOut.isMulticast();
int maxUDPPayload = newOut.getMaxUDPPayload();
int id = newOut.getId();
newOut.setFlags(flags | DNSConstants.FLAGS_TC);
newOut.setId(id);
this._jmDNSImpl.send(newOut);
newOut = new DNSOutgoing(flags, multicast, maxUDPPayload);
newOut.addAuthorativeAnswer(rec);
}
return newOut;
}
示例4: addAdditionalAnswer
import javax.jmdns.impl.DNSRecord; //导入依赖的package包/类
/**
* Add an additional answer to the record. Omit if there is no room.
*
* @param out
* outgoing message
* @param in
* incoming request
* @param rec
* DNS record answer
* @return outgoing message for the next answer
* @exception IOException
*/
public DNSOutgoing addAdditionalAnswer(DNSOutgoing out, DNSIncoming in, DNSRecord rec) throws IOException {
DNSOutgoing newOut = out;
try {
newOut.addAdditionalAnswer(in, rec);
} catch (final IOException e) {
int flags = newOut.getFlags();
boolean multicast = newOut.isMulticast();
int maxUDPPayload = newOut.getMaxUDPPayload();
int id = newOut.getId();
newOut.setFlags(flags | DNSConstants.FLAGS_TC);
newOut.setId(id);
this._jmDNSImpl.send(newOut);
newOut = new DNSOutgoing(flags, multicast, maxUDPPayload);
newOut.addAdditionalAnswer(in, rec);
}
return newOut;
}
示例5: buildOutgoingForDNS
import javax.jmdns.impl.DNSRecord; //导入依赖的package包/类
@Override
protected DNSOutgoing buildOutgoingForDNS(DNSOutgoing out) throws IOException {
DNSOutgoing newOut = out;
for (DNSRecord answer : this.getDns().getLocalHost().answers(DNSRecordClass.CLASS_ANY, DNSRecordClass.UNIQUE, this.getTTL())) {
newOut = this.addAnswer(newOut, null, answer);
}
return newOut;
}
示例6: buildOutgoingForInfo
import javax.jmdns.impl.DNSRecord; //导入依赖的package包/类
@Override
protected DNSOutgoing buildOutgoingForInfo(ServiceInfoImpl info, DNSOutgoing out) throws IOException {
DNSOutgoing newOut = out;
for (DNSRecord answer : info.answers(DNSRecordClass.CLASS_ANY, DNSRecordClass.UNIQUE, this.getTTL(), this.getDns().getLocalHost())) {
newOut = this.addAnswer(newOut, null, answer);
}
return newOut;
}
示例7: buildOutgoingForDNS
import javax.jmdns.impl.DNSRecord; //导入依赖的package包/类
@Override
protected DNSOutgoing buildOutgoingForDNS(DNSOutgoing out) throws IOException {
DNSOutgoing newOut = out;
newOut.addQuestion(DNSQuestion.newQuestion(this.getDns().getLocalHost().getName(), DNSRecordType.TYPE_ANY, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
for (DNSRecord answer : this.getDns().getLocalHost().answers(DNSRecordClass.CLASS_ANY, DNSRecordClass.NOT_UNIQUE, this.getTTL())) {
newOut = this.addAuthoritativeAnswer(newOut, answer);
}
return newOut;
}
示例8: buildOutgoingForInfo
import javax.jmdns.impl.DNSRecord; //导入依赖的package包/类
@Override
protected DNSOutgoing buildOutgoingForInfo(ServiceInfoImpl info, DNSOutgoing out) throws IOException {
DNSOutgoing newOut = out;
newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(info.getQualifiedName(), DNSRecordType.TYPE_ANY, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
// the "unique" flag should be not set here because these answers haven't been proven unique yet this means the record will not exactly match the announcement record
newOut = this.addAuthoritativeAnswer(newOut, new DNSRecord.Service(info.getQualifiedName(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, this.getTTL(), info.getPriority(), info.getWeight(), info.getPort(), this.getDns().getLocalHost()
.getName()));
return newOut;
}
示例9: addAnswers
import javax.jmdns.impl.DNSRecord; //导入依赖的package包/类
@Override
protected DNSOutgoing addAnswers(DNSOutgoing out) throws IOException {
DNSOutgoing newOut = out;
long now = System.currentTimeMillis();
for (ServiceInfo info : this.getDns().getServices().values()) {
newOut = this.addAnswer(newOut, new DNSRecord.Pointer(info.getType(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, DNSConstants.DNS_TTL, info.getQualifiedName()), now);
// newOut = this.addAnswer(newOut, new DNSRecord.Service(info.getQualifiedName(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, DNSConstants.DNS_TTL, info.getPriority(), info.getWeight(), info.getPort(),
// this.getDns().getLocalHost().getName()), now);
}
return newOut;
}
示例10: addAnswers
import javax.jmdns.impl.DNSRecord; //导入依赖的package包/类
@Override
protected DNSOutgoing addAnswers(DNSOutgoing out) throws IOException {
DNSOutgoing newOut = out;
long now = System.currentTimeMillis();
for (String type : this.getDns().getServiceTypes().keySet()) {
ServiceTypeEntry typeEntry = this.getDns().getServiceTypes().get(type);
newOut = this.addAnswer(newOut, new DNSRecord.Pointer("_services._dns-sd._udp.local.", DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, DNSConstants.DNS_TTL, typeEntry.getType()), now);
}
return newOut;
}
示例11: buildOutgoingForDNS
import javax.jmdns.impl.DNSRecord; //导入依赖的package包/类
@Override
protected DNSOutgoing buildOutgoingForDNS(DNSOutgoing out) throws IOException {
DNSOutgoing newOut = out;
for (DNSRecord answer : this.getDns().getLocalHost().answers(DNSRecordClass.UNIQUE, this.getTTL())) {
newOut = this.addAnswer(newOut, null, answer);
}
return newOut;
}
示例12: buildOutgoingForInfo
import javax.jmdns.impl.DNSRecord; //导入依赖的package包/类
@Override
protected DNSOutgoing buildOutgoingForInfo(ServiceInfoImpl info, DNSOutgoing out) throws IOException {
DNSOutgoing newOut = out;
for (DNSRecord answer : info.answers(DNSRecordClass.UNIQUE, this.getTTL(), this.getDns().getLocalHost())) {
newOut = this.addAnswer(newOut, null, answer);
}
return newOut;
}
示例13: buildOutgoingForDNS
import javax.jmdns.impl.DNSRecord; //导入依赖的package包/类
@Override
protected DNSOutgoing buildOutgoingForDNS(DNSOutgoing out) throws IOException {
DNSOutgoing newOut = out;
newOut.addQuestion(DNSQuestion.newQuestion(this.getDns().getLocalHost().getName(), DNSRecordType.TYPE_ANY, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
for (DNSRecord answer : this.getDns().getLocalHost().answers(DNSRecordClass.NOT_UNIQUE, this.getTTL())) {
newOut = this.addAuthoritativeAnswer(newOut, answer);
}
return newOut;
}
示例14: addAnswers
import javax.jmdns.impl.DNSRecord; //导入依赖的package包/类
@Override
protected DNSOutgoing addAnswers(DNSOutgoing out) throws IOException {
DNSOutgoing newOut = out;
if (!_info.hasData()) {
long now = System.currentTimeMillis();
newOut = this.addAnswer(newOut, (DNSRecord) this.getDns().getCache().getDNSEntry(_info.getQualifiedName(), DNSRecordType.TYPE_SRV, DNSRecordClass.CLASS_IN), now);
newOut = this.addAnswer(newOut, (DNSRecord) this.getDns().getCache().getDNSEntry(_info.getQualifiedName(), DNSRecordType.TYPE_TXT, DNSRecordClass.CLASS_IN), now);
if (_info.getServer().length() > 0) {
newOut = this.addAnswer(newOut, (DNSRecord) this.getDns().getCache().getDNSEntry(_info.getServer(), DNSRecordType.TYPE_A, DNSRecordClass.CLASS_IN), now);
newOut = this.addAnswer(newOut, (DNSRecord) this.getDns().getCache().getDNSEntry(_info.getServer(), DNSRecordType.TYPE_AAAA, DNSRecordClass.CLASS_IN), now);
}
}
return newOut;
}
示例15: run
import javax.jmdns.impl.DNSRecord; //导入依赖的package包/类
@Override
public void run()
{
if (this.getDns().isCanceling() || this.getDns().isCanceled())
{
return;
}
if (logger.isLoggable(Level.FINEST))
{
logger.finest(this.getName() + ".run() JmDNS reaping cache");
}
// Remove expired answers from the cache
// -------------------------------------
long now = System.currentTimeMillis();
for (DNSEntry entry : this.getDns().getCache().allValues())
{
try
{
DNSRecord record = (DNSRecord) entry;
if (record.isStale(now))
{
// we should query for the record we care about i.e. those in the service collectors
this.getDns().renewServiceCollector(record);
}
if (record.isExpired(now))
{
this.getDns().updateRecord(now, record, Operation.Remove);
this.getDns().getCache().removeDNSEntry(record);
}
}
catch (Exception exception)
{
logger.log(Level.SEVERE, this.getName() + ".Error while reaping records: " + entry, exception);
logger.severe(this.getDns().toString());
}
}
}