diff --git a/package.json b/package.json index 0fef1f8..fb67591 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ustb-wifi-tools", "private": true, - "version": "0.8.7", + "version": "0.8.8", "type": "module", "scripts": { "dev": "vite", diff --git a/public/QQ_1731406861238.png b/public/QQ_1731406861238.png new file mode 100644 index 0000000..4aa4983 Binary files /dev/null and b/public/QQ_1731406861238.png differ diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 6f112da..4bc9f1d 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -4626,7 +4626,7 @@ dependencies = [ [[package]] name = "ustb-wifi-tools" -version = "0.8.7" +version = "0.8.8" dependencies = [ "anyhow", "chrono", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 3eb80d4..24dc952 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ustb-wifi-tools" -version = "0.8.7" +version = "0.8.8" description = "A Tauri App that can be used to get information of the USTB Wifi" authors = ["CakeAL"] edition = "2021" diff --git a/src-tauri/src/requests.rs b/src-tauri/src/requests.rs index daef400..177fe37 100644 --- a/src-tauri/src/requests.rs +++ b/src-tauri/src/requests.rs @@ -4,7 +4,10 @@ use anyhow::{anyhow, Result}; use chrono::NaiveDateTime; use rand::Rng; use regex::Regex; -use reqwest::{header::SET_COOKIE, Client}; +use reqwest::{ + header::{LOCATION, SET_COOKIE}, + redirect, Client, +}; use scraper::{Html, Selector}; use serde_json::Value; @@ -580,12 +583,60 @@ pub async fn get_ammeter(num: u32) -> Result> { } pub async fn login_ustb_wifi(account: &str, password: &str) -> Result<()> { + let client = reqwest::Client::builder() + .redirect(redirect::Policy::none()) // 设置为不自动重定向 + .build()?; + // 第一次请求 login.ustb.edu.cn + let response = client.get("http://login.ustb.edu.cn/").send().await?; + if response.status().as_u16() != 302 { + return Err(anyhow!("Request {}", response.status())); + } + let location = response + .headers() + .get(LOCATION) + .and_then(|value| value.to_str().ok()) + .unwrap_or_default(); + let wlan_user_ipv6 = location.split(['=', '&']).nth(1).unwrap_or_default(); + + // dbg!(wlan_user_ipv6); + // 第二次请求 1.htm + let response = client + .get("http://202.204.48.82/1.htm") + .query(&[("mv6", wlan_user_ipv6), ("url", "")]) + .send() + .await?; + if response.status().as_u16() != 302 { + return Err(anyhow!("Request {}", response.status())); + } + let location = response + .headers() + .get(LOCATION) + .and_then(|value| value.to_str().ok()) + .unwrap_or_default(); + let ips = location.split(['=', '&']).collect::>(); + let (wlan_user_ip, wlan_ac_name, wlan_ac_ip) = ( + ips.get(1).copied().unwrap_or_default(), + ips.get(3).copied().unwrap_or_default(), + ips.get(5).copied().unwrap_or_default().replace("%2E", "."), + ); + dbg!(wlan_user_ipv6, wlan_user_ip, wlan_ac_name, &wlan_ac_ip); + let params = [ + ("callback", "dr1004"), + ("login_method", "1"), ("user_account", account), ("user_password", password), - ("wlan_ac_ip", "10.0.124.68"), + ("wlan_user_ip", wlan_user_ip), + ("wlan_user_ipv6", wlan_user_ipv6), + ("wlan_user_mac", "000000000000"), + ("wlan_ac_ip", &wlan_ac_ip), + ("wlan_ac_name", wlan_ac_name), + ("jsVersion", "4.1"), + ("terminal_type", "1"), + ("lang", "zh-cn"), + ("v", "2213"), ]; - let response = Client::new() + let response = client .get("http://202.204.48.66:801/eportal/portal/login") .query(¶ms) .send() diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 62a3faf..5cc91b0 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "productName": "ustb-wifi-tools", "mainBinaryName": "ustb-wifi-tools", - "version": "0.8.7", + "version": "0.8.8", "identifier": "ustb.wifi.tools", "build": { "beforeDevCommand": "pnpm dev", diff --git a/src/pages/About.vue b/src/pages/About.vue index 8bc5f30..b296d5a 100644 --- a/src/pages/About.vue +++ b/src/pages/About.vue @@ -118,7 +118,7 @@ const show1 = ref(false);

4. 通过 pt 站下载大型软件(比如 Photoshop 等)

5. 自建/使用 ipv6 代理服务器


-

当前 version = "0.8.7"

+

当前 version = "0.8.8"

diff --git a/src/pages/UnbindMacs.vue b/src/pages/UnbindMacs.vue index bf5648b..e40d5d5 100644 --- a/src/pages/UnbindMacs.vue +++ b/src/pages/UnbindMacs.vue @@ -145,8 +145,11 @@ const set_mac_custom_name = async (mac: string, index: number) => { - -
d
+ +
+

网络和 Internet -> WLAN -> 属性 -> 随机硬件地址 -> 关

+ +