V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
OpenWrt 是一个专门面向嵌入式设备的 Linux 发行版。你可以将 OpenWrt 支持的型号的嵌入式设备,比如各种路由器上的系统,换成一个有更多可能性可以折腾的 Linux 系统。
OpenWrt 官方网站
xinmans
V2EX  ›  OpenWrt

咨询一个问题,我们有没有办法检测 github 的访问来切换线路, openwrt 里有这种脚本吗?

  •  
  •   xinmans · 191 天前 via iPhone · 839 次点击
    这是一个创建于 191 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我现在发现需要频繁切换线路来规避无法访问 github ,很烦躁
    12 条回复    2023-11-09 13:46:20 +08:00
    AoEiuV020JP
        1
    AoEiuV020JP  
       191 天前
    线程指的是梯子?那么关键应该是你用的是什么梯子,而不是 openwrt ,
    比如 clash 的 url-test , 你可以置顶 test 地址为 github ,那就会自动选择能上 github 的节点了,
    不过 github 很容易连不上吗?
    AoEiuV020JP
        2
    AoEiuV020JP  
       191 天前
    @AoEiuV020JP #1 线程=>线路,
    AreYou0k
        3
    AreYou0k  
       191 天前
    @AoEiuV020JP #1 确实, 除了 clash 自动切换其它的都差点意思.
    xinmans
        4
    xinmans  
    OP
       191 天前 via iPhone
    @AoEiuV020JP 用的 passwall 。
    TinyBBC
        5
    TinyBBC  
       191 天前
    个人认为,是不是你的鸡厂不太行啊。。。
    xinmans
        6
    xinmans  
    OP
       191 天前 via iPhone
    @TinyBBC 有好的鸡场可以推荐给我
    flynaj
        7
    flynaj  
       190 天前 via Android
    mwan3 smartdns ,无感
    xinmans
        8
    xinmans  
    OP
       189 天前 via iPhone
    @flynaj nwan3 略显复杂啊,我还是自己写自己来切换吧
    xinmans
        9
    xinmans  
    OP
       189 天前 via iPhone
    写了一个脚本实现我需要的能力



    #!/bin/sh


    check_node_availability() {
    local url=$1
    response=$(curl -s -I "$url")
    if echo "$response" | grep -q "200 OK"; then
    echo "$url is accessible"
    return 0
    else
    echo "$url is not accessible"
    return 1
    fi
    }

    check_url() {
    success_count=0
    for _ in 1 2 3
    do
    if check_node_availability "https://github.com"; then
    success_count=$((success_count + 1))
    fi
    wait
    sleep 3
    done
    return "$success_count"
    }

    while :
    do
    # 只在美国和英国节点间切换 tail -10
    for node_id in `uci export passwall | grep 'config nodes' | tail -10 | awk '{print $3}'`; do
    eval "i=${node_id}"
    uci delete passwall.@global[0].tcp_node
    wait
    uci add_list passwall.@global[0].tcp_node=${i}
    uci show passwall.@global[0].tcp_node
    wait
    uci commit passwall
    wait
    /etc/init.d/passwall restart
    wait
    sleep 10
    while :
    do
    success_count=$(check_url)
    if [ "$success_count" -ne 3 ]; then
    echo "Switching to another node..."
    break
    else
    sleep 600
    fi
    done
    done
    done
    linuxgo
        10
    linuxgo  
       172 天前
    op 里很多插件都可以自动切换线路啊
    xinmans
        11
    xinmans  
    OP
       171 天前 via iPhone
    @linuxgo 推荐一个?
    linuxgo
        12
    linuxgo  
       171 天前
    @xinmans #11 openclash ,passwall ,helloworld ,bypass ,这些都可以
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1493 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 17:09 · PVG 01:09 · LAX 10:09 · JFK 13:09
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.