sing-box icon indicating copy to clipboard operation
sing-box copied to clipboard

脚本输入完端口卡住

Open CarterLeeAlt opened this issue 10 months ago • 2 comments

脚本输入完端口卡住,如图 用的bytevirt的kvm机器,singbox和xray、v2ray脚本都有这个问题

PS: 其实在检测公网ip这步就会卡住,将get_ip()函数替换为以下才能继续,然后输入端口后就又卡住了

get_ip() {
    # 只获取IPv4地址,尝试多个API
    local api_endpoints=(
        "https://api-ipv4.ip.sb/geoip"
        "https://api.ipapi.is"
    )
    
    for api in "${api_endpoints[@]}"; do
        local response=$(_wget -4 -qO- "$api" 2>/dev/null)
        if [[ -n "$response" ]]; then
            # 尝试解析JSON响应获取IP
            local extracted_ip=$(echo "$response" | jq -r '.ip // .query // .address // .ip_address' 2>/dev/null)
            if [[ -n "$extracted_ip" && "$extracted_ip" != "null" ]]; then
                export ip="$extracted_ip"
                return 0
            fi
        fi
        # 短暂延迟,避免请求过快
        sleep 0.5
    done
    
    # 如果所有API都失败,返回空
    export ip=""
    return 1
}
Image

CarterLeeAlt avatar Jan 14 '26 15:01 CarterLeeAlt

破案了,把[core.sh]里的get_ip()函数也替换成上面那段就正常了。。。

CarterLeeAlt avatar Jan 14 '26 15:01 CarterLeeAlt

又是获取ip 的问题,直接export ip=xx 就行

233boy avatar Jan 15 '26 00:01 233boy