1
0
mirror of https://github.com/QSCTech/zjunet.git synced 2026-01-22 03:34:48 +08:00

deprecate WLAN function

This commit is contained in:
Azuk 443 2023-12-21 15:39:53 +08:00
parent 89810b80c9
commit ff6ed1ab75
No known key found for this signature in database
GPG Key ID: A9F74F20D8C045FB
9 changed files with 12 additions and 144 deletions

View File

@ -22,8 +22,6 @@ Command Line Scripts for ZJU (VPN / WLAN / DNS)
- xl2tpd
- curl
- `dig` (Different package on different platform)
## Installation
@ -80,7 +78,7 @@ Please complete installation before connecting to the intranet.
### Other Linux (Build from source code)
```bash
xl2tpd -v; curl -V; dig -v # Check installation of dependencies. There should be 3 version numbers.
xl2tpd -v; dig -v # Check installation of dependencies. There should be 3 version numbers.
# Under proper directory
git clone https://github.com/QSCTech/zjunet.git
cd zjunet
@ -90,7 +88,7 @@ sudo ./install.sh
```
**ATTENTION** Requirement check will **NOT** be done running `./install.sh`.
Please run `xl2tpd -v`, `curl -V` and `dig -v` to verify the installation.
Please run `xl2tpd -v` and `dig -v` to verify the installation.
## Troubleshooting

View File

@ -20,8 +20,6 @@
- xl2tpd
- curl
- `dig` (在不同平台的包不同)
## 安装
@ -83,7 +81,7 @@ sudo yum install zjunet
### 其他 Linux (源代码安装)
```bash
xl2tpd -v; curl -V; dig -v # 检查依赖命令的安装情况。这句命令将输出三个版本号。
xl2tpd -v; dig -v # 检查依赖命令的安装情况。这句命令将输出三个版本号。
# 在合适的目录下
git clone https://github.com/QSCTech/zjunet.git
cd zjunet
@ -93,7 +91,7 @@ sudo ./install.sh
```
**注意** 运行 `./install.sh`**不会** 确认必要依赖是否已经安装。
您应当先运行 `xl2tpd -v``curl -V` 和 `dig -v` 确认安装。
您应当先运行 `xl2tpd -v``dig -v` 确认安装。
## 疑难解答

View File

@ -26,7 +26,7 @@ pkgdesc="Command Line Scripts for ZJU"
url="https://github.com/QSCTech/$PKGNAME"
arch=('any')
license=('GPL')
depends=('xl2tpd>=1.3.7' 'curl' 'dnsutils')
depends=('xl2tpd>=1.3.7' 'dnsutils')
source=("$PKGNAME-$PKGVER.tar.gz::https://github.com/QSCTech/$PKGNAME/archive/v$PKGVER.tar.gz")
md5sums=('$FILE_MD5')
sha1sums=('$FILE_SHA1')

View File

@ -36,7 +36,7 @@ Version: $VERSION
Section: net
Priority: optional
Architecture: all
Depends: xl2tpd (>= 1.3.7), curl, dnsutils
Depends: xl2tpd (>= 1.3.7), dnsutils
Maintainer: Azuk 443 <me@azuk.top>
Description: Command Line Scripts for ZJU Campus Network
This script provides a VPN / WLAN / NEXTHOP for ZJUer.

View File

@ -26,7 +26,7 @@ Version: $VERSION
Section: net
Priority: optional
Architecture: all
Depends: xl2tpd (>= 1.3.7), curl, bind-dig
Depends: xl2tpd (>= 1.3.7), bind-dig
Maintainer: Azuk 443 <me@azuk.top>
Description: Command Line Scripts for ZJU Campus Network
This script provides a VPN / WLAN / NEXTHOP for ZJUer.

View File

@ -13,7 +13,7 @@ echo "Group: Applications/Internet" >> zjunet.spec
echo "URL: https://github.com/QSCTech/zjunet/" >> zjunet.spec
echo "Vendor: Qiu Shi Chao Website of Zhejiang University" >> zjunet.spec
echo "Packager: Azuk 443 <me@azuk.top>" >> zjunet.spec
echo "Requires: xl2tpd >= 1.3.7, curl, bind-utils" >> zjunet.spec
echo "Requires: xl2tpd >= 1.3.7, bind-utils" >> zjunet.spec
echo "BuildRoot: %{_builddir}/%{name}-root" >> zjunet.spec
echo "Source: %{name}-%{version}.tar.gz" >> zjunet.spec
echo "BuildArch: noarch" >> zjunet.spec

View File

@ -103,20 +103,6 @@ for dev in $devs; do
cmd="${cmd} nexthop dev ${dev}"
done
case "$gateway" in
10.189.*)
# WLAN
zjuwlan_test_ip=10.202.68.46
ip route replace $zjuwlan_test_ip via ${gateway}
zjuwlan_status=`curl -s $zjuwlan_test_ip | grep net.zju.edu.cn | wc -l`
if [ $zjuwlan_status -eq 0 ]
then
cmd="${cmd} nexthop via ${gateway}"
fi
ip route del $zjuwlan_test_ip || true
;;
esac
$cmd
ip route

View File

