chore: sync vowifi-go alignment fixes (15 binary-exported symbols)

Sync the final API-fidelity additions (logger/logging/imscore With* options)
into vohive-open's third_party/vowifi-go.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
yibaibaandClaude Fable 5 committed 2026-08-07 09:05:33 +08:00
1 parent be68e52414
commit 8210e37b7a
5 files changed
+148

No files matched your search

+14
View File
@@ -100,3 +100,17 @@ func fixedWidthColorLevelEncoder(l zapcore.Level, enc zapcore.PrimitiveArrayEnco
}
enc.AppendString(text)
}
// AddCallerSkip returns a zap Option that adds the given number of caller
// frames to skip (recovered from the binary's zap option chain).
func AddCallerSkip(skip int) zap.Option { return zap.AddCallerSkip(skip) }
// AddStacktrace returns a zap Option that enables stack traces at the given
// level.
func AddStacktrace(l zapcore.LevelEnabler) zap.Option { return zap.AddStacktrace(l) }
// TimeEncoderOfLayout returns a zapcore.TimeEncoder using the given layout.
func TimeEncoderOfLayout(layout string) zapcore.TimeEncoder { return zapcore.TimeEncoderOfLayout(layout) }
// WithCaller returns a zap Option that enables or disables caller capture.
func WithCaller(enabled bool) zap.Option { return zap.WithCaller(enabled) }
+120
View File
@@ -0,0 +1,120 @@
package imscore
import (
"log/slog"
"net"
)
// SIPOption configures the IMS SIP stack (recovered from the binary's
// sipgo-style With* option chain).
type SIPOption func(*sipOptions)
// sipOptions carries the SIP stack configuration.
type sipOptions struct {
userAgent string
clientConn string
clientHost string
clientPort int
clientNAT string
terminateOnConnClose bool
unhandledRespHandler interface{}
transportLogger *slog.Logger
}
// WithUserAgent sets the User-Agent header value.
func WithUserAgent(ua string) SIPOption {
return func(o *sipOptions) { o.userAgent = ua }
}
// WithClientConnectionAddr sets the local client connection address.
func WithClientConnectionAddr(addr string) SIPOption {
return func(o *sipOptions) { o.clientConn = addr }
}
// WithClientHostname sets the local client hostname.
func WithClientHostname(host string) SIPOption {
return func(o *sipOptions) { o.clientHost = host }
}
// WithClientPort sets the local client port.
func WithClientPort(port int) SIPOption {
return func(o *sipOptions) { o.clientPort = port }
}
// WithClientNAT sets the client NAT traversal mode.
func WithClientNAT(mode string) SIPOption {
return func(o *sipOptions) { o.clientNAT = mode }
}
// WithTransactionLayerTerminateOnConnClose terminates transactions when the
// underlying connection closes.
func WithTransactionLayerTerminateOnConnClose(b bool) SIPOption {
return func(o *sipOptions) { o.terminateOnConnClose = b }
}
// WithTransactionLayerUnhandledResponseHandler sets the handler for
// unhandled responses.
func WithTransactionLayerUnhandledResponseHandler(h interface{}) SIPOption {
return func(o *sipOptions) { o.unhandledRespHandler = h }
}
// WithTransportLayerLogger sets the transport logger.
func WithTransportLayerLogger(l *slog.Logger) SIPOption {
return func(o *sipOptions) { o.transportLogger = l }
}
// WithUserAgentTransactionLayerOptions sets transaction-layer options.
func WithUserAgentTransactionLayerOptions(opts ...SIPOption) SIPOption {
return func(o *sipOptions) {
for _, opt := range opts {
if opt != nil {
opt(o)
}
}
}
}
// WithUserAgentTransportLayerOptions sets transport-layer options.
func WithUserAgentTransportLayerOptions(opts ...SIPOption) SIPOption {
return func(o *sipOptions) {
for _, opt := range opts {
if opt != nil {
opt(o)
}
}
}
}
// defaultSIPOptions returns the default SIP stack options.
func defaultSIPOptions() *sipOptions {
return &sipOptions{clientPort: 5060}
}
// applySIPOptions applies the options to the service config.
func (s *Service) applySIPOptions(opts ...SIPOption) {
if s == nil || s.cfg == nil {
return
}
o := defaultSIPOptions()
for _, opt := range opts {
if opt != nil {
opt(o)
}
}
if o.userAgent != "" {
s.cfg.UserAgent = o.userAgent
}
if o.clientConn != "" {
s.cfg.LocalIP = net.ParseIP(hostOnly(o.clientConn))
}
}
// hostOnly extracts the host part of a host[:port] string.
func hostOnly(addr string) string {
for i := 0; i < len(addr); i++ {
if addr[i] == ':' {
return addr[:i]
}
}
return addr
}
@@ -57,6 +57,8 @@ type IMSConfig struct {
IPSec3GPPEnabled bool
// TraceID is the session trace ID.
TraceID string
// UserAgent is the SIP User-Agent header value.
UserAgent string
}
// AKAProvider computes AKA from the network challenge.
@@ -217,3 +217,9 @@ func dedupeNonEmpty(in []string) []string {
}
return out
}
// WithCaller returns a slog HandlerOption that adds the caller to log
// records.
func WithCaller(enabled bool) slog.HandlerOptions {
return slog.HandlerOptions{AddSource: enabled}
}
+6
View File
@@ -44,5 +44,11 @@
"unplugin-vue-components": "^31.0.0",
"vite": "^8.1.3",
"vue-tsc": "^2.2.12"
},
"allowScripts": {
"esbuild@0.28.1": true,
"@parcel/watcher@2.5.6": true,
"vue-demi@0.14.10": true,
"fsevents@2.3.3": true
}
}