Skip to content

Commit

Permalink
✨ feat(request): login wifi and update
Browse files Browse the repository at this point in the history
  • Loading branch information
CakeAL committed Nov 12, 2024
1 parent 746de13 commit 72f0f87
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ustb-wifi-tools",
"private": true,
"version": "0.8.7",
"version": "0.8.8",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
Binary file added public/QQ_1731406861238.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
57 changes: 54 additions & 3 deletions src-tauri/src/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -580,12 +583,60 @@ pub async fn get_ammeter(num: u32) -> Result<Option<i32>> {
}

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::<Vec<&str>>();
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(&params)
.send()
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/pages/About.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const show1 = ref(false);
<p>4. 通过 pt 站下载大型软件(比如 Photoshop 等)</p>
<p>5. 自建/使用 ipv6 代理服务器</p>
<br />
<p>当前 version = "0.8.7"</p>
<p>当前 version = "0.8.8"</p>
</n-space>
</n-card>
</div>
Expand Down
7 changes: 5 additions & 2 deletions src/pages/UnbindMacs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,11 @@ const set_mac_custom_name = async (mac: string, index: number) => {
<n-image width="300" src="/QQ_1731405540124.png" />
</div>
</n-collapse-item>
<n-collapse-item title="Windows" name="3">
<div>d</div>
<n-collapse-item title="Windows 设备固定 MAC 地址方法" name="3">
<div>
<p>网络和 Internet -> WLAN -> 属性 -> 随机硬件地址 -> 关</p>
<n-image width="550" src="/QQ_1731406861238.png" />
</div>
</n-collapse-item>
</n-collapse>
</n-card>
Expand Down

0 comments on commit 72f0f87

Please sign in to comment.