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