mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-06-04 06:49:21 +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
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
|
||||||
"Open_IM/pkg/utils"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
@ -18,7 +16,7 @@ var (
|
|||||||
Root = filepath.Join(filepath.Dir(b), "../../..")
|
Root = filepath.Join(filepath.Dir(b), "../../..")
|
||||||
)
|
)
|
||||||
|
|
||||||
const confName = "openIMConf"
|
const ConfName = "openIMConf"
|
||||||
|
|
||||||
var Config config
|
var Config config
|
||||||
|
|
||||||
@ -729,16 +727,3 @@ func init() {
|
|||||||
Config.TokenPolicy.AccessSecret = UsualConfig.Tokenpolicy.AccessSecret
|
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"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
clientv3 "go.etcd.io/etcd/client/v3"
|
clientv3 "go.etcd.io/etcd/client/v3"
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -129,7 +130,7 @@ func UnRegisterEtcd() {
|
|||||||
rEtcd.cli.Delete(rEtcd.ctx, rEtcd.key)
|
rEtcd.cli.Delete(rEtcd.ctx, rEtcd.key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterConf(key, conf string) {
|
func registerConf(key, conf string) {
|
||||||
etcdAddr := strings.Join(config.Config.Etcd.EtcdAddr, ",")
|
etcdAddr := strings.Join(config.Config.Etcd.EtcdAddr, ",")
|
||||||
cli, err := clientv3.New(clientv3.Config{
|
cli, err := clientv3.New(clientv3.Config{
|
||||||
Endpoints: strings.Split(etcdAddr, ","), DialTimeout: 5 * time.Second})
|
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