maingate를 접근하는 로직 제거

This commit is contained in:
2023-06-20 17:51:55 +09:00
parent 0e94c204d3
commit 94b6d1499a

View File

@ -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())