Skip to content

清华大学校园网 Rust 库与客户端

License

Notifications You must be signed in to change notification settings

Berrysoft/tunet-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

1c5dcb2 · Jan 20, 2025
Sep 3, 2023
Jun 20, 2023
May 6, 2023
Sep 22, 2024
Aug 17, 2024
Sep 22, 2024
Nov 4, 2024
Jan 20, 2025
Nov 18, 2024
Jan 20, 2025
Sep 23, 2024
Sep 21, 2024
Aug 17, 2024
Nov 18, 2024
Aug 17, 2024
Jun 24, 2023
Jan 20, 2025
Jan 20, 2025
Mar 3, 2023
Jul 14, 2023
Aug 10, 2024
Apr 21, 2023
Apr 26, 2023
Apr 26, 2023

Repository files navigation

tunet-rust

清华大学校园网 Rust 库与客户端。

Azure DevOps builds

GUI(桌面端)

基于 Slint 开发。使用如下命令启动:

$ tunet-gui
平台
Windows Windows Windows
Linux Linux (暂无图片)
macOS macOS macOS

GUI(移动端)

基于 Flutter 开发。会尽量保证 iOS 版本能用,但是没钱发布。

平台
Android Android Android

CUI(命令行图形界面)

使用如下命令启动:

# 使用默认(自动判断)方式登录/注销
$ tunet-cui
# 使用 auth4 方式登录/注销
$ tunet-cui -s auth4

Console

命令行

登录/注销

# 使用默认(自动判断)方式登录
$ tunet login
# 使用默认(自动判断)方式注销
$ tunet logout
# 使用 auth4 方式登录
$ tunet login -s auth4
# 使用 auth4 方式注销
$ tunet logout -s auth4

在线状态

# 使用默认(自动判断)方式
$ tunet status
# 使用 auth4 方式
$ tunet status -s auth4

查询/强制下线在线 IP

# 查询
$ tunet online
# IP 上线
$ tunet connect -a IP地址
# IP 下线
$ tunet drop -a IP地址

流量明细

# 使用默认排序(注销时间,升序)查询明细
$ tunet detail
# 使用登录时间(升序)查询明细
$ tunet detail -o login
# 使用流量降序查询明细
$ tunet detail -o flux -d
# 使用流量降序查询明细,并按注销日期组合
$ tunet detail -o flux -dg

Nushell 集成

statusonlinedetail 子命令支持 --nuon 参数,可以配合 Nushell 得到结构化的数据:

# 在线状态表格
> tunet status --nuon | from nuon
# 查询在线 IP 表格
> tunet online --nuon | from nuon
# 明细表格
> tunet detail --nuon | from nuon
# 使用流量降序查询明细,并按注销日期组合
> tunet detail -g --nuon | from nuon | sort-by flux -r

Windows 服务/macOS launchd

# 注册服务
$ tunet-service register
# 注册服务,并定时5分钟连接一次
$ tunet-service register -i "5min"
# 注销服务
$ tunet-service unregister

注意 tunet-service.exe 自身是服务程序,如需删除应先注销服务。

Systemd

由于不同 Linux 发行版的服务机制不同,没有提供 registerunregister 命令。 Debian 打包提供了 [email protected] 文件。对于用户 foo,可以运行

# 启用服务
$ sudo systemctl enable tunet@foo
# 启动服务
$ sudo systemctl start tunet@foo

可以通过编辑该文件来调整重复登录的间隔。

密码

用户名和密码在第一次登录时根据提示输入。请不要在不信任的电脑上保存密码。可以在桌面端图形界面点击“删除并退出”,或在命令行使用如下命令删除:

$ tunet deletecred

注意:由于 Linux 的限制,目前没有找到合适的持续化密码保存方法,因此会直接明文存储。

网络状态

针对不同平台使用平台特定的方式尝试获得当前的网络连接方式,如果是无线网连接还会获取 SSID。 如果无法获取,则尝试连接特定的网址来判断。

平台 网络状态 WIFI SSID MAC 地址
Windows Windows::Networking::Connectivity GetAdaptersAddresses
Linux (无) Netlink getifaddrs
Android ConnectivityManager WifiManager
macOS X System Configuration Core WLAN
iOS NEHotspotNetwork

编译说明

使用 cargo 直接编译:

$ cargo build --release --workspace --exclude native

即可在 target/release 下找到编译好的程序。

若要为 Android 编译 APK:

$ cd tunet-flutter
$ make apk

即可在 tunet-flutter/build/app/outputs/flutter-apk/app-<架构>-release.apk 找到打包。

安装说明

从 Releases 即可找到最新版分发。

Arch Linux

有第三方打包的 AUR 和 archlinuxcn 源可以安装。