From 94b6d1499a94301ee8878f311f150f647c47cf08 Mon Sep 17 00:00:00 2001 From: mountain Date: Tue, 20 Jun 2023 17:51:55 +0900 Subject: [PATCH] =?UTF-8?q?maingate=EB=A5=BC=20=EC=A0=91=EA=B7=BC=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EB=A1=9C=EC=A7=81=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- authcollection.go | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/authcollection.go b/authcollection.go index 7108972..fb78dd7 100644 --- a/authcollection.go +++ b/authcollection.go @@ -97,45 +97,7 @@ func (ac *redisAuthCell) ToBytes() []byte { } func newAuthCollectionWithRedis(redisClient *redis.Client, subctx context.Context, maingateURL string, apiToken string) *AuthCollection { - req, _ := http.NewRequest("GET", fmt.Sprintf("%s/config", maingateURL), nil) - req.Header.Add("MG-X-API-TOKEN", apiToken) - sessionTTL := int64(3600) - client := http.Client{ - Timeout: 3 * time.Second, - } - resp, err := client.Do(req) - if resp != nil { - defer resp.Body.Close() - } - - if err != nil { - if !*devflag { - logger.Error("get maingate config failed :", err) - return nil - } - } else if resp.StatusCode == http.StatusOK { - raw, _ := io.ReadAll(resp.Body) - if len(raw) == 0 { - logger.Error("get maingate config failed :", err) - return nil - } - - var config map[string]any - err = json.Unmarshal(raw, &config) - if err != nil { - logger.Error("get maingate config failed :", err) - return nil - } - - if ttl, ok := config["maingate_session_ttl"].(float64); ok { - sessionTTL = int64(ttl) - } - } else if !*devflag { - logger.Error("get maingate config failed :", err) - return nil - } - ac := MakeAuthCollection(time.Duration(sessionTTL * int64(time.Second))) pubsub := redisClient.Subscribe(subctx, sessionSyncChannelName) ctx, cancel := context.WithCancel(context.TODO())