• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NetworkInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.qiniu.android.dns.NetworkInfo的典型用法代码示例。如果您正苦于以下问题:Java NetworkInfo类的具体用法?Java NetworkInfo怎么用?Java NetworkInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NetworkInfo类属于com.qiniu.android.dns包,在下文中一共展示了NetworkInfo类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: filter

import com.qiniu.android.dns.NetworkInfo; //导入依赖的package包/类
private LinkedList<Value> filter(LinkedList<Value> origin, NetworkInfo info) {
    LinkedList<Value> normal = new LinkedList<>();
    LinkedList<Value> special = new LinkedList<>();
    for (Value v : origin) {
        if (v.provider == NetworkInfo.ISP_GENERAL) {
            normal.add(v);
        }
        if (info.provider != NetworkInfo.ISP_GENERAL
                && v.provider == info.provider) {
            special.add(v);
        }
    }
    if (special.size() != 0) {
        return special;
    }
    return normal;
}
 
开发者ID:qiniu,项目名称:happy-dns-android,代码行数:18,代码来源:Hosts.java


示例2: resolve

import com.qiniu.android.dns.NetworkInfo; //导入依赖的package包/类
public Record[] resolve(Domain domain, NetworkInfo info) throws IOException {
    int length;
    Record r;
    int i = 0;
    Record[] records = this.resolver.resolve(domain, info);
    if (domain.hasCname) {
        boolean cname = false;
        for (Record r2 : records) {
            if (r2.isCname()) {
                cname = true;
                break;
            }
        }
        if (!cname) {
            throw new DnshijackingException(domain.domain, this.resolver.address
                    .getHostAddress());
        }
    }
    if (domain.maxTtl != 0) {
        length = records.length;
        while (i < length) {
            r2 = records[i];
            if (r2.isCname() || r2.ttl <= domain.maxTtl) {
                i++;
            } else {
                throw new DnshijackingException(domain.domain, this.resolver.address
                        .getHostAddress(), r2.ttl);
            }
        }
    }
    return records;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:33,代码来源:HijackingDetectWrapper.java


示例3: query

import com.qiniu.android.dns.NetworkInfo; //导入依赖的package包/类
public String[] query(Domain domain, NetworkInfo info) {
    ArrayList<Value> values = (ArrayList) this.hosts.get(domain.domain);
    if (values == null || values.isEmpty()) {
        return null;
    }
    return toIps(filter(values, info));
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:Hosts.java


示例4: filter

import com.qiniu.android.dns.NetworkInfo; //导入依赖的package包/类
private ArrayList<Value> filter(ArrayList<Value> origin, NetworkInfo info) {
    ArrayList<Value> normal = new ArrayList();
    ArrayList<Value> special = new ArrayList();
    Iterator it = origin.iterator();
    while (it.hasNext()) {
        Value v = (Value) it.next();
        if (v.provider == 0) {
            normal.add(v);
        }
        if (info.provider != 0 && v.provider == info.provider) {
            special.add(v);
        }
    }
    return special.size() != 0 ? special : normal;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:16,代码来源:Hosts.java


示例5: resolve

import com.qiniu.android.dns.NetworkInfo; //导入依赖的package包/类
public Record[] resolve(Domain domain, NetworkInfo info) throws IOException {
    int id;
    synchronized (random) {
        id = random.nextInt() & 255;
    }
    byte[] answer = udpCommunicate(DnsMessage.buildQuery(domain.domain, id));
    if (answer != null) {
        return DnsMessage.parseResponse(answer, id, domain.domain);
    }
    throw new DnsException(domain.domain, "cant get answer");
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:12,代码来源:Resolver.java


示例6: resolve

import com.qiniu.android.dns.NetworkInfo; //导入依赖的package包/类
public Record[] resolve(Domain domain, NetworkInfo info) throws IOException {
    HttpURLConnection httpConn = (HttpURLConnection) new URL("http://119.29.29" +
            ".29/d?ttl=1&dn=" + domain.domain).openConnection();
    httpConn.setConnectTimeout(BaseImageDownloader.DEFAULT_HTTP_CONNECT_TIMEOUT);
    httpConn.setReadTimeout(10000);
    if (httpConn.getResponseCode() != 200) {
        return null;
    }
    int length = httpConn.getContentLength();
    if (length <= 0 || length > 1024) {
        return null;
    }
    InputStream is = httpConn.getInputStream();
    byte[] data = new byte[length];
    int read = is.read(data);
    is.close();
    if (read <= 0) {
        return null;
    }
    String[] r1 = new String(data, 0, read).split(",");
    if (r1.length != 2) {
        return null;
    }
    try {
        int ttl = Integer.parseInt(r1[1]);
        String[] ips = r1[0].split(com.boohee.one.http.DnspodFree.IP_SPLIT);
        if (ips.length == 0) {
            return null;
        }
        Record[] records = new Record[ips.length];
        long time = System.currentTimeMillis() / 1000;
        for (int i = 0; i < ips.length; i++) {
            records[i] = new Record(ips[i], 1, ttl, time);
        }
        return records;
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:40,代码来源:DnspodFree.java


示例7: resolve

import com.qiniu.android.dns.NetworkInfo; //导入依赖的package包/类
public Record[] resolve(Domain domain, NetworkInfo info) throws IOException {
    HttpURLConnection httpConn = (HttpURLConnection) new URL(TimeLinePatterns.WEB_SCHEME +
            this.ip + "/d?ttl=1&dn=" + encrypt(domain.domain) + "&id=" + this.id)
            .openConnection();
    httpConn.setConnectTimeout(LocationClientOption.MIN_SCAN_SPAN_NETWORK);
    httpConn.setReadTimeout(6000);
    if (httpConn.getResponseCode() != 200) {
        return null;
    }
    int length = httpConn.getContentLength();
    if (length <= 0 || length > 1024) {
        return null;
    }
    InputStream is = httpConn.getInputStream();
    byte[] data = new byte[length];
    int read = is.read(data);
    is.close();
    if (read <= 0) {
        return null;
    }
    String[] r1 = decrypt(new String(data, 0, read)).split(",");
    if (r1.length != 2) {
        return null;
    }
    try {
        int ttl = Integer.parseInt(r1[1]);
        String[] ips = r1[0].split(DnspodFree.IP_SPLIT);
        if (ips.length == 0) {
            return null;
        }
        Record[] records = new Record[ips.length];
        long time = System.currentTimeMillis() / 1000;
        for (int i = 0; i < ips.length; i++) {
            records[i] = new Record(ips[i], 1, ttl, time);
        }
        return records;
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:41,代码来源:DnspodEnterprise.java


示例8: query

import com.qiniu.android.dns.NetworkInfo; //导入依赖的package包/类
public synchronized String[] query(Domain domain, NetworkInfo info) {
    LinkedList<Value> values = hosts.get(domain.domain);
    if (values == null || values.isEmpty()) {
        return null;
    }
    if (values.size() > 1) {
        Value first = values.get(0);
        values.remove(0);
        values.add(first);
    }
    values = filter(values, info);
    return toIps(values);
}
 
开发者ID:qiniu,项目名称:happy-dns-android,代码行数:14,代码来源:Hosts.java


示例9: resolve

import com.qiniu.android.dns.NetworkInfo; //导入依赖的package包/类
@Override
public Record[] resolve(Domain domain, NetworkInfo info) throws IOException {
    int id;
    synchronized (random) {
        id = random.nextInt() & 0XFF;
    }
    byte[] query = DnsMessage.buildQuery(domain.domain, id);
    byte[] answer = udpCommunicate(query);
    if (answer == null) {
        throw new DnsException(domain.domain, "cant get answer");
    }

    return DnsMessage.parseResponse(answer, id, domain.domain);
}
 
开发者ID:qiniu,项目名称:happy-dns-android,代码行数:15,代码来源:Resolver.java


示例10: genId

import com.qiniu.android.dns.NetworkInfo; //导入依赖的package包/类
private static String genId() {
    return System.currentTimeMillis() + "" + new Random().nextInt(NetworkInfo.ISP_OTHER);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:UserAgent.java


示例11: defaultResolver

import com.qiniu.android.dns.NetworkInfo; //导入依赖的package包/类
public static IResolver defaultResolver() {
    return new IResolver() {
        public Record[] resolve(Domain domain, NetworkInfo info) throws IOException {
            InetAddress[] addresses = AndroidDnsServer.getByReflection();
            if (addresses == null) {
                addresses = AndroidDnsServer.getByCommand();
            }
            if (addresses == null) {
                throw new IOException("cant get local dns server");
            }
            int i;
            int length;
            Record[] records = new HijackingDetectWrapper(new Resolver(addresses[0])).resolve
                    (domain, info);
            if (domain.hasCname) {
                boolean cname = false;
                for (Record r : records) {
                    Record r2;
                    if (r2.isCname()) {
                        cname = true;
                        break;
                    }
                }
                if (!cname) {
                    throw new DnshijackingException(domain.domain, addresses[0]
                            .getHostAddress());
                }
            }
            if (domain.maxTtl != 0) {
                length = records.length;
                i = 0;
                while (i < length) {
                    r2 = records[i];
                    if (r2.isCname() || r2.ttl <= domain.maxTtl) {
                        i++;
                    } else {
                        throw new DnshijackingException(domain.domain, addresses[0]
                                .getHostAddress(), r2.ttl);
                    }
                }
            }
            return records;
        }
    };
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:46,代码来源:AndroidDnsServer.java


示例12: Value

import com.qiniu.android.dns.NetworkInfo; //导入依赖的package包/类
public Value(String ip) {
    this(ip, NetworkInfo.ISP_GENERAL);
}
 
开发者ID:qiniu,项目名称:happy-dns-android,代码行数:4,代码来源:Hosts.java


示例13: resolve

import com.qiniu.android.dns.NetworkInfo; //导入依赖的package包/类
@Override
public Record[] resolve(Domain domain, NetworkInfo info) throws IOException {
    URL url = new URL("http://" + ip + "/d?ttl=1&dn=" + domain.domain);
    HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
    httpConn.setConnectTimeout(3000);
    httpConn.setReadTimeout(timeout * 1000);
    int responseCode = httpConn.getResponseCode();
    if (responseCode != HttpURLConnection.HTTP_OK) {
        return null;
    }

    int length = httpConn.getContentLength();
    if (length <= 0 || length > 1024) {
        return null;
    }
    InputStream is = httpConn.getInputStream();
    byte[] data = new byte[length];
    int read = is.read(data);
    is.close();
    if (read <= 0) {
        return null;
    }
    String response = new String(data, 0, read);
    String[] r1 = response.split(",");
    if (r1.length != 2) {
        return null;
    }
    int ttl;
    try {
        ttl = Integer.parseInt(r1[1]);
    } catch (Exception e) {
        return null;
    }
    String[] ips = r1[0].split(";");
    if (ips.length == 0) {
        return null;
    }
    Record[] records = new Record[ips.length];
    long time = System.currentTimeMillis() / 1000;
    for (int i = 0; i < ips.length; i++) {
        records[i] = new Record(ips[i], Record.TYPE_A, ttl, time);
    }
    return records;
}
 
开发者ID:qiniu,项目名称:happy-dns-android,代码行数:45,代码来源:DnspodFree.java


示例14: resolve

import com.qiniu.android.dns.NetworkInfo; //导入依赖的package包/类
@Override
public Record[] resolve(Domain domain, NetworkInfo info) throws IOException {
    URL url = new URL("http://" + ip + "/d?ttl=1&dn=" + encrypt(domain.domain)
            + "&id=" + id);

    HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
    httpConn.setConnectTimeout(3000);
    httpConn.setReadTimeout(timeout * 1000);
    int responseCode = httpConn.getResponseCode();
    if (responseCode != HttpURLConnection.HTTP_OK) {
        return null;
    }

    int length = httpConn.getContentLength();
    if (length <= 0 || length > 1024) {
        return null;
    }
    InputStream is = httpConn.getInputStream();
    byte[] data = new byte[length];
    int read = is.read(data);
    is.close();
    if (read <= 0) {
        return null;
    }
    String response = new String(data, 0, read);
    String result = decrypt(response);
    String[] r1 = result.split(",");
    if (r1.length != 2) {
        return null;
    }
    int ttl;
    try {
        ttl = Integer.parseInt(r1[1]);
    } catch (Exception e) {
        return null;
    }
    String[] ips = r1[0].split(";");
    if (ips.length == 0) {
        return null;
    }
    Record[] records = new Record[ips.length];
    long time = System.currentTimeMillis() / 1000;
    for (int i = 0; i < ips.length; i++) {
        records[i] = new Record(ips[i], Record.TYPE_A, ttl, time);
    }
    return records;
}
 
开发者ID:qiniu,项目名称:happy-dns-android,代码行数:48,代码来源:DnspodEnterprise.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EndpointContext类代码示例发布时间:2022-05-23
下一篇:
Java KieCommands类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap