Documentation ¶
Overview ¶
salt cache
Index ¶
- Constants
- func CheckBySalt(keyId, salt int64) bool
- func GetOrInsertSalt(keyId int64) (int64, error)
- func GetOrInsertSaltList(keyId int64, size int) ([]*mtproto.TLFutureSalt, error)
- func InitCacheAuthManager(cap int64, discovery *service_discovery.ServiceDiscoveryClientConfig)
- func NewClientSession(sessionId, salt, firstMsgId int64, m *clientSessionManager) *clientSession
- func NextId() int64
- type CacheAuthInterface
- type ClientConnID
- type Entry
- type ServerConfig
- type SessionConfig
- type SessionServer
- func (s *SessionServer) Destroy()
- func (s *SessionServer) Initialize() error
- func (s *SessionServer) OnConnectionClosed(conn *net2.TcpConnection)
- func (s *SessionServer) OnConnectionDataArrived(conn *net2.TcpConnection, msg interface{}) error
- func (s *SessionServer) OnNewConnection(conn *net2.TcpConnection)
- func (s *SessionServer) RunLoop()
- func (s *SessionServer) SendToClientData(connID, sessionID uint64, md *mtproto.ZProtoMetadata, buf []byte) error
- type TLInitConnectionExt
- type TLInvokeAfterMsgExt
- type TLInvokeAfterMsgsExt
- type TLInvokeWithLayerExt
- type TLInvokeWithoutUpdatesExt
- type TimingWheel
Constants ¶
const ( GENERIC = 0 DOWNLOAD = 1 UPLOAD = 3 // Android PUSH = 7 // 暂时不考虑 TEMP = 8 UNKNOWN = 256 INVALID_TYPE = -1 // math.MaxInt32 )
PUSH ==> ConnectionTypePush ConnectionTypePush和其它类型不太一样,session一旦创建以后不会改变
const ( TOKEN_TYPE_APNS = 1 TOKEN_TYPE_GCM = 2 TOKEN_TYPE_MPNS = 3 TOKEN_TYPE_SIMPLE_PUSH = 4 TOKEN_TYPE_UBUNTU_PHONE = 5 TOKEN_TYPE_BLACKBERRY = 6 // Android里使用 TOKEN_TYPE_INTERNAL_PUSH = 7 )
Variables ¶
This section is empty.
Functions ¶
func CheckBySalt ¶
Server Salt
A (random) 64-bit number periodically (say, every 24 hours) changed (separately for each session) at the request of the server. All subsequent messages must contain the new salt (although, messages with the old salt are still accepted for a further 300 seconds). Required to protect against replay attacks and certain tricks associated with adjusting the client clock to a moment in the distant future.
func GetOrInsertSalt ¶
func GetOrInsertSaltList ¶
func GetOrInsertSaltList(keyId int64, size int) ([]*mtproto.TLFutureSalt, error)
func InitCacheAuthManager ¶
func InitCacheAuthManager(cap int64, discovery *service_discovery.ServiceDiscoveryClientConfig)
func NewClientSession ¶
func NewClientSession(sessionId, salt, firstMsgId int64, m *clientSessionManager) *clientSession
Types ¶
type CacheAuthInterface ¶
type ClientConnID ¶
type ClientConnID struct {
// contains filtered or unexported fields
}
client connID
type ServerConfig ¶
type SessionConfig ¶
type SessionConfig struct { ServerId int32 // 服务器ID Redis []redis_client.RedisConfig SaltCache redis_client.RedisConfig AuthKeyRpcClient service_discovery.ServiceDiscoveryClientConfig BizRpcClient service_discovery.ServiceDiscoveryClientConfig NbfsRpcClient service_discovery.ServiceDiscoveryClientConfig SyncRpcClient service_discovery.ServiceDiscoveryClientConfig Server ServerConfig Discovery service_discovery.ServiceDiscoveryServerConfig }
type SessionServer ¶
type SessionServer struct {
// contains filtered or unexported fields
}
func NewSessionServer ¶
func NewSessionServer(configPath string) *SessionServer
func (*SessionServer) Destroy ¶
func (s *SessionServer) Destroy()
func (*SessionServer) Initialize ¶
func (s *SessionServer) Initialize() error
////////////////////////////////////////////////////////////////////////////////////////////////// AppInstance interface
func (*SessionServer) OnConnectionClosed ¶
func (s *SessionServer) OnConnectionClosed(conn *net2.TcpConnection)
func (*SessionServer) OnConnectionDataArrived ¶
func (s *SessionServer) OnConnectionDataArrived(conn *net2.TcpConnection, msg interface{}) error
func (*SessionServer) OnNewConnection ¶
func (s *SessionServer) OnNewConnection(conn *net2.TcpConnection)
////////////////////////////////////////////////////////////////////////////////////////////////// TcpConnectionCallback
func (*SessionServer) RunLoop ¶
func (s *SessionServer) RunLoop()
func (*SessionServer) SendToClientData ¶
func (s *SessionServer) SendToClientData(connID, sessionID uint64, md *mtproto.ZProtoMetadata, buf []byte) error
type TLInitConnectionExt ¶
type TLInitConnectionExt struct { ApiId int32 DeviceMode string SystemVersion string AppVersion string SystemLangCode string LangPack string LangCode string Query mtproto.TLObject }
initConnection#c7481da6 {X:Type} api_id:int device_model:string system_version:string app_version:string system_lang_code:string lang_pack:string lang_code:string query:!X = X;
func NewInitConnectionExt ¶
func NewInitConnectionExt(initConnection *mtproto.TLInitConnection) *TLInitConnectionExt
func (*TLInitConnectionExt) Decode ¶
func (m *TLInitConnectionExt) Decode(dbuf *mtproto.DecodeBuf) error
func (*TLInitConnectionExt) Encode ¶
func (m *TLInitConnectionExt) Encode() []byte
func (*TLInitConnectionExt) String ¶
func (m *TLInitConnectionExt) String() string
type TLInvokeAfterMsgExt ¶
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
func NewInvokeAfterMsgExt ¶
func NewInvokeAfterMsgExt(invokeAfterMsg *mtproto.TLInvokeAfterMsg) *TLInvokeAfterMsgExt
func (*TLInvokeAfterMsgExt) Decode ¶
func (m *TLInvokeAfterMsgExt) Decode(dbuf *mtproto.DecodeBuf) error
func (*TLInvokeAfterMsgExt) Encode ¶
func (m *TLInvokeAfterMsgExt) Encode() []byte
func (*TLInvokeAfterMsgExt) String ¶
func (m *TLInvokeAfterMsgExt) String() string
type TLInvokeAfterMsgsExt ¶
invokeAfterMsgs#3dc4b4f0 {X:Type} msg_ids:Vector<long> query:!X = X;
func NewInvokeAfterMsgsExt ¶
func NewInvokeAfterMsgsExt(invokeAfterMsgs *mtproto.TLInvokeAfterMsgs) *TLInvokeAfterMsgsExt
func (*TLInvokeAfterMsgsExt) Decode ¶
func (m *TLInvokeAfterMsgsExt) Decode(dbuf *mtproto.DecodeBuf) error
func (*TLInvokeAfterMsgsExt) Encode ¶
func (m *TLInvokeAfterMsgsExt) Encode() []byte
func (*TLInvokeAfterMsgsExt) String ¶
func (m *TLInvokeAfterMsgsExt) String() string
type TLInvokeWithLayerExt ¶
invokeWithLayer#da9b0d0d {X:Type} layer:int query:!X = X;
func NewInvokeWithLayerExt ¶
func NewInvokeWithLayerExt(invokeWithLayer *mtproto.TLInvokeWithLayer) *TLInvokeWithLayerExt
func (*TLInvokeWithLayerExt) Decode ¶
func (m *TLInvokeWithLayerExt) Decode(dbuf *mtproto.DecodeBuf) error
func (*TLInvokeWithLayerExt) Encode ¶
func (m *TLInvokeWithLayerExt) Encode() []byte
func (*TLInvokeWithLayerExt) String ¶
func (m *TLInvokeWithLayerExt) String() string
type TLInvokeWithoutUpdatesExt ¶
invokeWithoutUpdates#bf9459b7 {X:Type} query:!X = X;
func NewInvokeWithoutUpdatesExt ¶
func NewInvokeWithoutUpdatesExt(invokeWithoutUpdates *mtproto.TLInvokeWithoutUpdates) *TLInvokeWithoutUpdatesExt
func (*TLInvokeWithoutUpdatesExt) Decode ¶
func (m *TLInvokeWithoutUpdatesExt) Decode(dbuf *mtproto.DecodeBuf) error
func (*TLInvokeWithoutUpdatesExt) Encode ¶
func (m *TLInvokeWithoutUpdatesExt) Encode() []byte
func (*TLInvokeWithoutUpdatesExt) String ¶
func (m *TLInvokeWithoutUpdatesExt) String() string
type TimingWheel ¶
type TimingWheel struct {
// contains filtered or unexported fields
}
func NewTimingWheel ¶
func NewTimingWheel(size int) *TimingWheel
func (*TimingWheel) Start ¶
func (t *TimingWheel) Start()
func (*TimingWheel) Stop ¶
func (t *TimingWheel) Stop()