notify/client_config.go
starainrt 09d972c7b7
feat(notify): 重构通信内核并补齐 stream/bulk/record/transfer 能力
- 引入 LogicalConn/TransportConn 分层,ClientConn 保留兼容适配层
  - 新增 Stream、Bulk、RecordStream 三条数据面能力及对应控制路径
  - 完成 transfer/file 传输内核与状态快照、诊断能力
  - 补齐 reconnect、inbound dispatcher、modern psk 等基础模块
  - 增加大规模回归、并发与基准测试覆盖
  - 更新依赖库
2026-04-15 15:24:36 +08:00

156 lines
3.8 KiB
Go

package notify
import (
"context"
"time"
)
func (c *ClientCommon) DebugMode(dmg bool) {
c.mu.Lock()
c.debugMode = dmg
c.mu.Unlock()
}
func (c *ClientCommon) IsDebugMode() bool {
return c.debugMode
}
// Deprecated: SkipExchangeKey only controls the legacy RSA-based key exchange.
func (c *ClientCommon) SkipExchangeKey() bool {
return c.skipKeyExchange
}
// Deprecated: SetSkipExchangeKey only controls the legacy RSA-based key exchange.
func (c *ClientCommon) SetSkipExchangeKey(val bool) {
c.skipKeyExchange = val
}
func (c *ClientCommon) ShowError(std bool) {
c.mu.Lock()
c.showError = std
c.mu.Unlock()
}
func (c *ClientCommon) SetDefaultLink(fn func(message *Message)) {
c.defaultFns = fn
}
func (c *ClientCommon) SetLink(key string, fn func(*Message)) {
c.mu.Lock()
defer c.mu.Unlock()
c.linkFns[key] = fn
}
func (c *ClientCommon) SetFileHandler(fn func(FileEvent)) {
c.mu.Lock()
defer c.mu.Unlock()
c.onFileEvent = normalizeFileEventCallback(fn)
}
func (c *ClientCommon) SetFileReceiveDir(dir string) error {
return c.getFileReceivePool().setDir(dir)
}
func (c *ClientCommon) SetTransferResumeStore(store TransferResumeStore) {
if runtime := c.getTransferRuntime(); runtime != nil {
runtime.setResumeStore(store)
}
}
func (c *ClientCommon) RecoverTransferSnapshots(ctx context.Context) error {
if runtime := c.getTransferRuntime(); runtime != nil {
return runtime.recover(ctx)
}
return nil
}
func (c *ClientCommon) GetMsgEn() func([]byte, []byte) []byte {
return c.msgEn
}
// Deprecated: SetMsgEn overrides the transport codec directly.
// Prefer UseModernPSKClient or UseLegacySecurityClient.
func (c *ClientCommon) SetMsgEn(fn func([]byte, []byte) []byte) {
c.msgEn = fn
c.fastStreamEncode = nil
c.fastBulkEncode = nil
c.fastPlainEncode = nil
c.securityReadyCheck = false
}
func (c *ClientCommon) GetMsgDe() func([]byte, []byte) []byte {
return c.msgDe
}
// Deprecated: SetMsgDe overrides the transport codec directly.
// Prefer UseModernPSKClient or UseLegacySecurityClient.
func (c *ClientCommon) SetMsgDe(fn func([]byte, []byte) []byte) {
c.msgDe = fn
c.fastStreamEncode = nil
c.fastBulkEncode = nil
c.fastPlainEncode = nil
c.securityReadyCheck = false
}
func (c *ClientCommon) HeartbeatPeroid() time.Duration {
return c.heartbeatPeriod
}
func (c *ClientCommon) SetHeartbeatPeroid(duration time.Duration) {
c.heartbeatPeriod = duration
}
func (c *ClientCommon) GetSecretKey() []byte {
return c.SecretKey
}
// Deprecated: SetSecretKey injects a raw transport key directly.
// Prefer UseModernPSKClient or UseLegacySecurityClient.
func (c *ClientCommon) SetSecretKey(key []byte) {
c.SecretKey = key
c.securityReadyCheck = len(key) == 0
c.skipKeyExchange = true
}
// Deprecated: RsaPubKey exposes the legacy RSA handshake key. Prefer UseModernPSKClient.
func (c *ClientCommon) RsaPubKey() []byte {
return c.handshakeRsaPubKey
}
// Deprecated: SetRsaPubKey configures the legacy RSA handshake key. Prefer UseModernPSKClient.
func (c *ClientCommon) SetRsaPubKey(key []byte) {
c.handshakeRsaPubKey = key
}
func (c *ClientCommon) Stop() error {
if !sessionIsAlive(&c.alive) {
return nil
}
c.stopClientSession("recv stop signal from user", nil)
return nil
}
func (c *ClientCommon) StopMonitorChan() <-chan struct{} {
return sessionStopChan(c.clientStopContextSnapshot())
}
func (c *ClientCommon) Status() Status {
return sessionStatusValue(&c.mu, &c.status)
}
func (c *ClientCommon) GetSequenceEn() func(interface{}) ([]byte, error) {
return c.sequenceEn
}
func (c *ClientCommon) SetSequenceEn(fn func(interface{}) ([]byte, error)) {
c.sequenceEn = fn
}
func (c *ClientCommon) GetSequenceDe() func([]byte) (interface{}, error) {
return c.sequenceDe
}
func (c *ClientCommon) SetSequenceDe(fn func([]byte) (interface{}, error)) {
c.sequenceDe = fn
}