Skip to content

Commit 05ce258

Browse files
author
luyd
committed
init
1 parent c7f017a commit 05ce258

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2060
-0
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.iml
2+
/local.properties
3+
/.idea
4+
.DS_Store
5+
/build
6+
/captures
7+
.externalNativeBuild
8+
.gradle
9+
libs/
10+
src/main/res/drawable/

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 27
5+
defaultConfig {
6+
applicationId "com.ufoto.dns.dns"
7+
minSdkVersion 18
8+
targetSdkVersion 27
9+
versionCode 1
10+
versionName "1.0"
11+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12+
}
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
}
20+
21+
dependencies {
22+
implementation fileTree(include: ['*.jar'], dir: 'libs')
23+
implementation 'com.android.support:appcompat-v7:26.1.0'
24+
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
25+
implementation 'com.android.support:design:26.1.0'
26+
implementation project(':dnsdashboard')
27+
28+
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
29+
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
30+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile

app/src/main/AndroidManifest.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.ufoto.dns.dns">
4+
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
<application
7+
android:allowBackup="true"
8+
android:icon="@mipmap/ic_launcher"
9+
android:label="@string/app_name"
10+
android:roundIcon="@mipmap/ic_launcher_round"
11+
android:supportsRtl="true"
12+
android:theme="@style/AppTheme">
13+
<activity
14+
android:name=".MainActivity"
15+
android:label="@string/app_name"
16+
android:theme="@style/AppTheme.NoActionBar">
17+
<intent-filter>
18+
<action android:name="android.intent.action.MAIN" />
19+
20+
<category android:name="android.intent.category.LAUNCHER" />
21+
</intent-filter>
22+
</activity>
23+
</application>
24+
25+
</manifest>
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
package com.ufoto.dns.dns;
2+
3+
import java.util.List;
4+
5+
/**
6+
* http://www.wanandroid.com/banner/json
7+
*/
8+
public class Banner {
9+
10+
/**
11+
* data : [{"desc":"","id":6,"imagePath":"http://www.wanandroid.com/blogimgs/62c1bd68-b5f3-4a3c-a649-7ca8c7dfabe6.png","isVisible":1,"order":1,"title":"我们新增了一个常用导航Tab~","type":0,"url":"http://www.wanandroid.com/navi"},{"desc":"一起来做个App吧","id":10,"imagePath":"http://www.wanandroid.com/blogimgs/50c115c2-cf6c-4802-aa7b-a4334de444cd.png","isVisible":1,"order":1,"title":"一起来做个App吧","type":0,"url":"http://www.wanandroid.com/blog/show/2"},{"desc":"","id":7,"imagePath":"http://www.wanandroid.com/blogimgs/ffb61454-e0d2-46e7-bc9b-4f359061ae20.png","isVisible":1,"order":2,"title":"送你一个暖心的Mock API工具","type":0,"url":"http://www.wanandroid.com/blog/show/10"},{"desc":"","id":4,"imagePath":"http://www.wanandroid.com/blogimgs/ab17e8f9-6b79-450b-8079-0f2287eb6f0f.png","isVisible":1,"order":0,"title":"看看别人的面经,搞定面试~","type":1,"url":"http://www.wanandroid.com/article/list/0?cid=73"},{"desc":"","id":3,"imagePath":"http://www.wanandroid.com/blogimgs/fb0ea461-e00a-482b-814f-4faca5761427.png","isVisible":1,"order":1,"title":"兄弟,要不要挑个项目学习下?","type":1,"url":"http://www.wanandroid.com/project"},{"desc":"加个友情链接吧~","id":11,"imagePath":"http://www.wanandroid.com/blogimgs/84810df6-adf1-45bc-b3e2-294fa4e95005.png","isVisible":1,"order":1,"title":"加个友情链接吧~","type":1,"url":"http://www.wanandroid.com/ulink"},{"desc":"","id":2,"imagePath":"http://www.wanandroid.com/blogimgs/90cf8c40-9489-4f9d-8936-02c9ebae31f0.png","isVisible":1,"order":2,"title":"JSON工具","type":1,"url":"http://www.wanandroid.com/tools/bejson"},{"desc":"","id":5,"imagePath":"http://www.wanandroid.com/blogimgs/acc23063-1884-4925-bdf8-0b0364a7243e.png","isVisible":1,"order":3,"title":"微信文章合集","type":1,"url":"http://www.wanandroid.com/blog/show/6"}]
12+
* errorCode : 0
13+
* errorMsg :
14+
*/
15+
16+
private int errorCode;
17+
private String errorMsg;
18+
private List<DataBean> data;
19+
20+
public int getErrorCode() {
21+
return errorCode;
22+
}
23+
24+
public void setErrorCode(int errorCode) {
25+
this.errorCode = errorCode;
26+
}
27+
28+
public String getErrorMsg() {
29+
return errorMsg;
30+
}
31+
32+
public void setErrorMsg(String errorMsg) {
33+
this.errorMsg = errorMsg;
34+
}
35+
36+
public List<DataBean> getData() {
37+
return data;
38+
}
39+
40+
public void setData(List<DataBean> data) {
41+
this.data = data;
42+
}
43+
44+
public static class DataBean {
45+
/**
46+
* desc :
47+
* id : 6
48+
* imagePath : http://www.wanandroid.com/blogimgs/62c1bd68-b5f3-4a3c-a649-7ca8c7dfabe6.png
49+
* isVisible : 1
50+
* order : 1
51+
* title : 我们新增了一个常用导航Tab~
52+
* type : 0
53+
* url : http://www.wanandroid.com/navi
54+
*/
55+
56+
private String desc;
57+
private int id;
58+
private String imagePath;
59+
private int isVisible;
60+
private int order;
61+
private String title;
62+
private int type;
63+
private String url;
64+
65+
public String getDesc() {
66+
return desc;
67+
}
68+
69+
public void setDesc(String desc) {
70+
this.desc = desc;
71+
}
72+
73+
public int getId() {
74+
return id;
75+
}
76+
77+
public void setId(int id) {
78+
this.id = id;
79+
}
80+
81+
public String getImagePath() {
82+
return imagePath;
83+
}
84+
85+
public void setImagePath(String imagePath) {
86+
this.imagePath = imagePath;
87+
}
88+
89+
public int getIsVisible() {
90+
return isVisible;
91+
}
92+
93+
public void setIsVisible(int isVisible) {
94+
this.isVisible = isVisible;
95+
}
96+
97+
public int getOrder() {
98+
return order;
99+
}
100+
101+
public void setOrder(int order) {
102+
this.order = order;
103+
}
104+
105+
public String getTitle() {
106+
return title;
107+
}
108+
109+
public void setTitle(String title) {
110+
this.title = title;
111+
}
112+
113+
public int getType() {
114+
return type;
115+
}
116+
117+
public void setType(int type) {
118+
this.type = type;
119+
}
120+
121+
public String getUrl() {
122+
return url;
123+
}
124+
125+
public void setUrl(String url) {
126+
this.url = url;
127+
}
128+
}
129+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.ufoto.dns.dns;
2+
3+
import retrofit2.Call;
4+
import retrofit2.http.GET;
5+
6+
public interface BannerApi {
7+
8+
@GET("banner/json")
9+
Call<Banner> getBanner();
10+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
package com.ufoto.dns.dns;
2+
3+
import android.os.Bundle;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.util.Log;
6+
import android.view.View;
7+
import android.widget.TextView;
8+
9+
import com.ufoto.dns.Dns;
10+
import com.ufoto.dns.detection.DNSInfor;
11+
import com.ufoto.dns.detection.DnsDashboard;
12+
import com.ufoto.dns.detection.InformationListener;
13+
14+
import java.util.ArrayList;
15+
import java.util.List;
16+
17+
import retrofit2.Call;
18+
import retrofit2.Callback;
19+
import retrofit2.Response;
20+
import retrofit2.Retrofit;
21+
import retrofit2.converter.gson.GsonConverterFactory;
22+
23+
public class MainActivity extends AppCompatActivity {
24+
private TextView mTvDnsDomain;
25+
private TextView mTvDnsResolution;
26+
private TextView mTvDnsStartTime;
27+
private TextView mTvDnsEndTime;
28+
29+
@Override
30+
protected void onCreate(Bundle savedInstanceState) {
31+
super.onCreate(savedInstanceState);
32+
setContentView(R.layout.activity_main);
33+
34+
mTvDnsDomain = findViewById(R.id.tv_dns_domain);
35+
mTvDnsResolution = findViewById(R.id.tv_dns_resolution);
36+
mTvDnsStartTime = findViewById(R.id.tv_dns_start_time);
37+
mTvDnsEndTime = findViewById(R.id.tv_dns_end_time);
38+
39+
Dns.dnsCacheInject(this);
40+
//调用DnsDashboard.hookDNS(),传入InformationListener对象,在onMonitor()中DNSInfor中就是DNS解析相关信息。
41+
DnsDashboard.getInstance().hookDNS(new InformationListener() {
42+
@Override
43+
public void onMonitor(final DNSInfor dnsInfor) {
44+
runOnUiThread(new Runnable() {
45+
@Override
46+
public void run() {
47+
printLog(dnsInfor);
48+
}
49+
});
50+
}
51+
});
52+
}
53+
54+
private void printLog(DNSInfor dnsInfor) {
55+
if (dnsInfor.isHookSuccess()) {
56+
mTvDnsDomain.setText("请求站点:" + dnsInfor.getDomain());
57+
mTvDnsResolution.setText("解析用时:" + dnsInfor.getResolutionTime());
58+
mTvDnsStartTime.setText("开始解析:" + dnsInfor.getStartTime());
59+
mTvDnsEndTime.setText("结束解析:" + dnsInfor.getEndTime());
60+
61+
Log.i("DnsSDK", "请求站点:" + dnsInfor.getDomain());
62+
Log.i("DnsSDK", "解析用时:" + dnsInfor.getResolutionTime());
63+
Log.i("DnsSDK", "开始解析:" + dnsInfor.getStartTime());
64+
Log.i("DnsSDK", "结束解析:" + dnsInfor.getEndTime());
65+
} else {
66+
mTvDnsDomain.setText("请求站点:" + dnsInfor.getDomain());
67+
mTvDnsResolution.setText("解析用时:" + dnsInfor.getResolutionTime());
68+
mTvDnsStartTime.setText("开始解析:" + dnsInfor.getStartTime());
69+
mTvDnsEndTime.setText("结束解析:" + dnsInfor.getEndTime());
70+
71+
Log.i("DnsSDK", "请求站点:" + dnsInfor.getDomain());
72+
Log.i("DnsSDK", "解析用时:" + dnsInfor.getResolutionTime());
73+
Log.i("DnsSDK", "开始解析:" + dnsInfor.getStartTime());
74+
Log.i("DnsSDK", "结束解析:" + dnsInfor.getEndTime());
75+
}
76+
}
77+
78+
public void onRequestClick(View v) {
79+
Retrofit retrofit = new Retrofit.Builder()
80+
.baseUrl("https://blog.csdn.net/zhujianlin1990/article/details/51469359/")
81+
.addConverterFactory(GsonConverterFactory.create())
82+
.build();
83+
BannerApi bannerApi = retrofit.create(BannerApi.class);
84+
final Call<Banner> banner = bannerApi.getBanner();
85+
banner.enqueue(new Callback<Banner>() {
86+
@Override
87+
public void onResponse(Call<Banner> call, Response<Banner> response) {
88+
if (null != response && null != response.body()) {
89+
Log.i("DNS", "Title: " + response.body().getData().get(0).getTitle());
90+
}
91+
}
92+
93+
@Override
94+
public void onFailure(Call<Banner> call, Throwable t) {
95+
Log.i("DNS", "请求Error: " + t.getMessage());
96+
}
97+
});
98+
99+
List<String> list = new ArrayList<>();
100+
list.add("www.baidu.com");
101+
Dns.loadDns(list);
102+
}
103+
104+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:aapt="http://schemas.android.com/aapt"
3+
android:width="108dp"
4+
android:height="108dp"
5+
android:viewportHeight="108"
6+
android:viewportWidth="108">
7+
<path
8+
android:fillType="evenOdd"
9+
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
10+
android:strokeColor="#00000000"
11+
android:strokeWidth="1">
12+
<aapt:attr name="android:fillColor">
13+
<gradient
14+
android:endX="78.5885"
15+
android:endY="90.9159"
16+
android:startX="48.7653"
17+
android:startY="61.0927"
18+
android:type="linear">
19+
<item
20+
android:color="#44000000"
21+
android:offset="0.0" />
22+
<item
23+
android:color="#00000000"
24+
android:offset="1.0" />
25+
</gradient>
26+
</aapt:attr>
27+
</path>
28+
<path
29+
android:fillColor="#FFFFFF"
30+
android:fillType="nonZero"
31+
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
32+
android:strokeColor="#00000000"
33+
android:strokeWidth="1" />
34+
</vector>

0 commit comments

Comments
 (0)