diff --git a/server/mailserver/app/app.go b/server/mailserver/app/app.go index fca4ce3c..3dcef813 100644 --- a/server/mailserver/app/app.go +++ b/server/mailserver/app/app.go @@ -1,23 +1,14 @@ package app import ( - "crypto/md5" - "encoding/hex" "f5" - "fmt" "main/constant" - "math/rand" "mt" - "sync" - "time" ) type app struct { initCb func() unInitCb func() - sessionLock sync.Mutex - sessionHash map[string]string - accountIdHash map[string]string } func (this *app) GetPkgName() string { @@ -37,8 +28,6 @@ func (this *app) Run(initCb func(), unInitCb func()) { func (this *app) Init() { f5.LoadMetaTable(mt.Table) this.registerDataSources() - this.sessionHash = make(map[string]string) - this.accountIdHash = make(map[string]string) this.initCb() } @@ -59,45 +48,3 @@ func (this *app) registerDataSources() { mt.Table.MailDb.GetById(0).GetDatabase(), 30) } - -func (this *app) AddSession(accountId string) string { - this.sessionLock.Lock() - defer this.sessionLock.Unlock() - uuid := f5.GetApp().NewUuid() - str := fmt.Sprintf("%s%d%s%d", accountId, uuid, randStringBytes(12), time.Now().Unix()) - md5New := md5.New() - strByte := []byte(str) - md5New.Write(strByte) - md5String := hex.EncodeToString(md5New.Sum(nil)) - token := accountId + "|" + md5String - this.sessionHash[accountId] = token - return token -} - -const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" - -func randStringBytes(n int) string { - b := make([]byte, n) - for i := range b { - b[i] = letterBytes[rand.Intn(len(letterBytes))] - } - return string(b) -} - -func (this *app) GetSessionAccountId(accountId string) string { - this.sessionLock.Lock() - defer this.sessionLock.Unlock() - if session, ok := this.sessionHash[accountId]; ok { - return session - } else { - return "nil" - } -} - -func (this *app) RemoveSession(accountId string) { - this.sessionLock.Lock() - defer this.sessionLock.Unlock() - if _, ok := this.sessionHash[accountId]; ok { - delete(this.sessionHash, accountId) - } -} diff --git a/server/mailserver/common/types.go b/server/mailserver/common/types.go index 23a1505b..cc44a038 100644 --- a/server/mailserver/common/types.go +++ b/server/mailserver/common/types.go @@ -2,9 +2,6 @@ package common type App interface { Run(func(), func()) - AddSession(accountId string) string - GetSessionAccountId(accountId string) string - RemoveSession(accountId string) } type Player interface {