From 405a60c4f8abf9d1112c3a0ef6a087ef603ef783 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Mon, 14 Nov 2022 18:35:53 +0800 Subject: [PATCH] Merge branch 'v2.3.0release' of github.com:OpenIMSDK/Open-IM-Server into v2.3.0release # Conflicts: # config/usualConfig.yaml --- pkg/common/config/config.go | 17 +---------------- pkg/grpc-etcdv3/getcdv3/register.go | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index 64ca6d727..4fce63c19 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -1,8 +1,6 @@ package config import ( - "Open_IM/pkg/grpc-etcdv3/getcdv3" - "Open_IM/pkg/utils" "fmt" "io/ioutil" "os" @@ -18,7 +16,7 @@ var ( Root = filepath.Join(filepath.Dir(b), "../../..") ) -const confName = "openIMConf" +const ConfName = "openIMConf" var Config config @@ -729,16 +727,3 @@ func init() { Config.TokenPolicy.AccessSecret = UsualConfig.Tokenpolicy.AccessSecret } } - -func RegisterConf() { - bytes, err := yaml.Marshal(Config) - if err != nil { - panic(err.Error()) - } - secretMD5 := utils.Md5(Config.Etcd.Secret) - confBytes, err := utils.AesEncrypt(bytes, []byte(secretMD5[0:16])) - if err != nil { - panic(err.Error()) - } - getcdv3.RegisterConf(getcdv3.GetPrefix(Config.Etcd.EtcdSchema, confName), string(confBytes)) -} diff --git a/pkg/grpc-etcdv3/getcdv3/register.go b/pkg/grpc-etcdv3/getcdv3/register.go index 6884dc465..3416fca18 100644 --- a/pkg/grpc-etcdv3/getcdv3/register.go +++ b/pkg/grpc-etcdv3/getcdv3/register.go @@ -7,6 +7,7 @@ import ( "context" "fmt" clientv3 "go.etcd.io/etcd/client/v3" + "gopkg.in/yaml.v3" "net" "strconv" "strings" @@ -129,7 +130,7 @@ func UnRegisterEtcd() { rEtcd.cli.Delete(rEtcd.ctx, rEtcd.key) } -func RegisterConf(key, conf string) { +func registerConf(key, conf string) { etcdAddr := strings.Join(config.Config.Etcd.EtcdAddr, ",") cli, err := clientv3.New(clientv3.Config{ Endpoints: strings.Split(etcdAddr, ","), DialTimeout: 5 * time.Second}) @@ -150,3 +151,16 @@ func RegisterConf(key, conf string) { } } + +func init() { + bytes, err := yaml.Marshal(config.Config) + if err != nil { + panic(err.Error()) + } + secretMD5 := utils.Md5(config.Config.Etcd.Secret) + confBytes, err := utils.AesEncrypt(bytes, []byte(secretMD5[0:16])) + if err != nil { + panic(err.Error()) + } + registerConf(GetPrefix(config.Config.Etcd.EtcdSchema, config.ConfName), string(confBytes)) +}