mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-06-02 13:19:19 +08:00
Merge branch 'v2.3.0release' of github.com:OpenIMSDK/Open-IM-Server into v2.3.0release
# Conflicts: # config/usualConfig.yaml
This commit is contained in:
parent
de528270a2
commit
405a60c4f8
@ -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))
|
||||
}
|
||||
|
@ -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))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user