当前位置: 首页>>代码示例>>Java>>正文


Java DNSRecord类代码示例

本文整理汇总了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;
}
 
开发者ID:blackshadowwalker,项目名称:log4j-collector,代码行数:18,代码来源:ServiceInfoResolver.java

示例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;
}
 
开发者ID:mwaylabs,项目名称:JmDNS,代码行数:32,代码来源:DNSTask.java

示例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;
}
 
开发者ID:mwaylabs,项目名称:JmDNS,代码行数:30,代码来源:DNSTask.java

示例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;
}
 
开发者ID:mwaylabs,项目名称:JmDNS,代码行数:32,代码来源:DNSTask.java

示例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;
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:9,代码来源:Announcer.java

示例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;
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:9,代码来源:Announcer.java

示例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;
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:10,代码来源:Prober.java

示例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;
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:10,代码来源:Prober.java

示例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;
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:12,代码来源:ServiceResolver.java

示例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;
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:11,代码来源:TypeResolver.java

示例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;
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:9,代码来源:Announcer.java

示例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;
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:9,代码来源:Announcer.java

示例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;
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:10,代码来源:Prober.java

示例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;
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:15,代码来源:ServiceInfoResolver.java

示例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());
        }
    }
}
 
开发者ID:blackshadowwalker,项目名称:log4j-collector,代码行数:39,代码来源:RecordReaper.java


注:本文中的javax.jmdns.impl.DNSRecord类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。