Files
hideck/internal/device/cellular_ims_path.go
yibaiba 6b36b700ac fix(proxy): cap country-pool pick wait and skip unused probes
Pick-time SOCKS5 checks use a 2s budget and cancel after the first
UDP-healthy peer plus a short grace. Cellular starts that bind the
modem interface no longer probe the country pool. Hit logs include
pick tier and skipped-node diagnosis.
2026-09-13 00:24:24 +08:00

48 lines
1.3 KiB
Go

package device
import (
"fmt"
"strings"
"github.com/iniwex5/vowifi-go/runtimehost"
)
type cellularIMSTransport struct {
BindInterface string
Proxy *runtimehost.ProxyConfig
ViaProxy bool
}
func classifyCellularIMSError(err error) error {
if err == nil {
return nil
}
msg := err.Error()
if strings.Contains(msg, "无法访问外网") {
return err
}
if strings.Contains(msg, "ePDG") || strings.Contains(msg, "SWu tunnel") {
return fmt.Errorf("蜂窝数据无法到达运营商 ePDG: %w", err)
}
return err
}
func cellularIMSUsesBoundInterface(hasInternet bool, iface string) bool {
return hasInternet && strings.TrimSpace(iface) != ""
}
func selectCellularIMSTransport(hasInternet bool, iface string, proxy *runtimehost.ProxyConfig) (cellularIMSTransport, error) {
iface = strings.TrimSpace(iface)
proxyReady := proxy != nil && proxy.Enabled && strings.TrimSpace(proxy.Addr) != ""
if cellularIMSUsesBoundInterface(hasInternet, iface) {
return cellularIMSTransport{BindInterface: iface}, nil
}
if proxyReady {
return cellularIMSTransport{Proxy: proxy, ViaProxy: true}, nil
}
if !hasInternet {
return cellularIMSTransport{}, fmt.Errorf("蜂窝数据已连接但无法访问外网,无法到达 ePDG")
}
return cellularIMSTransport{}, nil
}