Mmx233 / BitSrunLoginGo

深澜校园网登录程序 Go 语言版,适用于Windows、Linux、路由器等。提供对 Docker、Go Module、OpenWrt 的支持
GNU Affero General Public License v3.0
303 stars 27 forks source link

请问ac_id能否自动获取 #24

Closed qiaoborui closed 1 year ago

qiaoborui commented 1 year ago

如API地址为http://10.186.255.33,默认打开ac_id为1,但是可以访问1.1.1.1会自动重定向到含有正确ac_id的url

Mmx233 commented 1 year ago

这种重定向可能不能在任何情况下都正常工作,而且会让登录流程多一个请求。既然这个参数和别的参数在同一个请求里,那顺便复制一下问题也不大。添加 ac_id 自动获取可能并不划算

qiaoborui commented 1 year ago

是这样的,可能只是我们学校是这样做的,但是手动复制一定程度上降低了自动化的程度,假如设备的位置一直在变,导致acid的值也在改变,就需要每次手动修改,那么能否增添一个命令行参数用来覆盖配置文件中的acid,使得可以使用在使用shell脚本等工具拿到acid后传入bitsrun程序。

发自我的 iPad

在 2023年6月3日,17:18,Mmx @.***> 写道:



这种重定向可能不能在任何情况下都正常工作,而且会让登录流程多一个请求。既然这个参数和别的参数在同一个请求里,那顺便复制一下问题也不大。添加 ac_id 自动获取可能并不划算

— Reply to this email directly, view it on GitHubhttps://github.com/Mmx233/BitSrunLoginGo/issues/24#issuecomment-1574805514, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJQEFGQ7IT4IHDD44LRJP3TXJL6MHANCNFSM6AAAAAAYZFGDMU. You are receiving this because you authored the thread.Message ID: @.***>

Mmx233 commented 1 year ago

好的,稍后几天我会添加该功能

Mmx233 commented 1 year ago

我不建议现在就关闭 issue,我需要它提醒我还有个活没干。而且之后需要等你反馈良好之后我才会发布正式版,也就是说我们还要在这个 issue 交流

qiaoborui commented 1 year ago

你说的很对,谢谢提醒,我将会reopen this issue

Mmx233 commented 1 year ago

现在可以用 --acid 9 覆盖配置文件 acid 配置,可以使用 --auto-acid 开启自动检测。测试时请使用 --debug 打开测试日志以便追踪错误。

bitsrun_aix_ppc64.zip bitsrun_android_arm64.zip bitsrun_darwin_amd64.zip bitsrun_darwin_arm64.zip bitsrun_dragonfly_amd64.zip bitsrun_freebsd_386.zip bitsrun_freebsd_amd64.zip bitsrun_freebsd_arm.zip bitsrun_freebsd_arm64.zip bitsrun_illumos_amd64.zip bitsrun_js_wasm.zip bitsrun_linux_386.zip bitsrun_linux_amd64.zip bitsrun_linux_arm.zip bitsrun_linux_arm64.zip bitsrun_linux_mips.zip bitsrun_linux_mips_softfloat.zip bitsrun_linux_mips64.zip bitsrun_linux_mips64_softfloat.zip bitsrun_linux_mips64le.zip bitsrun_linux_mips64le_softfloat.zip bitsrun_linux_mipsle.zip bitsrun_linux_mipsle_softfloat.zip bitsrun_linux_ppc64.zip bitsrun_linux_ppc64le.zip bitsrun_linux_riscv64.zip bitsrun_linux_s390x.zip bitsrun_netbsd_386.zip bitsrun_netbsd_amd64.zip bitsrun_netbsd_arm.zip bitsrun_netbsd_arm64.zip bitsrun_openbsd_386.zip bitsrun_openbsd_amd64.zip bitsrun_openbsd_arm.zip bitsrun_openbsd_arm64.zip bitsrun_solaris_amd64.zip bitsrun_windows_386.zip bitsrun_windows_amd64.zip bitsrun_windows_arm.zip bitsrun_windows_arm64.zip

qiaoborui commented 1 year ago

acid配置覆盖测试没有问题,但顺便问一下auto detect作用是什么?


#!/bin/bash
AC_ID=""
IP="1.1.1.1"

function check_access(){    
    RESP_CODE=$(curl -s --noproxy 1.1.1.1 -o /dev/null -w "%{http_code}" $IP)
    if [ $RESP_CODE == "302" ]; then
        AC_ID=$(curl -s -I -X GET $IP | grep -i "index_.*\.html" | awk -F'[._]' '{print $5}')
    elif [ $RESP_CODE == "200" ]; then
        AC_ID=$(curl -s $IP | grep -o "index_.*\.html" | head -n 1 | awk -F'[._]' '{print $2}' 2>/dev/null)
    elif [ $RESP_CODE == "301" ]; then
        # 未找到情况
        echo "IP地址不存在!"
        return 1
    else
        # 其他响应情况,可能是被封禁等
        echo "未知错误!"
        return 1
    fi

    if [ -z "$AC_ID" ]; then
        echo "没有找到AC_ID!"
        return 1
    fi
    return 0 
}

# 检查依赖
if ! command -v curl &> /dev/null; then
    echo "请安装curl!"
    exit 1
fi

# 检查访问
check_access
if [ $? -eq 1 ]; then
    exit 1
else
    echo "获取AC_ID成功"
    ./bitsrun --acid $AC_ID
fi

用来测试的shell脚本

Mmx233 commented 1 year ago

自动查找 acid