added more login failed handling to steam connection manager
This commit is contained in:
@@ -41,20 +41,21 @@ type DemoMatchLoaderConfig struct {
|
||||
}
|
||||
|
||||
type DemoMatchLoader struct {
|
||||
client *steam.Client
|
||||
GCReady bool
|
||||
steamLogin *steam.LogOnDetails
|
||||
matchRecv chan *protobuf.CMsgGCCStrike15V2_MatchList
|
||||
cmList []*netutil.PortAddr
|
||||
sentryFile string
|
||||
loginKey string
|
||||
db *ent.Client
|
||||
dp *DemoParser
|
||||
parseDemo chan *Demo
|
||||
parseMap map[string]bool
|
||||
parseMapL *sync.RWMutex
|
||||
cache *cache.Cache
|
||||
connecting bool
|
||||
client *steam.Client
|
||||
GCReady bool
|
||||
steamLogin *steam.LogOnDetails
|
||||
matchRecv chan *protobuf.CMsgGCCStrike15V2_MatchList
|
||||
cmList []*netutil.PortAddr
|
||||
sentryFile string
|
||||
loginKey string
|
||||
db *ent.Client
|
||||
dp *DemoParser
|
||||
parseDemo chan *Demo
|
||||
parseMap map[string]bool
|
||||
parseMapL *sync.RWMutex
|
||||
cache *cache.Cache
|
||||
connecting *sync.Mutex
|
||||
connectionWait uint64
|
||||
}
|
||||
|
||||
func AccountId2SteamId(accId uint32) uint64 {
|
||||
@@ -184,6 +185,7 @@ func (dml *DemoMatchLoader) Setup(config *DemoMatchLoaderConfig) error {
|
||||
dml.parseMap = map[string]bool{}
|
||||
dml.parseMapL = new(sync.RWMutex)
|
||||
dml.cache = config.Cache
|
||||
dml.connecting = new(sync.Mutex)
|
||||
err := dml.dp.Setup(config.Db, config.Worker, config.SprayTimeout)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -240,11 +242,20 @@ func (dml DemoMatchLoader) LoadDemo(demo *Demo) error {
|
||||
}
|
||||
|
||||
func (dml DemoMatchLoader) connectLoop() {
|
||||
if !dml.connecting {
|
||||
dml.connecting = true
|
||||
dml.connecting.Lock()
|
||||
defer dml.connecting.Unlock()
|
||||
if !dml.client.Connected() {
|
||||
for dml.connectToSteam() != nil {
|
||||
log.Infof("[DL] Retrying connecting to steam...")
|
||||
time.Sleep(time.Minute * 10)
|
||||
if dml.connectionWait == 0 {
|
||||
dml.connectionWait = 1
|
||||
}
|
||||
time.Sleep(time.Minute * time.Duration(dml.connectionWait))
|
||||
dml.connectionWait *= 2
|
||||
}
|
||||
if dml.client.Connected() {
|
||||
log.Infof("[DL] Steam login successfully restored after %d minutes", dml.connectionWait)
|
||||
dml.connectionWait = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -262,21 +273,23 @@ func (dml *DemoMatchLoader) steamEventHandler() {
|
||||
log.Errorf("[DL] Unable write sentry file: %v", err)
|
||||
}
|
||||
case *steam.LoggedOnEvent:
|
||||
log.Debug("[DL] Login successfully!")
|
||||
log.Debug("[DL] Steam login success!")
|
||||
dml.client.Social.SetPersonaState(steamlang.EPersonaState_Online)
|
||||
go dml.setPlaying()
|
||||
case *steam.LogOnFailedEvent:
|
||||
log.Warningf("[DL] Steam login denied: %+v", e)
|
||||
log.Debugf("[DL] Steam login denied: %+v", e)
|
||||
switch e.Result {
|
||||
case steamlang.EResult_AccountLogonDenied:
|
||||
log.Fatalf("[DL] Please provide AuthCode in config")
|
||||
case steamlang.EResult_InvalidPassword:
|
||||
_ = os.Remove(dml.sentryFile)
|
||||
_ = os.Remove(dml.loginKey)
|
||||
log.Warningf("[DL] Steam login wrong")
|
||||
log.Warningf("[DL] Steam login failed: InvalidPassword")
|
||||
go dml.connectLoop()
|
||||
case steamlang.EResult_InvalidLoginAuthCode:
|
||||
log.Fatalf("[DL] Steam auth code wrong")
|
||||
default:
|
||||
log.Warningf("[DL] Unhandled login fasiled event %+v", e)
|
||||
}
|
||||
case *steam.DisconnectedEvent:
|
||||
log.Warningf("Steam disconnected, trying to reconnect...")
|
||||
@@ -287,7 +300,7 @@ func (dml *DemoMatchLoader) steamEventHandler() {
|
||||
if err != nil {
|
||||
log.Errorf("[DL] Unable write login_key: %v", err)
|
||||
}
|
||||
case steam.FatalErrorEvent:
|
||||
case *steam.FatalErrorEvent:
|
||||
log.Debugf("[DL] Got FatalError %+v", e)
|
||||
case error:
|
||||
log.Fatalf("[DL] Got error %+v", e)
|
||||
|
Reference in New Issue
Block a user