cleanup config client

This commit is contained in:
shoopea 2021-11-26 08:22:37 +08:00
parent d3126446f7
commit 07c2ea7adb
2 changed files with 15 additions and 4 deletions

11
ttd.go
View File

@ -138,6 +138,7 @@ func (s *ServerTTD) HeartBeat(stop chan struct{}) {
s.UpdateDate() s.UpdateDate()
s.UpdateClients() s.UpdateClients()
s.UpdateCompanies() s.UpdateCompanies()
s.UpdateConfigClients()
s.PruneClients() s.PruneClients()
s.PruneCompanies() s.PruneCompanies()
s.ComputeClientTime() s.ComputeClientTime()
@ -565,6 +566,16 @@ func (s *ServerTTD) UpdateCompanies() {
s.Status.UpdateCompanies = time.Now() s.Status.UpdateCompanies = time.Now()
} }
func (s *ServerTTD) UpdateConfigClients() {
for _, cc := range cfg.Clients {
if cc.CompanyID != 255 {
if _, ok := srv.Status.Companies[cc.CompanyID]; !ok {
cc.CompanyID = 255
}
}
}
}
func (s *ServerTTD) PruneClients() { func (s *ServerTTD) PruneClients() {
for cltID, clt := range s.Status.Clients { for cltID, clt := range s.Status.Clients {
if clt.LastSeen.Add(2 * updateHeartBeat).Before(time.Now()) { if clt.LastSeen.Add(2 * updateHeartBeat).Before(time.Now()) {

View File

@ -1,6 +1,6 @@
// Code generated by version.sh (@generated) DO NOT EDIT. // Code generated by version.sh (@generated) DO NOT EDIT.
package main package main
var githash = "3ddb733" var githash = "d312644"
var buildstamp = "2021-11-22_10:20:29" var buildstamp = "2021-11-26_00:22:05"
var commits = "204" var commits = "205"
var version = "3ddb733-b204 - 2021-11-22_10:20:29" var version = "d312644-b205 - 2021-11-26_00:22:05"