Source File
session.go
Belonging Package
github.com/gotd/td/pool
package poolimport ()// Session represents DC session.type Session struct {DC intAuthKey crypto.AuthKeySalt int64}// SyncSession is synchronization helper for Session.type SyncSession struct {data Sessionmux sync.RWMutex}// NewSyncSession creates new SyncSession.func ( Session) *SyncSession {return &SyncSession{data: ,}}// Store saves given Session.func ( *SyncSession) ( Session) {.mux.Lock().data =.mux.Unlock()}// Migrate changes current DC and its addr, zeroes AuthKey and Salt.func ( *SyncSession) ( int) {.mux.Lock().data.DC =.data.AuthKey = crypto.AuthKey{}.data.Salt = 0.mux.Unlock()}// Options fills Key and Salt field of given Options using stored session and returns it.func ( *SyncSession) ( mtproto.Options) (mtproto.Options, Session) {.mux.RLock():= .data.mux.RUnlock()if .EnablePFS {// Stored key in pool/session remains backward-compatible single "AuthKey".// In PFS mode this persisted key is treated as permanent key, while// temporary key is always generated per runtime connection..PermKey = .AuthKey.Key = crypto.AuthKey{}} else {.Key = .AuthKey}.Salt = .Saltreturn ,}// Load gets session and returns it.func ( *SyncSession) () ( Session) {.mux.RLock()= .data.mux.RUnlock()return}
![]() |
The pages are generated with Golds v0.8.4. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |