server

package
v0.0.0-...-6e21e7b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2018 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

salt cache

Index

Constants

View Source
const (
	GENERIC  = 0
	DOWNLOAD = 1
	UPLOAD   = 3

	// Android
	PUSH = 7

	// 暂时不考虑
	TEMP = 8

	UNKNOWN = 256

	INVALID_TYPE = -1 // math.MaxInt32
)

PUSH ==> ConnectionTypePush ConnectionTypePush和其它类型不太一样,session一旦创建以后不会改变

View Source
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

func CheckBySalt(keyId, salt int64) bool

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 GetOrInsertSalt(keyId int64) (int64, error)

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

func NextId

func NextId() int64

Types

type CacheAuthInterface

type CacheAuthInterface interface {
	GetAuthKey(int64) ([]byte, bool)
	GetUserID(int64) (int32, bool)
}

type ClientConnID

type ClientConnID struct {
	// contains filtered or unexported fields
}

client connID

type Entry

type Entry interface {
	AddRef()
	Release() int32
	TimerCallback()
}

type ServerConfig

type ServerConfig struct {
	Name      string
	ProtoName string
	Addr      string
}

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

type TLInvokeAfterMsgExt struct {
	MsgId int64
	Query mtproto.TLObject
}

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

type TLInvokeAfterMsgsExt struct {
	MsgIds []int64
	Query  mtproto.TLObject
}

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

type TLInvokeWithLayerExt struct {
	Layer int32
	Query mtproto.TLObject
}

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

type TLInvokeWithoutUpdatesExt struct {
	Query mtproto.TLObject
}

invokeWithoutUpdates#bf9459b7 {X:Type} query:!X = X;

func NewInvokeWithoutUpdatesExt

func NewInvokeWithoutUpdatesExt(invokeWithoutUpdates *mtproto.TLInvokeWithoutUpdates) *TLInvokeWithoutUpdatesExt

func (*TLInvokeWithoutUpdatesExt) Decode

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) AddTimer

func (t *TimingWheel) AddTimer(entry Entry, tm int) error

func (*TimingWheel) Start

func (t *TimingWheel) Start()

func (*TimingWheel) Stop

func (t *TimingWheel) Stop()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL