From 07c2ea7adbbf4ecab5241b02df7fcd7055ff8fb5 Mon Sep 17 00:00:00 2001 From: shoopea Date: Fri, 26 Nov 2021 08:22:37 +0800 Subject: [PATCH] cleanup config client --- ttd.go | 11 +++++++++++ version.go | 8 ++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ttd.go b/ttd.go index 72b982d..ae0f9f0 100644 --- a/ttd.go +++ b/ttd.go @@ -138,6 +138,7 @@ func (s *ServerTTD) HeartBeat(stop chan struct{}) { s.UpdateDate() s.UpdateClients() s.UpdateCompanies() + s.UpdateConfigClients() s.PruneClients() s.PruneCompanies() s.ComputeClientTime() @@ -565,6 +566,16 @@ func (s *ServerTTD) UpdateCompanies() { 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() { for cltID, clt := range s.Status.Clients { if clt.LastSeen.Add(2 * updateHeartBeat).Before(time.Now()) { diff --git a/version.go b/version.go index 0a9093b..97bbd46 100644 --- a/version.go +++ b/version.go @@ -1,6 +1,6 @@ // Code generated by version.sh (@generated) DO NOT EDIT. package main -var githash = "3ddb733" -var buildstamp = "2021-11-22_10:20:29" -var commits = "204" -var version = "3ddb733-b204 - 2021-11-22_10:20:29" +var githash = "d312644" +var buildstamp = "2021-11-26_00:22:05" +var commits = "205" +var version = "d312644-b205 - 2021-11-26_00:22:05"