mirror of
https://github.com/yibaiba/hideck.git
synced 2026-12-05 16:02:17 +00:00
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.
48 lines
1.3 KiB
Go
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
|
|
}
|