V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
knighttools
V2EX  ›  程序员

一键配置本地代理告别 404 和 SSL Error

  •  
  •   knighttools · 1 天前 · 1205 次点击

    开发的目的:

    解决了每次需要自己手动设置 http_proxy 的麻烦,一键配置,喜欢的同学给个 Star ,感谢🙏

    功能:

    🚀 一键启动/停止/切换代理设置

    🔍 自动检测代理端口 (支持 7890,7891,7892,7893, 8888, 8080) --- 这样就不需要点击 clashmeta 复制终端代理命令,然后粘贴到控制台粘贴这种频繁的操作

    📊 显示详细的代理状态信息

    🌐 测试互联网和代理连接

    ⚙️ 支持设置自定义代理地址

    🔄 一键切换代理状态

    一个轻量级、功能强大的代理管理脚本,适用于 Bash 和 Zsh ,一键配置 http_proxy,https_proxy,socks5_proxy,all_proxy.

    带有一个 cli 快捷切换.

    image.png

    image.png

    image.png

    地址:

    链接

    24 条回复    2025-07-12 16:41:58 +08:00
    wenrouxiaozhu
        1
    wenrouxiaozhu  
       1 天前
    我一般这样
    alias proxy="export https_proxy=http://127.0.0.1:7890;export http_proxy=http://127.0.0.1:7890;export all_proxy=socks5://127.0.0.1:7890"
    alias unproxy="unset https_proxy http_proxy all_proxy"
    knighttools
        2
    knighttools  
    OP
       1 天前
    @wenrouxiaozhu 是的,本质上是做差不多的事,不过我这边把他做成工具,能支持配置,自动检测和开关,本质上还是方便开发!
    383394544
        3
    383394544  
       1 天前   ❤️ 1
    怎么不用 zsh-osx-autoproxy
    https://github.com/SukkaW/zsh-osx-autoproxy
    383394544
        4
    383394544  
       1 天前
    看了你检测代理的方式... 这啥

    detect_proxy() {
    # Test common proxy ports: 7890, 7891, 7892,7893,8888, 8080
    # 测试常见代理端口: 7890, 7891, 7892,7893,8888, 8080
    for port in {7890,7891,7892,7893,8888,8080}; do
    if curl -s --proxy "http://127.0.0.1:$port" https://example.com >/dev/null 2>&1; then
    PROXY_ADDRESS="http://127.0.0.1:$port"
    SOCKS_ADDRESS="socks5://127.0.0.1:$port"
    echo "[Proxy] Auto detected port: $port" >&2
    return
    fi
    done
    # If no proxy detected, keep default settings
    # 如果未检测到代理,保留默认设置
    echo "[Proxy] ⚠️ No proxy detected, using default settings" >&2
    }

    用其他端口的怎么办
    knighttools
        5
    knighttools  
    OP
       1 天前
    @383394544 默认检测这些端口,默认当做代理端口,如果存在则自动配置为本地代理
    knighttools
        6
    knighttools  
    OP
       1 天前
    @383394544 各有优劣吧,本质还是自己想到这么个想法,就去做了~
    383394544
        7
    383394544  
       1 天前 via iPhone
    @knighttools #6 神 tm 各有优劣 你如果发帖是为了获得掌声而听不进改进建议还是去 nodeseek 吧
    383394544
        8
    383394544  
       1 天前 via iPhone
    @knighttools 那我问你 如果代理不是 127.0.0.1 怎么办 如果代理是随机端口怎么办 而且你这个还要输入指令 其他项目可以做到自动化设置 不进你的更方便
    383394544
        9
    383394544  
       1 天前 via iPhone
    *比你的更方便
    17681880207
        10
    17681880207  
       1 天前
    v2rayN 的默认端口是 10808 / +3 / +4 / +5
    luojianxhlxt
        11
    luojianxhlxt  
       1 天前
    @17681880207 #10 新版本已经 mix 端口了
    sunny2580839896
        12
    sunny2580839896  
       1 天前 via iPhone
    我拉取 docker 镜像必须配置局域网的地址,配置 127 会导致报错
    w568w
        13
    w568w  
       1 天前
    我总感觉看到过类似工具。OP 用过 https://github.com/RubyMetric/chsrc 吗(虽然场景略微不一样)
    xljya
        14
    xljya  
       1 天前
    可以分享一下字体吗,感觉挺好看
    knighttools
        15
    knighttools  
    OP
       12 小时 18 分钟前
    @383394544 不喜欢可以不用呢,没人逼你用呢,哥哥
    knighttools
        16
    knighttools  
    OP
       12 小时 17 分钟前
    @sunny2580839896 有问题可以提 issue ,合理的我会采纳的,感谢~
    knighttools
        17
    knighttools  
    OP
       12 小时 17 分钟前
    @383394544 这里不欢迎杠精哈,问就是你对
    knighttools
        18
    knighttools  
    OP
       12 小时 14 分钟前
    @383394544 那我问你 如果代理不是 127.0.0.1 怎么办 如果代理是随机端口怎么办 而且你这个还要输入指令 其他项目可以做到自动化设置 不进你的更方便 ,回答你的问题,如果不是 127.0.0.1 ,随机端口,你哪怕自己装一下或者看一眼图也不会问出来这种问题,pset 干嘛用的?
    knighttools
        19
    knighttools  
    OP
       12 小时 12 分钟前
    @383394544 最烦你这种上来就要杠,我又不是你爹,脑子不好别上网还 nodeseek ,ns 人怎么你了,自己都没独立思考能力,上来就杠
    knighttools
        20
    knighttools  
    OP
       12 小时 9 分钟前
    @w568w 倒是写之前没有去看市面上有没有类似的,只是觉得很简单的一个功能,想到就去写了,如有雷同纯属巧合哈。
    knighttools
        21
    knighttools  
    OP
       12 小时 9 分钟前
    @xljya Mac 自带的,没改过字体
    knighttools
        22
    knighttools  
    OP
       12 小时 7 分钟前
    @sunny2580839896 不是改 docker 镜像源就好了吗,实在不行走全局,这个就不在本脚本的范围内了吧。
    sunny2580839896
        23
    sunny2580839896  
       11 小时 33 分钟前
    @knighttools 好的,谢谢大佬
    kevinhwang
        24
    kevinhwang  
       11 小时 27 分钟前
    抛开项目,其实现在 V2EX 没什么好逛了,质量一直降低。跟网络相关的推广发 nodeseek 会好点很多
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   893 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 20:09 · PVG 04:09 · LAX 13:09 · JFK 16:09
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.