notify/servertype.go
starainrt 98ef9e7fcc
feat(transport): 完成安全架构拆分并收口 stream/bulk 传输优化
- 新增 managed/external/nested 三种传输保护模式
  - 新增 peer attach 显式认证、抗重放、channel binding 和可选前向保密协商
  - 明确单连接注入与可重拨连接源的语义边界
  - 禁止 ConnectByConn 场景下 dedicated bulk 走 sidecar,auto 模式自动回退 shared
  - 修正 dedicated attach 在 bootstrap/steady profile 切换下的处理逻辑
  - 优化 shared bulk super-batch 与批量 framed write 路径
  - 降低 stream/bulk fast path 的复制和分发损耗
  - 补齐 benchmark、回归测试、运行时快照和 README 文档
2026-04-20 16:35:44 +08:00

114 lines
5.8 KiB
Go

package notify
import (
"context"
"net"
"time"
)
type Server interface {
// Deprecated: SetDefaultCommEncode overrides the transport codec directly.
// Prefer UseModernPSKServer or UseLegacySecurityServer.
SetDefaultCommEncode(func([]byte, []byte) []byte)
// Deprecated: SetDefaultCommDecode overrides the transport codec directly.
// Prefer UseModernPSKServer or UseLegacySecurityServer.
SetDefaultCommDecode(func([]byte, []byte) []byte)
SetDefaultLink(func(message *Message))
SetLink(string, func(*Message))
SetFileHandler(func(FileEvent))
SetStreamHandler(func(StreamAcceptInfo) error)
SetRecordStreamHandler(func(RecordAcceptInfo) error)
SetBulkHandler(func(BulkAcceptInfo) error)
SetTransferHandler(func(TransferAcceptInfo) (TransferReceiveOptions, error))
GetStreamConfig() StreamConfig
SetStreamConfig(StreamConfig)
SetTransferResumeStore(TransferResumeStore)
RecoverTransferSnapshots(context.Context) error
SetBulkOpenTuning(BulkOpenTuning)
BulkOpenTuning() BulkOpenTuning
SetPeerAttachSecurityConfig(PeerAttachSecurityConfig) error
PeerAttachSecurityConfig() PeerAttachSecurityConfig
SetFileReceiveDir(dir string) error
send(c *ClientConn, msg TransferMsg) (WaitMsg, error)
sendEnvelope(c *ClientConn, env Envelope) error
sendWait(c *ClientConn, msg TransferMsg, timeout time.Duration) (Message, error)
OpenStreamLogical(ctx context.Context, c *LogicalConn, opt StreamOpenOptions) (Stream, error)
OpenStreamTransport(ctx context.Context, t *TransportConn, opt StreamOpenOptions) (Stream, error)
OpenRecordStreamLogical(ctx context.Context, c *LogicalConn, opt RecordOpenOptions) (RecordStream, error)
OpenRecordStreamTransport(ctx context.Context, t *TransportConn, opt RecordOpenOptions) (RecordStream, error)
OpenBulkLogical(ctx context.Context, c *LogicalConn, opt BulkOpenOptions) (Bulk, error)
OpenBulkTransport(ctx context.Context, t *TransportConn, opt BulkOpenOptions) (Bulk, error)
SendTransferLogical(ctx context.Context, c *LogicalConn, opt TransferSendOptions) (TransferHandle, error)
SendTransferTransport(ctx context.Context, t *TransportConn, opt TransferSendOptions) (TransferHandle, error)
SendObjCtxLogical(ctx context.Context, c *LogicalConn, key string, val interface{}) (Message, error)
SendObjLogical(c *LogicalConn, key string, val interface{}) error
SendLogical(c *LogicalConn, key string, value MsgVal) error
SendWaitLogical(c *LogicalConn, key string, value MsgVal, timeout time.Duration) (Message, error)
SendWaitObjLogical(c *LogicalConn, key string, value interface{}, timeout time.Duration) (Message, error)
SendCtxLogical(ctx context.Context, c *LogicalConn, key string, value MsgVal) (Message, error)
SendObjCtxTransport(ctx context.Context, t *TransportConn, key string, val interface{}) (Message, error)
SendObjTransport(t *TransportConn, key string, val interface{}) error
SendTransport(t *TransportConn, key string, value MsgVal) error
SendWaitTransport(t *TransportConn, key string, value MsgVal, timeout time.Duration) (Message, error)
SendWaitObjTransport(t *TransportConn, key string, value interface{}, timeout time.Duration) (Message, error)
SendCtxTransport(ctx context.Context, t *TransportConn, key string, value MsgVal) (Message, error)
// Deprecated: prefer the LogicalConn/TransportConn variants.
SendObjCtx(ctx context.Context, c *ClientConn, key string, val interface{}) (Message, error)
// Deprecated: prefer the LogicalConn/TransportConn variants.
SendObj(c *ClientConn, key string, val interface{}) error
// Deprecated: prefer the LogicalConn/TransportConn variants.
Send(c *ClientConn, key string, value MsgVal) error
// Deprecated: prefer the LogicalConn/TransportConn variants.
SendWait(c *ClientConn, key string, value MsgVal, timeout time.Duration) (Message, error)
// Deprecated: prefer the LogicalConn/TransportConn variants.
SendWaitObj(c *ClientConn, key string, value interface{}, timeout time.Duration) (Message, error)
// Deprecated: prefer the LogicalConn/TransportConn variants.
SendCtx(ctx context.Context, c *ClientConn, key string, value MsgVal) (Message, error)
Reply(m Message, value MsgVal) error
pushMessage([]byte, string)
removeLogical(logical *LogicalConn)
removeClient(client *ClientConn)
Listen(network string, addr string) error
ListenByListener(listener net.Listener) error
Stop() error
StopMonitorChan() <-chan struct{}
Status() Status
GetSecretKey() []byte
// Deprecated: SetSecretKey injects a raw transport key directly.
// Prefer UseModernPSKServer or UseLegacySecurityServer.
SetSecretKey(key []byte)
// Deprecated: RsaPrivKey exposes the legacy RSA handshake key. Prefer UseModernPSKServer.
RsaPrivKey() []byte
// Deprecated: SetRsaPrivKey configures the legacy RSA handshake key. Prefer UseModernPSKServer.
SetRsaPrivKey([]byte)
GetLogicalConn(id string) *LogicalConn
GetLogicalConnList() []*LogicalConn
GetCurrentTransportConn(id string) *TransportConn
GetCurrentTransportConnByLogical(c *LogicalConn) *TransportConn
GetCurrentTransportConnList() []*TransportConn
// Deprecated: prefer GetLogicalConn.
GetClient(id string) *ClientConn
// Deprecated: prefer GetLogicalConnList.
GetClientLists() []*ClientConn
GetClientAddrs() []net.Addr
GetSequenceEn() func(interface{}) ([]byte, error)
SetSequenceEn(func(interface{}) ([]byte, error))
GetSequenceDe() func([]byte) (interface{}, error)
SetSequenceDe(func([]byte) (interface{}, error))
ShowError(bool)
DebugMode(bool)
IsDebugMode() bool
HeartbeatTimeoutSec() int64
SetHeartbeatTimeoutSec(int64)
DetachedClientKeepSec() int64
SetDetachedClientKeepSec(int64)
SendFileLogical(ctx context.Context, c *LogicalConn, filePath string) error
SendFileTransport(ctx context.Context, t *TransportConn, filePath string) error
// Deprecated: prefer SendFileLogical or SendFileTransport.
SendFile(ctx context.Context, c *ClientConn, filePath string) error
}