Skip to content

Commit

Permalink
update 1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
M-studen committed Feb 19, 2024
1 parent a3e130d commit aafaf22
Show file tree
Hide file tree
Showing 19 changed files with 311 additions and 179 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"pinia-plugin-persistedstate": "^3.2.1",
"unplugin-vue-components": "^0.26.0",
"vue": "^3.3.4",
"vue-router": "4"
"vue-router": "4",
"vue-toast-notification": "^3"
},
"devDependencies": {
"@tauri-apps/cli": "^1.5.9",
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
surge-ping = "0.8.0"
tokio = { version = "1.21.2", features = ["full"] }
trust-dns-resolver = "0.20"
trust-dns-resolver = { version = "0.20.4", features = ["tokio-runtime"] }


[features]
# this feature is used for production builds or when `devPath` points to the filesystem
Expand Down
1 change: 1 addition & 0 deletions src-tauri/DnsList.v6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"list":[{"name":"阿里 IPv6 DNS (Alidns)","IP":"2400:3200::1","delay":"未测量"},{"name":"阿里 IPv6 DNS (Alidns)","IP":"2400:3200:baba::1","delay":"未测量"},{"name":"腾讯 DNSPod IPv6 DNS","IP":"2402:4e00::","delay":"未测量"},{"name":"百度 IPv6 DNS","IP":"2400:da00::6666","delay":"未测量"},{"name":"中国电信 IPv6 DNS","IP":"240e:4c:4008::1","delay":"未测量"},{"name":"中国电信 IPv6 DNS","IP":"240e:4c:4808::1","delay":"未测量"},{"name":"中国联通 IPv6 DNS","IP":"2408:8899::8","delay":"未测量"},{"name":"中国联通 IPv6 DNS","IP":"2408:8888::8","delay":"未测量"},{"name":"中国移动 IPv6 DNS","IP":"2409:8088::a","delay":"未测量"},{"name":"中国移动 IPv6 DNS","IP":"2409:8088::b","delay":"未测量"},{"name":"下一代互联网北京研究中心","IP":"240C::6666","delay":"未测量"},{"name":"下一代互联网北京研究中心","IP":"240C::6644","delay":"未测量"},{"name":"CNNIC IPv6 DNS 服务器","IP":"2001:dc7:1000::1","delay":"未测量"},{"name":"TWNIC IPv6 DNS Quad 101","IP":"2001:de4::101","delay":"未测量"},{"name":"TWNIC IPv6 DNS Quad 101","IP":"2001:de4::102","delay":"未测量"},{"name":"北京邮电大学 IPv6 DNS 服务器","IP":"2001:da8:202:10::36","delay":"未测量"},{"name":"北京邮电大学 IPv6 DNS 服务器","IP":"2001:da8:202:10::37","delay":"未测量"},{"name":"上海交通大学 IPv6 DNS 服务器","IP":"2001:da8:8000:1:202:120:2:100","delay":"未测量"},{"name":"上海交通大学 IPv6 DNS 服务器","IP":"2001:da8:8000:1:202:120:2:101","delay":"未测量"},{"IP":"中科院网络信息中心 IPv6 DNS 服务器","name":"2001:cc0:2fff:1::6666","delay":"未测量"},{"IP":"北京交通大学 IPv6 DNS 服务器","name":"2001:da8:205:2060::188","delay":"未测量"},{"IP":"清华大学 IPv6 DNS 服务器","name":"2001:da8:ff:305:20c:29ff:fe1f:a92a","delay":"未测量"},{"IP":"清华大学 TUNA 协会 IPv6 DNS 服务器","name":"2001:da8::666","delay":"未测量"},{"IP":"北京科技大学 IPv6 DNS 服务器","name":"2001:da8:208:10::6","delay":"未测量"},{"IP":"科技网 IPv6 DNS 服务器","name":"2001:cc0:2fff:2::6 ","delay":"未测量"},{"IP":"Google Public IPv6 DNS","name":"2001:4860:4860::8888","delay":"未测量"},{"IP":"Google Public IPv6 DNS","name":"2001:4860:4860::8844","delay":"未测量"},{"IP":"Cloudflare IPv6 DNS","name":"2606:4700:4700::1111","delay":"未测量"},{"IP":"Cloudflare IPv6 DNS","name":"2606:4700:4700::1001","delay":"未测量"},{"IP":"OpenDNS","name":"2620:0:ccc::2","delay":"未测量"},{"IP":"OpenDNS","name":"2620:0:ccd::2","delay":"未测量"},{"IP":"Quad9 IPv6 DNS","name":"2620:fe::fe","delay":"未测量"},{"IP":"Quad9 IPv6 DNS","name":"2620:fe::9","delay":"未测量"},{"IP":"Neustar UltraDNS IPv6(基础版)","name":"2620:74:1b::1:1","delay":"未测量"},{"IP":"Neustar UltraDNS IPv6(基础版)","name":"2620:74:1c::2:2","delay":"未测量"},{"IP":"Neustar UltraDNS IPv6(安全版)","name":"2610:a1:1018::2","delay":"未测量"},{"IP":"Neustar UltraDNS IPv6(安全版)","name":"2610:a1:1019::2","delay":"未测量"},{"IP":"Neustar UltraDNS IPv6(家庭版)","name":"2610:a1:1018::3","delay":"未测量"},{"IP":"Neustar UltraDNS IPv6(家庭版)","name":"2610:a1:1019::3","delay":"未测量"},{"IP":"DNS.SB","name":"2a09::","delay":"未测量"}]}
62 changes: 0 additions & 62 deletions src-tauri/src/dns.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src-tauri/src/getjsonlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ pub struct CmdParams {

// 定义一个 Tauri 命令
#[command]
pub fn get_records(params: CmdParams) -> Result<RecordList, tauri::Error> {
pub async fn get_records(params: CmdParams) -> Result<RecordList, tauri::Error> {
read_records_from_json(params.path).map_err(|e| e.into())
}
2 changes: 1 addition & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn main() {
.invoke_handler(tauri::generate_handler![
ping::pings,
getjsonlist::get_records,
pollute::check_dns_pollution
pollute::check_dns_pollution,
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
Expand Down
2 changes: 0 additions & 2 deletions src-tauri/src/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ use tauri::command;
pub async fn pings(address: String) -> Result<i64, String> {
// 解析地址为 IpAddr
let address = address.parse::<IpAddr>().map_err(|_| "Invalid IP address".to_string())?;

// 使用 surge_ping crate 提供的 ping 函数
let result = ping(address, &[0; 32]).await.map_err(|e| e.to_string())?;

// 将 Duration 转换为毫秒
let duration_ms = result.1.as_secs_f64() * 1000.0;
Ok(duration_ms as i64)
Expand Down
42 changes: 32 additions & 10 deletions src-tauri/src/pollute.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,46 @@
use tauri::command;
use trust_dns_resolver::config::*;
use trust_dns_resolver::Resolver;
use trust_dns_resolver::lookup_ip::LookupIp;
use trust_dns_resolver::Name;
use std::str::FromStr;
use serde::{Serialize, Deserialize};
use std::net::IpAddr;
use tauri::InvokeError;

#[derive(Serialize, Deserialize)]
pub struct DnsCheckResult {
all_system_ips_not_in_public: bool,
public_response: Vec<IpAddr>,
system_response: Vec<IpAddr>,
}

type Result<T> = std::result::Result<T, InvokeError>;

#[command]
pub fn check_dns_pollution(domain: String) -> Result<bool, String> {
pub fn check_dns_pollution(domain: String) -> Result<DnsCheckResult> {
let public_resolver = Resolver::new(ResolverConfig::google(), ResolverOpts::default())
.map_err(|e| e.to_string())?;
.map_err(|e| InvokeError::from(e.to_string()))?;
let system_resolver = Resolver::from_system_conf()
.map_err(|e| e.to_string())?;
.map_err(|e| InvokeError::from(e.to_string()))?;

let name = Name::from_str(&domain).map_err(|e| InvokeError::from(e.to_string()))?;

let public_response: LookupIp = public_resolver.lookup_ip(name.clone()).map_err(|e| InvokeError::from(e.to_string()))?;
let system_response: LookupIp = system_resolver.lookup_ip(name).map_err(|e| InvokeError::from(e.to_string()))?;

let name = Name::from_str(&domain).map_err(|e| e.to_string())?;
let public_response = public_resolver.lookup_ip(name.clone()).map_err(|e| e.to_string())?;
let system_response = system_resolver.lookup_ip(name).map_err(|e| e.to_string())?;
// 将LookupIp转换为Vec<IpAddr>
let public_ips: Vec<IpAddr> = public_response.iter().map(|r| r).collect();
let system_ips: Vec<IpAddr> = system_response.iter().map(|r| r).collect();

// Check if all system resolver IPs are not in the public resolver IP list
let all_system_ips_not_in_public = system_response.iter().all(|system_ip| {
!public_response.iter().any(|public_ip| public_ip == system_ip)
// 检查所有系统解析器的IP是否都不在公共解析器的IP列表中
let all_system_ips_not_in_public = system_ips.iter().all(|system_ip| {
!public_ips.iter().any(|public_ip| public_ip == system_ip)
});

Ok(all_system_ips_not_in_public)
Ok(DnsCheckResult {
all_system_ips_not_in_public,
public_response: public_ips,
system_response: system_ips,
})
}
5 changes: 3 additions & 2 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"package": {
"productName": "DnsTools",
"version": "1.2.0"
"version": "1.2.1"
},
"tauri": {
"allowlist": {
Expand Down Expand Up @@ -57,7 +57,8 @@
],
"resources": [
"DnsList.json",
"DnsList.min.json"
"DnsList.min.json",
"DnsList.V6.json"
]
},

Expand Down
52 changes: 24 additions & 28 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,42 +1,38 @@

<template>
<n-layout has-sider>
<n-layout-sider bordered >
<NAffix :trigger-top="80" :top="0">
<n-layout has-sider>
<n-layout-sider bordered>
<NAffix :trigger-top="80" :top="0">
<Logo></Logo>
<Menu></Menu>
</NAffix>

</NAffix>
</n-layout-sider>
<n-layout-content bordered >
<div class="content" >
<RouterView></RouterView>
</div>
<n-layout-content bordered>
<div class="content">
<RouterView></RouterView>
</div>
</n-layout-content>
</n-layout>

</n-layout>
</template>

<script setup>
import Menu from "@/components/menu/index.vue"
import { NLayout,NLayoutContent,NLayoutSider,NAffix } from "naive-ui";
import Logo from "@/components/logo/index.vue"
import Menu from "@/components/menu/index.vue";
import { NLayout, NLayoutContent, NLayoutSider, NAffix } from "naive-ui";
import Logo from "@/components/logo/index.vue";
</script>

<style lang="scss" scoped>
.n-menu{
.n-menu-item{
width: 10px;
}
.n-menu {
.n-menu-item {
width: 10px;
}
}
.n-affix{
width: 270px;
transition: top 10s;
.n-affix {
width: 270px;
transition: top 10s;
}
.content{
margin-left: 2%;
margin-right: 2%;
margin-top: 2%;
.content {
margin-left: 2%;
margin-right: 2%;
margin-top: 2%;
}
</style>
</style>
3 changes: 3 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import { createApp } from "vue";
import App from "./App.vue";
import router from "./router/index.js";
import { createPinia } from 'pinia'
import ToastPlugin from "vue-toast-notification";
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import 'vue-toast-notification/dist/theme-sugar.css';
const app = createApp(App)
const pinia=createPinia()
pinia.use(piniaPluginPersistedstate)
app.use(router)
app.use(pinia)
app.use(ToastPlugin)
app.mount('#app')
51 changes: 51 additions & 0 deletions src/store/pullute.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { defineStore } from 'pinia'

export const usePulluteStore = defineStore('pullute', {
state: () => ({
options:[{
type:"group",
label:"蓝奏云",
key:"蓝奏云",
children:[
{label:"lanzoui.com",value:"lanzoui.com"},
{label:"lanzoul.com",value:"lanzoul.com"},
{label:"lanzoux.com",value:"lanzoux.com"},
{label:"lanzouw.com",value:"lanzouw.com"},
]
},
{label:"推特",value:"twitter.com"},
{label:"谷歌",value:"google.com"},
{label:"Gmail",value:"gmail.com"},
{label:"FaceBook",value:"facebook.com"},
{label:"Instagram",value:"instagram.com"},
{label:"Netflix",value:"netflix.com"},
{
type:"group",
label:"历史输入",
value:"历史输入",
children:[]
}
]}),
persist:true,
actions: {
addHistoryInput(inputValue) {
const isValueUnique = !this.options.some(option => {
// 检查是否为 group 类型并搜索其 children
if (option.type === 'group') {
return option.children.some(child => child.value === inputValue);
}
// 不是 group 类型,直接比对 value
return option.value === inputValue;
});

if (isValueUnique) {
const historyGroup = this.options.find(option => option.label === '历史输入');
if (historyGroup) {
const newItem = { label: inputValue, value: inputValue };
historyGroup.children.push(newItem);
}
}
}
}

})
3 changes: 2 additions & 1 deletion src/store/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { ref } from 'vue'

export const useSettingsStore = defineStore('settings', {
state: () => ({
filePath: ref("./DnsList.json")
filePath: ref("./DnsList.json"),
firstwarn:false
}),
persist:true

Expand Down
8 changes: 6 additions & 2 deletions src/store/speed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineStore } from 'pinia';
import { invoke } from "@tauri-apps/api";
import { useSettingsStore } from './settings';
import { useToast } from 'vue-toast-notification';
export const useSpeedStore = defineStore('speed', {
state: () => ({
data:[],
Expand All @@ -19,7 +20,11 @@ export const useSpeedStore = defineStore('speed', {
});
sessionStorage.setItem("Ini",1)
} catch (error) {
console.log(error);
useToast().open({
message:"初始化出错:"+error,
type:"error",
position:"top-right"
})
}
}
},
Expand All @@ -34,7 +39,6 @@ export const useSpeedStore = defineStore('speed', {

} catch (err) {
i.delay = "请求超时";
console.log({"当前索引:":i,"错误:":err});
continue;
}
}
Expand Down
Loading

0 comments on commit aafaf22

Please sign in to comment.