@ -2,11 +2,10 @@
# wlan.sh -- login/logout for ZJUWLAN
#
# Requirements: curl
#
# Copyright (C) 2014 Zhang Hai <Dreaming.in.Code.ZH@Gmail.com>
# Copyright (C) 2014 Zeno Zeng <zenoofzeng@gmail.com>
# Copyright (C) 2017 Wu Fan <wfwf1997@gmail.com>
# Copyright (C) 2023 Azuk 443 <azukmm@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -22,114 +21,5 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
BASEDIR=$(dirname $0)
DISABLE_CHECK=${BASEDIR}/.disable-wlan
USER="${BASEDIR}/user.sh"
USERNAME=$($USER get)
PASSWORD=$($USER getpwd $USERNAME)
if [ -f "${DISABLE_CHECK}" ]; then
echo WLAN function has been disabled.;
exit 1;
fi
logout() {
USERNAME=$1
PASSWORD=$2
echo "Logout: ${USERNAME}"
RESPONSE=$(curl "https://net.zju.edu.cn/include/auth_action.php" -H "Content-Type: application/x-www-form-urlencoded" -d "action=logout&username=${USERNAME}&password=${PASSWORD}&ajax=1" -s)
if [ $? -eq 60 ]; then
CHOOSE=''
read -p "There's an issue with ZJUNET's CA certificates, do you want to do it anyway? [yes/NO] " CHOOSE
if [ $CHOOSE = "YES" ] || [ $CHOOSE = "yes" ]; then
RESPONSE=$(curl "https://net.zju.edu.cn/include/auth_action.php" -H "Content-Type: application/x-www-form-urlencoded" -d "action=logout&username=${USERNAME}&password=${PASSWORD}&ajax=1" -s -k)
fi
fi
case "${RESPONSE}" in
*ok*)
echo "Logout: success."
;;
*已断开*)
echo "Logout: success."
;;
*)
echo "Logout: unsuccess."
echo "${RESPONSE}"
exit 1;
;;
esac
}
login() {
USERNAME=$1
PASSWORD=$2
STATUS=$(curl http://g.cn/generate_204 -I -s | grep HTTP | awk {'print $2'})
if [ $STATUS -eq 204 ]; then
echo "You have already logged in."
exit 0
fi
echo "Login: ${USERNAME}"
RESPONSE=$(curl "https://net.zju.edu.cn/include/auth_action.php" -H "Content-Type: application/x-www-form-urlencoded" -d "action=login&username=${USERNAME}&password=${PASSWORD}&ac_id=3&user_ip=&nas_ip=&user_mac=&save_me=1&ajax=1" -s)
if [ $? -eq 60 ]; then
CHOOSE=''
read -p "There's an issue with ZJUNET's CA certificates, do you want to do it anyway? [yes/NO] " CHOOSE
if [ $CHOOSE = "YES" ] || [ $CHOOSE = "yes" ]; then
RESPONSE=$(curl "https://net.zju.edu.cn/include/auth_action.php" -H "Content-Type: application/x-www-form-urlencoded" -d "action=login&username=${USERNAME}&password=${PASSWORD}&ac_id=3&user_ip=&nas_ip=&user_mac=&save_me=1&ajax=1" -s -k)
fi
fi
case "${RESPONSE}" in
*help.html*)
echo "Login: success."
;;
*login_ok*)
echo "Login: success."
;;
*E2532*)
echo "Login: failed. Please retry after 10s." >&2
echo "Login: ${RESPONSE}" >&2
exit 1
;;
*)
echo "Login: failed." >&2
if [ -z "${RESPONSE}" ]; then
echo "Login: (Empty response)" >&2
else
echo "Login: ${RESPONSE}" >&2
fi
exit 1
;;
esac
}
case "$1" in
d|-d|disconnect)
logout $USERNAME $PASSWORD
;;
""|c|-c|connect)
login $USERNAME $PASSWORD
;;
disable)
"${BASEDIR}/sudo.sh" touch "${DISABLE_CHECK}"
exit 0
;;
*)
echo Invalid subcommand \"$1\" for \`zjunet wlan\`. Run \`zjunet usage\` for help.
;;
esac
"${BASEDIR}/sudo.sh" "${BASEDIR}/route.sh"
echo "zjunet WLAN function is deprecated."
exit 1

View File

@ -3,6 +3,7 @@
# zjunet.sh -- router for zjunet
#
# Copyright (C) 2014 Zeno Zeng <zenoofzeng@gmail.com>
# Copyright (C) 2023 Azuk 443 <azukmm@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -64,10 +65,6 @@ Actions:
vpn, v
connect, -c Connect VPN and set up ip route
disconnect, -d Disconnect VPN and reset ip route
wlan, w
connect, -c Login ZJUWLAN using curl
disconnect, -d Logout ZJUWLAN using curl
disable Disable WLAN capability
route, r Set up static route
dns [ip], d [ip] Test and set up DNS Server (default: 10.10.0.21)
version, -v Display program version
@ -76,7 +73,6 @@ Example:
zjunet user add Add a new user
zjunet vpn -c Connect VPN
zjunet vpn -d Disconnect VPN
zjunet wlan disable Completely disable WLAN capatibility
EOF
;;
esac