mirror of
https://github.com/yibaiba/hideck.git
synced 2026-12-06 08:02:21 +00:00
feat: integrate rewritten vowifi-go (binary-faithful imscore/voice API)
Replace third_party/vowifi-go with the reverse-engineered rewrite that matches the v1.5.5 binary's actual vowifi-go (internal/vowifi/imscore + internal/vowifi/voice), and adapt the host code to its API: - device: modemAdapter/qmiModemAdapter implement runtimehost.Modem (Capabilities, IMSIdentityProvider) and identity.Access; SetLogger uses slog.Default() - api: GetSMSDeliveryStatus passes ctx - platform shims so the Linux-targeted code compiles on macOS for tests: SO_BINDTODEVICE consts (netprobe/proxy/qmi), qmi control-device-holder stub, udev build-tag + no-op stub - test modems implement the runtimehost.Modem interface Result: 25 packages pass on macOS; only internal/web + cmd/vohive fail on the pre-existing missing web dist assets (//go:embed all:dist). The vowifi-go module itself builds on both macOS and Linux. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
de689a554d
commit
320ef758c0
300 files changed
+30145
-1337
No files matched your search
@@ -0,0 +1,2 @@
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
@@ -1070,7 +1070,7 @@ func (s *Server) handleSMSDelivery(c *gin.Context) {
|
||||
if svc == nil {
|
||||
continue
|
||||
}
|
||||
status, err := svc.GetSMSDeliveryStatus(messageID)
|
||||
status, err := svc.GetSMSDeliveryStatus(c.Request.Context(), messageID)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ func (m vowifiIdentityTestModem) IsSimInserted() bool { return true
|
||||
func (m vowifiIdentityTestModem) QuerySIMInserted() (bool, error) { return true, nil }
|
||||
func (m vowifiIdentityTestModem) GetRegStatus() (int, string) { return 1, "已注册" }
|
||||
func (m vowifiIdentityTestModem) GetNetworkMode() string { return "LTE" }
|
||||
func (m vowifiIdentityTestModem) Capabilities() runtimehost.ModemCapabilities { return runtimehost.ModemCapabilities{} }
|
||||
func (m vowifiIdentityTestModem) IMSIdentityProvider() runtimehost.IMSIdentityProvider { return m }
|
||||
func (m vowifiIdentityTestModem) ExecuteATSilent(string, time.Duration) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/iniwex5/vohive/internal/backend"
|
||||
"github.com/iniwex5/vohive/pkg/logger"
|
||||
"github.com/iniwex5/vowifi-go/runtimehost"
|
||||
"github.com/iniwex5/vowifi-go/runtimehost/identity"
|
||||
)
|
||||
|
||||
@@ -123,3 +124,13 @@ func (a *qmiModemAdapter) Stop() {
|
||||
logger.Info("QMI modem adapter Stop() 被调用(不关闭 Backend,由 Worker 统一管理)",
|
||||
"device", a.deviceID)
|
||||
}
|
||||
|
||||
// Capabilities reports the modem capabilities (runtimehost.Modem).
|
||||
func (a *qmiModemAdapter) Capabilities() runtimehost.ModemCapabilities {
|
||||
return runtimehost.ModemCapabilities{}
|
||||
}
|
||||
|
||||
// IMSIdentityProvider returns the modem's identity provider.
|
||||
func (a *qmiModemAdapter) IMSIdentityProvider() runtimehost.IMSIdentityProvider {
|
||||
return a
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
//go:build linux
|
||||
|
||||
package device
|
||||
|
||||
import (
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//go:build !linux
|
||||
|
||||
package device
|
||||
|
||||
// UdevWatcher is a no-op on non-Linux platforms (udev is Linux-only).
|
||||
type UdevWatcher struct{}
|
||||
|
||||
// NewUdevWatcher returns a no-op watcher.
|
||||
func NewUdevWatcher(pool *Pool) *UdevWatcher { return &UdevWatcher{} }
|
||||
|
||||
// Start is a no-op.
|
||||
func (w *UdevWatcher) Start() {}
|
||||
|
||||
// Stop is a no-op.
|
||||
func (w *UdevWatcher) Stop() {}
|
||||
@@ -1,3 +1,5 @@
|
||||
//go:build linux
|
||||
|
||||
package device
|
||||
|
||||
import "testing"
|
||||
|
||||
@@ -89,3 +89,13 @@ func normalizeVoWiFiAPDUError(err error) error {
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// Capabilities reports the modem capabilities (runtimehost.Modem).
|
||||
func (a *modemAdapter) Capabilities() runtimehost.ModemCapabilities {
|
||||
return runtimehost.ModemCapabilities{}
|
||||
}
|
||||
|
||||
// IMSIdentityProvider returns the modem's identity provider.
|
||||
func (a *modemAdapter) IMSIdentityProvider() runtimehost.IMSIdentityProvider {
|
||||
return a
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package device
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -202,7 +203,7 @@ func (p *Pool) prepareVoWiFiStartContext(deviceID, traceID, runtimeEPDGOverride
|
||||
return startCtx, err
|
||||
}
|
||||
|
||||
runtimehost.SetLogger(logger.ZapLogger())
|
||||
runtimehost.SetLogger(slog.Default())
|
||||
prepared, errPrepare := identity.PrepareStart(identity.PrepareStartInput{
|
||||
DeviceID: deviceID,
|
||||
Profile: startProfile,
|
||||
|
||||
@@ -134,7 +134,7 @@ func (p *Prober) boundDialer() *net.Dialer {
|
||||
d.Control = func(_, _ string, c syscall.RawConn) error {
|
||||
var serr error
|
||||
if err := c.Control(func(fd uintptr) {
|
||||
serr = syscall.SetsockoptString(int(fd), syscall.SOL_SOCKET, syscall.SO_BINDTODEVICE, p.cfg.Interface)
|
||||
serr = syscall.SetsockoptString(int(fd), syscall.SOL_SOCKET, soBindToDevice, p.cfg.Interface)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
//go:build linux
|
||||
|
||||
package netprobe
|
||||
|
||||
import "syscall"
|
||||
|
||||
// soBindToDevice is SO_BINDTODEVICE on Linux.
|
||||
const soBindToDevice = syscall.SO_BINDTODEVICE
|
||||
@@ -0,0 +1,6 @@
|
||||
//go:build !linux
|
||||
|
||||
package netprobe
|
||||
|
||||
// soBindToDevice is a no-op placeholder on non-Linux platforms.
|
||||
const soBindToDevice = 0
|
||||
@@ -122,7 +122,7 @@ func newBoundDialer(id, iface string) *net.Dialer {
|
||||
}
|
||||
var sockErr error
|
||||
if err := c.Control(func(fd uintptr) {
|
||||
sockErr = syscall.SetsockoptString(int(fd), syscall.SOL_SOCKET, syscall.SO_BINDTODEVICE, iface)
|
||||
sockErr = syscall.SetsockoptString(int(fd), syscall.SOL_SOCKET, soBindToDevice, iface)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
//go:build linux
|
||||
|
||||
package server
|
||||
|
||||
import "syscall"
|
||||
|
||||
// soBindToDevice is SO_BINDTODEVICE on Linux.
|
||||
const soBindToDevice = syscall.SO_BINDTODEVICE
|
||||
@@ -0,0 +1,6 @@
|
||||
//go:build !linux
|
||||
|
||||
package server
|
||||
|
||||
// soBindToDevice is a no-op placeholder on non-Linux platforms.
|
||||
const soBindToDevice = 0
|
||||
@@ -0,0 +1,36 @@
|
||||
//go:build !linux
|
||||
|
||||
package qmicore
|
||||
|
||||
import "strings"
|
||||
|
||||
// qmiControlDeviceHolder describes a process holding a QMI control device.
|
||||
type qmiControlDeviceHolder struct {
|
||||
PID int
|
||||
Command string
|
||||
}
|
||||
|
||||
// qmiControlDeviceHolders is the set of processes holding a control device.
|
||||
type qmiControlDeviceHolders struct {
|
||||
Holders []qmiControlDeviceHolder
|
||||
Unknown bool
|
||||
}
|
||||
|
||||
// detectQMIControlDeviceHolders is a no-op on non-Linux platforms.
|
||||
var detectQMIControlDeviceHolders = func(controlDevice string) (qmiControlDeviceHolders, error) {
|
||||
return qmiControlDeviceHolders{}, nil
|
||||
}
|
||||
|
||||
// onlyQMIProxy reports whether all holders are the QMI proxy.
|
||||
func (h qmiControlDeviceHolders) onlyQMIProxy() bool {
|
||||
if len(h.Holders) == 0 {
|
||||
return false
|
||||
}
|
||||
for _, holder := range h.Holders {
|
||||
cmd := strings.ToLower(strings.TrimSpace(holder.Command))
|
||||
if !strings.Contains(cmd, "qmi-proxy") {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -1093,7 +1093,7 @@ func (m *Manager) boundDialer(timeout time.Duration) *net.Dialer {
|
||||
dialer.Control = func(network, address string, c syscall.RawConn) error {
|
||||
var sockErr error
|
||||
if err := c.Control(func(fd uintptr) {
|
||||
sockErr = syscall.SetsockoptString(int(fd), syscall.SOL_SOCKET, syscall.SO_BINDTODEVICE, m.cfg.Interface)
|
||||
sockErr = syscall.SetsockoptString(int(fd), syscall.SOL_SOCKET, soBindToDevice, m.cfg.Interface)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
//go:build linux
|
||||
|
||||
package qmicore
|
||||
|
||||
import "syscall"
|
||||
|
||||
// soBindToDevice is SO_BINDTODEVICE on Linux.
|
||||
const soBindToDevice = syscall.SO_BINDTODEVICE
|
||||
@@ -0,0 +1,6 @@
|
||||
//go:build !linux
|
||||
|
||||
package qmicore
|
||||
|
||||
// soBindToDevice is a no-op placeholder on non-Linux platforms.
|
||||
const soBindToDevice = 0
|
||||
@@ -19,6 +19,9 @@ func (runtimeStartTestModem) IsSimInserted() bool {
|
||||
func (runtimeStartTestModem) QuerySIMInserted() (bool, error) { return true, nil }
|
||||
func (runtimeStartTestModem) GetRegStatus() (int, string) { return 1, "registered" }
|
||||
func (runtimeStartTestModem) GetNetworkMode() string { return "LTE" }
|
||||
func (runtimeStartTestModem) Capabilities() runtimehost.ModemCapabilities { return runtimehost.ModemCapabilities{} }
|
||||
func (runtimeStartTestModem) IMSIdentityProvider() runtimehost.IMSIdentityProvider { return runtimeStartTestModem{} }
|
||||
func (runtimeStartTestModem) GetISIMIdentity() (identity.Identity, error) { return identity.Identity{IMPI: "310260123456789@ims.example.com", IMPU: []string{"sip:310260123456789@ims.example.com"}, Domain: "ims.example.com"}, nil }
|
||||
func (runtimeStartTestModem) ExecuteATSilent(string, time.Duration) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Vendored
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+23
@@ -0,0 +1,23 @@
|
||||
package sim
|
||||
|
||||
import "errors"
|
||||
|
||||
var (
|
||||
ErrSyncFailure = errors.New("aka sync failure")
|
||||
ErrAuthFailure = errors.New("aka authentication failure")
|
||||
)
|
||||
|
||||
type AKAResult struct {
|
||||
RES []byte
|
||||
CK []byte
|
||||
IK []byte
|
||||
AUTS []byte
|
||||
}
|
||||
|
||||
type AKAProvider interface {
|
||||
CalculateAKA(rand16, autn16 []byte) (AKAResult, error)
|
||||
}
|
||||
|
||||
type ISIMAKAProvider interface {
|
||||
CalculateISIMAKA(rand16, autn16 []byte) (AKAResult, error)
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Vendored
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Vendored
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Vendored
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,49 @@
|
||||
package swu
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTunnelConfigValidateAllowsExplicitEPDG(t *testing.T) {
|
||||
cfg := TunnelConfig{
|
||||
DeviceID: "dev-1",
|
||||
Mode: DataplaneModeUserspace,
|
||||
EPDGAddress: "epdg.example",
|
||||
IMSI: "310280233641503",
|
||||
}
|
||||
if err := cfg.Validate(); err != nil {
|
||||
t.Fatalf("Validate() error = %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTunnelConfigValidateAllowsCarrierDerivedEPDG(t *testing.T) {
|
||||
cfg := TunnelConfig{
|
||||
DeviceID: "dev-1",
|
||||
MCC: "310",
|
||||
MNC: "280",
|
||||
Identity: IMSIdentity{IMPI: "310280233641503@private.att.net"},
|
||||
}
|
||||
if err := cfg.Validate(); err != nil {
|
||||
t.Fatalf("Validate() error = %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTunnelConfigValidateRejectsMissingIdentity(t *testing.T) {
|
||||
err := (TunnelConfig{
|
||||
DeviceID: "dev-1",
|
||||
EPDGAddress: "epdg.example",
|
||||
}).Validate()
|
||||
if !errors.Is(err, ErrInvalidTunnelConfig) {
|
||||
t.Fatalf("Validate() err=%v, want ErrInvalidTunnelConfig", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTunnelResultReadyRequiresIKEAndIPsec(t *testing.T) {
|
||||
if (TunnelResult{Ready: true, IKEEstablished: true}).IsReady() {
|
||||
t.Fatalf("IsReady()=true without IPsec")
|
||||
}
|
||||
if !(TunnelResult{Ready: true, IKEEstablished: true, IPsecEstablished: true}).IsReady() {
|
||||
t.Fatalf("IsReady()=false with all readiness flags")
|
||||
}
|
||||
}
|
||||
Vendored
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Vendored
File renamed without changes.
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
module github.com/iniwex5/vowifi-go
|
||||
|
||||
go 1.26.4
|
||||
|
||||
require (
|
||||
github.com/emiago/sipgo v1.4.0
|
||||
github.com/pion/rtcp v1.2.16
|
||||
github.com/pion/srtp/v3 v3.0.12
|
||||
golang.org/x/sys v0.41.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/gobwas/httphead v0.1.0 // indirect
|
||||
github.com/gobwas/pool v0.2.1 // indirect
|
||||
github.com/gobwas/ws v1.3.2 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/pion/logging v0.2.4 // indirect
|
||||
github.com/pion/randutil v0.1.0 // indirect
|
||||
github.com/pion/rtp v1.10.2 // indirect
|
||||
github.com/pion/transport/v4 v4.0.2 // indirect
|
||||
golang.org/x/sync v0.16.0 // indirect
|
||||
)
|
||||
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/emiago/sipgo v1.4.0 h1:IRiwIUu4H97gC+vq2zsm3iWe/j08LPExFZRe3kfY0f0=
|
||||
github.com/emiago/sipgo v1.4.0/go.mod h1:DuwAxBZhKMqIzQFPGZb1MVAGU6Wuxj64oTOhd5dx/FY=
|
||||
github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
|
||||
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
|
||||
github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og=
|
||||
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
|
||||
github.com/gobwas/ws v1.3.2 h1:zlnbNHxumkRvfPWgfXu8RBwyNR1x8wh9cf5PTOCqs9Q=
|
||||
github.com/gobwas/ws v1.3.2/go.mod h1:hRKAFb8wOxFROYNsT1bqfWnhX+b5MFeJM9r2ZSwg/KY=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/pion/logging v0.2.4 h1:tTew+7cmQ+Mc1pTBLKH2puKsOvhm32dROumOZ655zB8=
|
||||
github.com/pion/logging v0.2.4/go.mod h1:DffhXTKYdNZU+KtJ5pyQDjvOAh/GsNSyv1lbkFbe3so=
|
||||
github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
|
||||
github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8=
|
||||
github.com/pion/rtcp v1.2.16 h1:fk1B1dNW4hsI78XUCljZJlC4kZOPk67mNRuQ0fcEkSo=
|
||||
github.com/pion/rtcp v1.2.16/go.mod h1:/as7VKfYbs5NIb4h6muQ35kQF/J0ZVNz2Z3xKoCBYOo=
|
||||
github.com/pion/rtp v1.10.2 h1:l+f6tTDcAH6xwepaAoW791ddhuYsJlqRATOzirO04Mo=
|
||||
github.com/pion/rtp v1.10.2/go.mod h1:Au8fc6cEByy8RLTwKTQTEeQqDB/SJDxwL4mZuxYA5Pk=
|
||||
github.com/pion/srtp/v3 v3.0.12 h1:U7V17bckl7sI4mb3sepiojByDuBY0wNCqQE+6IlQBbc=
|
||||
github.com/pion/srtp/v3 v3.0.12/go.mod h1:EeZOi/sd6glM1EXapg051gdNWO9yWT1YSsgQ4SlJkns=
|
||||
github.com/pion/transport/v4 v4.0.2 h1:ifYlPqNwsy6aKQ9y8yzxXlHae5431ZrH2avkD/Rn6Tk=
|
||||
github.com/pion/transport/v4 v4.0.2/go.mod h1:06hFI+jCFcok2X2MekVufNZ/uzNZXivGBPfviSVcjgM=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
|
||||
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
|
||||
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 300 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user