fix: kcp 协议内部日志细节

This commit is contained in:
2026-03-25 15:09:32 +08:00
parent be013b701b
commit 665a908421
15 changed files with 1117 additions and 42 deletions

View File

@@ -7,6 +7,7 @@ import (
"path/filepath"
"sync/atomic"
"syscall"
"time"
"omnisocketgo/cmd/internal/latencylog"
"omnisocketgo/cmd/internal/protocol"
@@ -16,11 +17,13 @@ import (
var dialServer = dialServerWithOptions
type clientOptions struct {
logger latencylog.Logger
txTimestampDebugLogger transport.TXTimestampDebugLogger
kcpPacketDebugLogger transport.KCPPacketDebugLogger
bindIP string
bindDevice string
logger latencylog.Logger
txTimestampDebugLogger transport.TXTimestampDebugLogger
kcpPacketDebugLogger transport.KCPPacketDebugLogger
kcpSessionStatsLogger transport.KCPSessionStatsLogger
kcpSessionStatsInterval time.Duration
bindIP string
bindDevice string
}
// Option 用于配置 Client 的可选行为,例如时延日志。
@@ -47,6 +50,14 @@ func WithKCPPacketDebugLogger(logger transport.KCPPacketDebugLogger) Option {
}
}
// WithKCPSessionStatsLogger 为 KCP 会话统计日志注入记录器与采样间隔。
func WithKCPSessionStatsLogger(logger transport.KCPSessionStatsLogger, interval time.Duration) Option {
return func(options *clientOptions) {
options.kcpSessionStatsLogger = logger
options.kcpSessionStatsInterval = interval
}
}
// WithBindIP 指定拨号时使用的本地源 IP。
func WithBindIP(ip string) Option {
return func(options *clientOptions) {