本文整理汇总了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;未经允许,请勿转载。 |
请发表评论