Organize configuration files and configuration items, and remove redundant fields.

pull/454/head
skiffer-git 2 years ago
parent 94e91d561d
commit ba3e10813a

@ -45,9 +45,6 @@ func startPprof() {
} }
func run(port int) error { func run(port int) error {
if port == 0 {
port = config.Config.Api.GinPort[0]
}
var err error var err error
rdb, err := cache.NewRedis() rdb, err := cache.NewRedis()
if err != nil { if err != nil {

@ -1,67 +1,56 @@
# The class cannot be named by Pascal or camel case. # OpenIM config
# If it is not used, the corresponding structure will not be set,
# and it will not be read naturally.
serverversion: 2.3.7
#---------------Infrastructure configuration---------------------# #---------------Infrastructure configuration---------------------#
zookeeper: zookeeper:
schema: openim #默认即可 schema: openim #默认即可
zkAddr: [ 127.0.0.1:2181 ] #单机部署时,默认即可 address: [ 127.0.0.1:2181 ] #
userName: userName:
password: password:
mysql: mysql:
dbMysqlAddress: [ 127.0.0.1:13306 ] #mysql地址 目前仅支持单机,默认即可 address: [ 127.0.0.1:13306 ] #mysql地址 目前仅支持单机,默认即可
dbMysqlUserName: root #mysql用户名建议修改 userName: root #mysql用户名建议修改
dbMysqlPassword: openIM123 # mysql密码建议修改 password: openIM123 # mysql密码建议修改
dbMysqlDatabaseName: openIM_v2 #默认即可 databaseName: openIM_v2 #默认即可
dbTableName: eMsg #默认即可 maxOpenConns: 100 #
dbMsgTableNum: 1 maxIdleConns: 10 #
dbMaxOpenConns: 100 maxLifeTime: 5 #
dbMaxIdleConns: 10 logLevel: 4 # 1=slient 2=error 3=warn 4=info
dbMaxLifeTime: 5 slowThreshold: 500 # 毫秒
logLevel: 4 #1=slient 2=error 3=warn 4=info
slowThreshold: 500
mongo: mongo:
dbUri: ""#当dbUri值不为空则直接使用该值 uri: #不为空则直接使用该值
dbAddress: [ 127.0.0.1:37017 ] #单机时为mongo地址使用分片集群时为mongos地址 默认即可 address: [ 127.0.0.1:37017 ] #单机时为mongo地址使用分片集群时为mongos地址 默认即可
dbDirect: false timeout: 60
dbTimeout: 60 database: openIM #mongo db 默认即可
dbDatabase: openIM #mongo db 默认即可 source: admin
dbSource: admin userName: root #mongo用户名建议先不设置
dbUserName: root #mongo用户名建议先不设置 password: openIM123 #mongo密码建议先不设置
dbPassword: openIM123 #mongo密码建议先不设置 maxPoolSize: 100
dbMaxPoolSize: 100 retainChatRecords: 3650 #mongo保存离线消息时间根据需求修改
dbRetainChatRecords: 3650 #mongo保存离线消息时间根据需求修改 chatRecordsClearTime: "0 2 * * 3" #每周三凌晨2点清除mongo中的过期消息该配置和linux定时任务一样
chatRecordsClearTime: "0 2 * * 3" # 每周三凌晨2点清除消息该配置和linux定时任务一样 清理操作建议设置在用户活跃少的时候 # 0 3 * * *
redis: redis:
dbAddress: [ 127.0.0.1:16379 ] #redis地址 单机时填写一个地址即可使用redis集群时候填写集群中多个节点地址主从地址都可以填写增加容灾能力默认即可 address: [ 127.0.0.1:16379 ] #redis地址 单机时填写一个地址即可使用redis集群时候填写集群中多个节点地址主从地址都可以填写增加容灾能力默认即可
dbMaxIdle: 128 userName: #only redis version 6.0+ need username
dbMaxActive: 0 passWord: openIM123 #redis密码 建议修改
dbIdleTimeout: 120
dbUserName: #only redis version 6.0+ need username
dbPassWord: openIM123 #redis密码 建议修改
enableCluster: false #如果外部redis以集群方式启动需要打开此开关
kafka: kafka:
SASLUserName: SASLUserName:
SASLPassword: SASLPassword:
ws2mschat: addr: [ 127.0.0.1:9092 ] #kafka配置默认即可
addr: [ 127.0.0.1:9092 ] #kafka配置默认即可 latestMsgToRedis:
topic: "ws2ms_chat" #用于mongo和mysql保存消息 topic: "latestMsgToRedis" #
msgtomongo: offlineMsgToMongoMysql:
addr: [ 127.0.0.1:9092 ] #kafka配置默认即可 topic: "offlineMsgToMongoMysql" #用于mongo和mysql保存消息
topic: "msg_to_mongo" msqToPush:
ms2pschat: topic: "msqToPush" #消息push
addr: [ 127.0.0.1:9092 ] #kafka配置默认即可 msgToModify:
topic: "ms2ps_chat" #消息push topic: "msgToModify" #消息push
msgtomodify: consumerGroupID:
addr: [ 127.0.0.1:9092 ] #kafka配置默认即可 msgToRedis: redis
topic: "msg_to_modify" msgToMongo: mongo
consumergroupid:
msgToTransfer: mongo
msgToMongo: mongo_ex
msgToMySql: mysql msgToMySql: mysql
msgToPush: push msgToPush: push
msgToModify: modify msgToModify: modify
@ -69,42 +58,36 @@ kafka:
#---------------Internal service configuration---------------------# #---------------Internal service configuration---------------------#
# The service ip default is empty,
# automatically obtain the machine's valid network card ip as the service ip,
# otherwise the configuration ip is preferred
#如果是单机模式用0.0.0.0或者不填,默认即可
#作为rpc时注册到etcd的地址单机默认即可如果是集群部署需要修改具体使用内网地址还是外网地址要依情况而定目的是api/gateway能访问到
rpcRegisterIP:
#默认即可 rpc:
listenIP: 0.0.0.0 registerIP: #作为rpc启动时注册到zookeeper的IPapi/gateway能访问到此ip和对应的rpcPort中的端口
listenIP: #如不设置则为 0.0.0.0
api: api:
openImApiPort: [ 10002 ] #api服务端口默认即可需要开放此端口或做nginx转发 openImApiPort: [ 10002 ] #api服务端口
listenIP: 0.0.0.0 listenIP:
sdk: sdk:
openImSdkWsPort: [ 10003 ] #jssdk服务端口默认即可项目中使用jssdk才需开放此端口或做nginx转发 openImSdkWsPort: [ 10003 ] #jssdk服务端口
dataDir: [ ../db/sdk/ ] dataDir: [ ../db/sdk/ ]
openImWsAddress: ws://127.0.0.1:10001 openImWsAddress: ws://127.0.0.1:10001
openImApiAddress: http://127.0.0.1:10002 openImApiAddress: http://127.0.0.1:10002
#对象存储服务以下配置二选一目前支持两种腾讯云和minio二者配置好其中一种即可如果使用minio参考https://doc.rentsoft.cn/#/qa/minio搭建minio服务器
credential: #腾讯cos发送图片、视频、文件时需要请自行申请后替换必须修改
object: object:
enable: minio enable: minio
apiURL: http://127.0.0.1:10002/third/object apiURL: http://127.0.0.1:10002/third/object
minio: #MinIO 发送图片、视频、文件时需要,请自行申请后替换,必须修改。 客户端初始化InitSDK中 object_storage参数为minio minio:
tempBucket: "openim" tempBucket: "openim"
dataBucket: "openim" dataBucket: "openim"
location: us-east-1 location: us-east-1
endpoint: http://127.0.0.1:10005 #minio外网ip 这个ip是给客户端访问的 endpoint: http://127.0.0.1:10005 #minio外网ip 这个ip是给客户端访问的
accessKeyID: root accessKeyID: root
secretAccessKey: openIM123 secretAccessKey: openIM123
isDistributedMod: false # 是否分布式多硬盘部署 默认docker-compose中为false如果是多硬盘部署需要修改为true isDistributedMod: false #是否分布式多硬盘部署 默认docker-compose中为false如果是多硬盘部署需要修改为true
tencent: tencent:
appID: appID:
region: region:
@ -131,7 +114,7 @@ object:
externalId: #角色扩展Id externalId: #角色扩展Id
roleSessionName: #角色SESSION名称 roleSessionName: #角色SESSION名称
rpcport: #rpc服务端口 默认即可 rpcPort: #rpc服务端口 默认即可
openImUserPort: [ 10110 ] openImUserPort: [ 10110 ]
openImFriendPort: [ 10120 ] openImFriendPort: [ 10120 ]
openImMessagePort: [ 10130 ] openImMessagePort: [ 10130 ]
@ -143,7 +126,7 @@ rpcport: #rpc服务端口 默认即可
openImRtcPort: [ 10190 ] openImRtcPort: [ 10190 ]
openImThirdPort: [ 10200 ] openImThirdPort: [ 10200 ]
rpcregistername: #rpc注册服务名默认即可 rpcRegisterName: #rpc注册服务名默认即可
openImUserName: User openImUserName: User
openImFriendName: Friend openImFriendName: Friend
openImMsgName: Msg openImMsgName: Msg
@ -158,65 +141,44 @@ rpcregistername: #rpc注册服务名默认即可
log: log:
storageLocation: ../logs/ storageLocation: ../logs/
rotationTime: 24 rotationTime: 24
remainRotationCount: 2 #日志数量 remainRotationCount: 2 #日志数量
#日志级别 6表示全都打印测试阶段建议设置为6 remainLogLevel: 6 #日志级别 6表示全都打印测试阶段建议设置为6
remainLogLevel: 6
isStdout: false isStdout: false
isJson: false isJson: false
withStack: false withStack: false
modulename: #日志文件按模块命名,默认即可
longConnSvrName: msg_gateway
msgTransferName: msg_transfer
pushName: push
longconnsvr: longConnSvr:
openImWsPort: [ 10001 ] # ws服务端口默认即可要开放此端口或做nginx转发 openImWsPort: [ 10001 ] #ws服务端口默认即可要开放此端口或做nginx转发
websocketMaxConnNum: 10000 websocketMaxConnNum: 10000
websocketMaxMsgLen: 4096 websocketMaxMsgLen: 4096
websocketTimeOut: 10 websocketTimeOut: 10
## 推送只能开启一个 enable代表开启
push: push:
tpns: #腾讯推送,暂未测试 暂不要使用 enable: getui
ios: geTui: #个推推送
accessID: 1600018281
secretKey: 3cd68a77a95b89e5089a1aca523f318f
android:
accessID: 111
secretKey: 111
enable: false # true or false (bool)
jpns: #极光推送 在极光后台申请后,修改以下四项,必须修改
appKey:
masterSecret:
pushUrl:
pushIntent:
enable: false # true or false (bool)
getui: #个推推送
pushUrl: "https://restapi.getui.com/v2/$appId" pushUrl: "https://restapi.getui.com/v2/$appId"
masterSecret: "" masterSecret: ""
appKey: "" appKey: ""
intent: "" intent: ""
enable: false # true or false (bool)
channelID: "" channelID: ""
channelName: "" channelName: ""
fcm: #firebase cloud message 消息推送 fcm: #firebase cloud message 消息推送
serviceAccount: "openim-5c6c0-firebase-adminsdk-ppwol-8765884a78.json" #帐号文件,此处需要改修配置,并且这个文件放在 config目录下 serviceAccount: "openim-5c6c0-firebase-adminsdk-ppwol-8765884a78.json" #帐号文件,此处需要改修配置,并且这个文件放在 config目录下
enable: false
manager: manager:
#app管理员userID和对应的secret 建议修改。 用于管理后台登录也可以用户管理后台对应的api #app管理员userID和nickename 用于管理后台登录
appManagerUid: [ "openIM123456","openIM654321", "openIM333", "openIMAdmin" ] appManagerUserID: [ "openIM123456","openIM654321","openIMAdmin" ]
nickname: [ "系统通知","openIM654321", "openIM333", "openIMAdmin" ] appManagerNickname: [ "system1","system2", "system3" ]
secret: tuoyun
# 多端互踢策略 # 多端互踢策略
# 1多平台登录Android、iOS、Windows、Mac 每种平台只能一个在线web端可以多个同时在线 # 1多平台登录Android、iOS、Windows、Mac 每种平台只能一个在线web端可以多个同时在线
multiloginpolicy: 1 multiLoginPolicy: 1
#msg log insert to db #msg log insert to db
chatpersistencemysql: true chatPersistenceMysql: true
#消息缓存时间 #消息缓存时间
msgCacheTimeout: 86400 msgCacheTimeout: 86400
#群聊已读开启 #群聊已读开启
@ -225,82 +187,82 @@ groupMessageHasReadReceiptEnable: true
singleMessageHasReadReceiptEnable: true singleMessageHasReadReceiptEnable: true
#token config #token config
tokenpolicy: tokenPolicy:
accessSecret: "OpenIM_server" #token生成相关默认即可 accessSecret: openIM123 #token生成相关默认即可
# Token effective time day as a unit # Token effective time day as a unit
accessExpire: 90 #token过期时间 默认即可 accessExpire: 90 #token过期时间 默认即可
messageverify:
messageVerify:
friendVerify: false friendVerify: false
#ios系统推送声音以及标记计数 #ios系统推送声音以及标记计数
iospush: iosPush:
pushSound: "xxx" pushSound: "xxx"
badgeCount: true badgeCount: true
production: false production: false
callback: callback:
# callback url 需要自行更换callback url # callback url 需要自行更换callback url
callbackUrl: "http://127.0.0.1:10008/callback/open_im" url:
# 开启关闭操作前后回调的配置 beforeSendSingleMsg:
callbackBeforeSendSingleMsg:
enable: false # 回调是否启用 enable: false # 回调是否启用
callbackTimeOut: 2 # 回调超时时间 timeout: 5 #callback超时时间
callbackFailedContinue: true # 回调超时是否继续执行代码 failedContinue: true #如果callback失败是否继续
callbackAfterSendSingleMsg: afterSendSingleMsg:
enable: false enable: false
callbackTimeOut: 2 timeout: 5
callbackBeforeSendGroupMsg: beforeSendGroupMsg:
enable: false enable: false
callbackTimeOut: 2 timeout: 5
callbackFailedContinue: true failedContinue: true
callbackAfterSendGroupMsg: afterSendGroupMsg:
enable: false enable: false
callbackTimeOut: 2 timeout: 5
callbackMsgModify: msgModify:
enable: false enable: false
callbackTimeOut: 2 timeout: 5
callbackFailedContinue: true failedContinue: true
callbackUserOnline: userOnline:
enable: false enable: false
callbackTimeOut: 2 timeout: 5
callbackUserOffline: userOffline:
enable: false enable: false
callbackTimeOut: 2 timeout: 5
callbackUserKickOff: userKickOff:
enable: false enable: false
callbackTimeOut: 2 timeout: 5
callbackOfflinePush: offlinePush:
enable: false enable: false
callbackTimeOut: 2 timeout: 5
callbackFailedContinue: true # 回调超时是否继续离线推送 failedContinue: true
callbackOnlinePush: onlinePush:
enable: false enable: false
callbackTimeOut: 2 timeout: 5
callbackFailedContinue: true # 回调超时是否继续离线推送 failedContinue: true
callbackSuperGroupOnlinePush: superGroupOnlinePush:
enable: false enable: false
callbackTimeOut: 2 timeout: 5
callbackFailedContinue: true # 回调超时是否继续离线推送 failedContinue: true
callbackBeforeAddFriend: beforeAddFriend:
enable: false enable: false
callbackTimeOut: 2 timeout: 5
callbackFailedContinue: true # 回调超时是否继续 failedContinue: true
callbackBeforeCreateGroup: beforeCreateGroup:
enable: false enable: false
callbackTimeOut: 2 timeout: 5
callbackFailedContinue: true # 回调超时是否继续 failedContinue: true
callbackBeforeMemberJoinGroup: beforeMemberJoinGroup:
enable: false enable: false
callbackTimeOut: 2 timeout: 5
callbackFailedContinue: true # 回调超时是否继续 failedContinue: true
callbackBeforeSetGroupMemberInfo: beforeSetGroupMemberInfo:
enable: false enable: false
callbackTimeOut: 2 timeout: 5
callbackFailedContinue: true # 回调超时是否继续 failedContinue: true
callbackSetMessageReactionExtensions: setMessageReactionExtensions:
enable: false enable: false
callbackTimeOut: 2 timeout: 5
callbackFailedContinue: true # 回调超时是否继续 failedContinue: true
# prometheus每个服务监听的端口数量需要和rpc port保持一致 # prometheus每个服务监听的端口数量需要和rpc port保持一致
prometheus: prometheus:

@ -30,7 +30,7 @@ func NewModifyMsgConsumerHandler(database controller.ExtendMsgDatabase) *ModifyM
return &ModifyMsgConsumerHandler{ return &ModifyMsgConsumerHandler{
modifyMsgConsumerGroup: kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0, modifyMsgConsumerGroup: kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0,
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.MsgToModify.Topic}, OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.MsgToModify.Topic},
config.Config.Kafka.MsgToModify.Addr, config.Config.Kafka.ConsumerGroupID.MsgToModify), config.Config.Kafka.Addr, config.Config.Kafka.ConsumerGroupID.MsgToModify),
extendMsgDatabase: database, extendMsgDatabase: database,
} }
} }

@ -75,8 +75,8 @@ func NewOnlineHistoryRedisConsumerHandler(database controller.CommonMsgDatabase,
och.conversationRpcClient = conversationRpcClient och.conversationRpcClient = conversationRpcClient
och.groupRpcClient = groupRpcClient och.groupRpcClient = groupRpcClient
och.historyConsumerGroup = kafka.NewMConsumerGroup(&kafka.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0, och.historyConsumerGroup = kafka.NewMConsumerGroup(&kafka.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0,
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.Ws2mschat.Topic}, OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.LatestMsgToRedis.Topic},
config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.ConsumerGroupID.MsgToRedis) config.Config.Kafka.Addr, config.Config.Kafka.ConsumerGroupID.MsgToRedis)
//statistics.NewStatistics(&och.singleMsgSuccessCount, config.Config.ModuleName.MsgTransferName, fmt.Sprintf("%d second singleMsgCount insert to mongo", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval) //statistics.NewStatistics(&och.singleMsgSuccessCount, config.Config.ModuleName.MsgTransferName, fmt.Sprintf("%d second singleMsgCount insert to mongo", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
return &och return &och
} }

@ -21,7 +21,7 @@ func NewOnlineHistoryMongoConsumerHandler(database controller.CommonMsgDatabase)
mc := &OnlineHistoryMongoConsumerHandler{ mc := &OnlineHistoryMongoConsumerHandler{
historyConsumerGroup: kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0, historyConsumerGroup: kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0,
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.MsgToMongo.Topic}, OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.MsgToMongo.Topic},
config.Config.Kafka.MsgToMongo.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMongo), config.Config.Kafka.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMongo),
msgDatabase: database, msgDatabase: database,
} }
return mc return mc

@ -29,8 +29,8 @@ type PersistentConsumerHandler struct {
func NewPersistentConsumerHandler(database controller.ChatLogDatabase) *PersistentConsumerHandler { func NewPersistentConsumerHandler(database controller.ChatLogDatabase) *PersistentConsumerHandler {
return &PersistentConsumerHandler{ return &PersistentConsumerHandler{
persistentConsumerGroup: kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0, persistentConsumerGroup: kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0,
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.Ws2mschat.Topic}, OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.LatestMsgToRedis.Topic},
config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMySql), config.Config.Kafka.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMySql),
chatLogDatabase: database, chatLogDatabase: database,
} }
} }

@ -124,8 +124,8 @@ func newPushReq(title, content string) PushReq {
Title: title, Title: title,
Body: content, Body: content,
ClickType: "startapp", ClickType: "startapp",
ChannelID: config.Config.Push.Getui.ChannelID, ChannelID: config.Config.Push.GeTui.ChannelID,
ChannelName: config.Config.Push.Getui.ChannelName, ChannelName: config.Config.Push.GeTui.ChannelName,
}}} }}}
return pushReq return pushReq
} }

@ -1,8 +1,13 @@
package getui package getui
import ( import (
"github.com/go-redis/redis"
"sync" "sync"
"context"
"crypto/sha256"
"encoding/hex"
"errors"
"github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush" "github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
@ -11,12 +16,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs" "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils/splitter" "github.com/OpenIMSDK/Open-IM-Server/pkg/utils/splitter"
"github.com/redis/go-redis/v9"
"context"
"crypto/sha256"
"encoding/hex"
"errors"
"strconv" "strconv"
"time" "time"
@ -98,12 +97,12 @@ func (g *Client) Push(ctx context.Context, userIDs []string, title, content stri
func (g *Client) Auth(ctx context.Context, timeStamp int64) (token string, expireTime int64, err error) { func (g *Client) Auth(ctx context.Context, timeStamp int64) (token string, expireTime int64, err error) {
h := sha256.New() h := sha256.New()
h.Write([]byte(config.Config.Push.Getui.AppKey + strconv.Itoa(int(timeStamp)) + config.Config.Push.Getui.MasterSecret)) h.Write([]byte(config.Config.Push.GeTui.AppKey + strconv.Itoa(int(timeStamp)) + config.Config.Push.GeTui.MasterSecret))
sign := hex.EncodeToString(h.Sum(nil)) sign := hex.EncodeToString(h.Sum(nil))
reqAuth := AuthReq{ reqAuth := AuthReq{
Sign: sign, Sign: sign,
Timestamp: strconv.Itoa(int(timeStamp)), Timestamp: strconv.Itoa(int(timeStamp)),
AppKey: config.Config.Push.Getui.AppKey, AppKey: config.Config.Push.GeTui.AppKey,
} }
respAuth := AuthResp{} respAuth := AuthResp{}
err = g.request(ctx, authURL, reqAuth, "", &respAuth) err = g.request(ctx, authURL, reqAuth, "", &respAuth)
@ -146,7 +145,7 @@ func (g *Client) request(ctx context.Context, url string, input interface{}, tok
header := map[string]string{"token": token} header := map[string]string{"token": token}
resp := &Resp{} resp := &Resp{}
resp.Data = output resp.Data = output
return g.postReturn(ctx, config.Config.Push.Getui.PushUrl+url, header, input, resp, 3) return g.postReturn(ctx, config.Config.Push.GeTui.PushUrl+url, header, input, resp, 3)
} }
func (g *Client) postReturn(ctx context.Context, url string, header map[string]string, input interface{}, output RespI, timeout int) error { func (g *Client) postReturn(ctx context.Context, url string, header map[string]string, input interface{}, output RespI, timeout int) error {

@ -23,7 +23,7 @@ func NewConsumerHandler(pusher *Pusher) *ConsumerHandler {
var consumerHandler ConsumerHandler var consumerHandler ConsumerHandler
consumerHandler.pusher = pusher consumerHandler.pusher = pusher
consumerHandler.pushConsumerGroup = kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0, consumerHandler.pushConsumerGroup = kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0,
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.Ms2pschat.Topic}, config.Config.Kafka.Ms2pschat.Addr, OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.Ms2pschat.Topic}, config.Config.Kafka.Addr,
config.Config.Kafka.ConsumerGroupID.MsgToPush) config.Config.Kafka.ConsumerGroupID.MsgToPush)
return &consumerHandler return &consumerHandler
} }

@ -57,7 +57,7 @@ func NewPusher(discov discoveryregistry.SvcDiscoveryRegistry, offlinePusher offl
func NewOfflinePusher(cache cache.MsgModel) offlinepush.OfflinePusher { func NewOfflinePusher(cache cache.MsgModel) offlinepush.OfflinePusher {
var offlinePusher offlinepush.OfflinePusher var offlinePusher offlinepush.OfflinePusher
if config.Config.Push.Getui.Enable { if config.Config.Push.GeTui.Enable {
offlinePusher = getui.NewClient(cache) offlinePusher = getui.NewClient(cache)
} }
if config.Config.Push.Fcm.Enable { if config.Config.Push.Fcm.Enable {
@ -164,8 +164,8 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
return err return err
} }
log.ZInfo(ctx, "GroupDismissedNotificationInfo****", "groupID", groupID, "num", len(pushToUserIDs), "list", pushToUserIDs) log.ZInfo(ctx, "GroupDismissedNotificationInfo****", "groupID", groupID, "num", len(pushToUserIDs), "list", pushToUserIDs)
if len(config.Config.Manager.AppManagerUid) > 0 { if len(config.Config.Manager.AppManagerUserID) > 0 {
ctx = mcontext.WithOpUserIDContext(ctx, config.Config.Manager.AppManagerUid[0]) ctx = mcontext.WithOpUserIDContext(ctx, config.Config.Manager.AppManagerUserID[0])
} }
defer func(groupID string) { defer func(groupID string) {
if err := p.groupRpcClient.DismissGroup(ctx, groupID); err != nil { if err := p.groupRpcClient.DismissGroup(ctx, groupID); err != nil {

@ -45,10 +45,10 @@ func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
return err return err
} }
users := make([]*tablerelation.UserModel, 0) users := make([]*tablerelation.UserModel, 0)
if len(config.Config.Manager.AppManagerUid) != len(config.Config.Manager.Nickname) { if len(config.Config.Manager.AppManagerUserID) != len(config.Config.Manager.Nickname) {
return errs.ErrConfig.Wrap("len(config.Config.Manager.AppManagerUid) != len(config.Config.Manager.Nickname)") return errs.ErrConfig.Wrap("len(config.Config.Manager.AppManagerUid) != len(config.Config.Manager.Nickname)")
} }
for k, v := range config.Config.Manager.AppManagerUid { for k, v := range config.Config.Manager.AppManagerUserID {
users = append(users, &tablerelation.UserModel{UserID: v, Nickname: config.Config.Manager.Nickname[k]}) users = append(users, &tablerelation.UserModel{UserID: v, Nickname: config.Config.Manager.Nickname[k]})
} }
userDB := relation.NewUserGorm(db) userDB := relation.NewUserGorm(db)

@ -36,8 +36,8 @@ var Config config
type CallBackConfig struct { type CallBackConfig struct {
Enable bool `yaml:"enable"` Enable bool `yaml:"enable"`
CallbackTimeOut int `yaml:"callbackTimeOut"` CallbackTimeOut int `yaml:"timeout"`
CallbackFailedContinue *bool `yaml:"callbackFailedContinue"` CallbackFailedContinue *bool `yaml:"failedContinue"`
} }
type NotificationConf struct { type NotificationConf struct {
@ -55,22 +55,81 @@ type POfflinePush struct {
} }
type config struct { type config struct {
ServerIP string `yaml:"serverip"` Zookeeper struct {
Schema string `yaml:"schema"`
ZkAddr []string `yaml:"address"`
UserName string `yaml:"userName"`
Password string `yaml:"password"`
} `yaml:"zookeeper"`
Mysql struct {
DBAddress []string `yaml:"address"`
DBUserName string `yaml:"userName"`
DBPassword string `yaml:"password"`
DBDatabaseName string `yaml:"databaseName"`
DBMaxOpenConns int `yaml:"maxOpenConns"`
DBMaxIdleConns int `yaml:"maxIdleConns"`
DBMaxLifeTime int `yaml:"maxLifeTime"`
LogLevel int `yaml:"logLevel"`
SlowThreshold int `yaml:"slowThreshold"`
} `yaml:"mysql"`
Mongo struct {
DBUri string `yaml:"uri"`
DBAddress []string `yaml:"address"`
DBTimeout int `yaml:"timeout"`
DBDatabase string `yaml:"database"`
DBSource string `yaml:"source"`
DBUserName string `yaml:"userName"`
DBPassword string `yaml:"password"`
DBMaxPoolSize int `yaml:"maxPoolSize"`
DBRetainChatRecords int `yaml:"retainChatRecords"`
ChatRecordsClearTime string `yaml:"chatRecordsClearTime"`
} `yaml:"mongo"`
Redis struct {
DBAddress []string `yaml:"address"`
DBUserName string `yaml:"userName"`
DBPassWord string `yaml:"passWord"`
} `yaml:"redis"`
Kafka struct {
SASLUserName string `yaml:"SASLUserName"`
SASLPassword string `yaml:"SASLPassword"`
Addr []string `yaml:"addr"`
LatestMsgToRedis struct {
Topic string `yaml:"topic"`
} `yaml:"latestMsgToRedis"`
OfflineMsgToMongoMysql struct {
Topic string `yaml:"topic"`
} `yaml:"offlineMsgToMongoMysql"`
MsqToPush struct {
Topic string `yaml:"topic"`
} `yaml:"msqToPush"`
MsgToModify struct {
Topic string `yaml:"topic"`
} `yaml:"msgToModify"`
ConsumerGroupID struct {
MsgToRedis string `yaml:"msgToRedis"`
MsgToMongo string `yaml:"msgToMongo"`
MsgToMySql string `yaml:"msgToMySql"`
MsgToPush string `yaml:"msgToPush"`
MsgToModify string `yaml:"msgToModify"`
} `yaml:"consumerGroupID"`
} `yaml:"kafka"`
RpcRegisterIP string `yaml:"rpcRegisterIP"` Rpc struct {
ListenIP string `yaml:"listenIP"` RegisterIP string `yaml:"registerIP"`
ListenIP string `yaml:"listenIP"`
} `yaml:"rpc"`
ServerVersion string `yaml:"serverversion"` Api struct {
Api struct {
GinPort []int `yaml:"openImApiPort"`
ListenIP string `yaml:"listenIP"` ListenIP string `yaml:"listenIP"`
} } `yaml:"api"`
Sdk struct { Sdk struct {
WsPort []int `yaml:"openImSdkWsPort"`
DataDir []string `yaml:"dataDir"` DataDir []string `yaml:"dataDir"`
} } `yaml:"sdk"`
Credential struct {
}
Object struct { Object struct {
Enable string `yaml:"enable"` Enable string `yaml:"enable"`
@ -90,7 +149,7 @@ type config struct {
Bucket string `yaml:"bucket"` Bucket string `yaml:"bucket"`
SecretID string `yaml:"secretID"` SecretID string `yaml:"secretID"`
SecretKey string `yaml:"secretKey"` SecretKey string `yaml:"secretKey"`
} } `yaml:"tencent"`
Ali struct { Ali struct {
RegionID string `yaml:"regionID"` RegionID string `yaml:"regionID"`
AccessKeyID string `yaml:"accessKeyID"` AccessKeyID string `yaml:"accessKeyID"`
@ -101,7 +160,7 @@ type config struct {
FinalHost string `yaml:"finalHost"` FinalHost string `yaml:"finalHost"`
StsDurationSeconds int64 `yaml:"stsDurationSeconds"` StsDurationSeconds int64 `yaml:"stsDurationSeconds"`
OssRoleArn string `yaml:"OssRoleArn"` OssRoleArn string `yaml:"OssRoleArn"`
} } `yaml:"ali"`
Aws struct { Aws struct {
AccessKeyID string `yaml:"accessKeyID"` AccessKeyID string `yaml:"accessKeyID"`
AccessKeySecret string `yaml:"accessKeySecret"` AccessKeySecret string `yaml:"accessKeySecret"`
@ -112,56 +171,10 @@ type config struct {
ExternalId string `yaml:"externalId"` ExternalId string `yaml:"externalId"`
RoleSessionName string `yaml:"roleSessionName"` RoleSessionName string `yaml:"roleSessionName"`
} `yaml:"aws"` } `yaml:"aws"`
} } `yaml:"object"`
Mysql struct {
DBAddress []string `yaml:"dbMysqlAddress"`
DBUserName string `yaml:"dbMysqlUserName"`
DBPassword string `yaml:"dbMysqlPassword"`
DBDatabaseName string `yaml:"dbMysqlDatabaseName"`
DBTableName string `yaml:"DBTableName"`
DBMsgTableNum int `yaml:"dbMsgTableNum"`
DBMaxOpenConns int `yaml:"dbMaxOpenConns"`
DBMaxIdleConns int `yaml:"dbMaxIdleConns"`
DBMaxLifeTime int `yaml:"dbMaxLifeTime"`
LogLevel int `yaml:"logLevel"`
SlowThreshold int `yaml:"slowThreshold"`
}
Mongo struct {
DBUri string `yaml:"dbUri"`
DBAddress []string `yaml:"dbAddress"`
DBDirect bool `yaml:"dbDirect"`
DBTimeout int `yaml:"dbTimeout"`
DBDatabase string `yaml:"dbDatabase"`
DBSource string `yaml:"dbSource"`
DBUserName string `yaml:"dbUserName"`
DBPassword string `yaml:"dbPassword"`
DBMaxPoolSize int `yaml:"dbMaxPoolSize"`
DBRetainChatRecords int `yaml:"dbRetainChatRecords"`
ChatRecordsClearTime string `yaml:"chatRecordsClearTime"`
}
Redis struct {
DBAddress []string `yaml:"dbAddress"`
DBMaxIdle int `yaml:"dbMaxIdle"`
DBMaxActive int `yaml:"dbMaxActive"`
DBIdleTimeout int `yaml:"dbIdleTimeout"`
DBUserName string `yaml:"dbUserName"`
DBPassWord string `yaml:"dbPassWord"`
EnableCluster bool `yaml:"enableCluster"`
}
RpcPort struct { RpcPort struct {
OpenImUserPort []int `yaml:"openImUserPort"` } `yaml:"rpcPort"`
OpenImFriendPort []int `yaml:"openImFriendPort"`
OpenImMessagePort []int `yaml:"openImMessagePort"`
OpenImMessageGatewayPort []int `yaml:"openImMessageGatewayPort"`
OpenImGroupPort []int `yaml:"openImGroupPort"`
OpenImAuthPort []int `yaml:"openImAuthPort"`
OpenImPushPort []int `yaml:"openImPushPort"`
OpenImConversationPort []int `yaml:"openImConversationPort"`
OpenImCachePort []int `yaml:"openImCachePort"`
OpenImRtcPort []int `yaml:"openImRtcPort"`
OpenImThirdPort []int `yaml:"openImThirdPort"`
}
RpcRegisterName struct { RpcRegisterName struct {
OpenImUserName string `yaml:"openImUserName"` OpenImUserName string `yaml:"openImUserName"`
OpenImFriendName string `yaml:"openImFriendName"` OpenImFriendName string `yaml:"openImFriendName"`
@ -173,124 +186,85 @@ type config struct {
OpenImConversationName string `yaml:"openImConversationName"` OpenImConversationName string `yaml:"openImConversationName"`
OpenImRtcName string `yaml:"openImRtcName"` OpenImRtcName string `yaml:"openImRtcName"`
OpenImThirdName string `yaml:"openImThirdName"` OpenImThirdName string `yaml:"openImThirdName"`
} } `yaml:"rpcRegisterName"`
Zookeeper struct {
Schema string `yaml:"schema"`
ZkAddr []string `yaml:"zkAddr"`
UserName string `yaml:"userName"`
Password string `yaml:"password"`
} `yaml:"zookeeper"`
Log struct { Log struct {
StorageLocation string `yaml:"storageLocation"` StorageLocation string `yaml:"storageLocation"`
RotationTime int `yaml:"rotationTime"` RotationTime int `yaml:"rotationTime"`
RemainRotationCount uint `yaml:"remainRotationCount"` RemainRotationCount uint `yaml:"remainRotationCount"`
RemainLogLevel int `yaml:"remainLogLevel"` RemainLogLevel int `yaml:"remainLogLevel"`
IsStdout bool `yaml:"isStdout"` IsStdout bool `yaml:"isStdout"`
WithStack bool `yaml:"withStack"`
IsJson bool `yaml:"isJson"` IsJson bool `yaml:"isJson"`
} WithStack bool `yaml:"withStack"`
ModuleName struct { } `yaml:"log"`
LongConnSvrName string `yaml:"longConnSvrName"`
MsgTransferName string `yaml:"msgTransferName"`
PushName string `yaml:"pushName"`
}
LongConnSvr struct { LongConnSvr struct {
WebsocketPort []int `yaml:"openImWsPort"` WebsocketMaxConnNum int `yaml:"websocketMaxConnNum"`
WebsocketMaxConnNum int `yaml:"websocketMaxConnNum"` WebsocketMaxMsgLen int `yaml:"websocketMaxMsgLen"`
WebsocketMaxMsgLen int `yaml:"websocketMaxMsgLen"` WebsocketTimeOut int `yaml:"websocketTimeOut"`
WebsocketTimeOut int `yaml:"websocketTimeOut"` } `yaml:"longConnSvr"`
}
Push struct { Push struct {
Jpns struct { Enable string `yaml:"enable"`
AppKey string `yaml:"appKey"` GeTui struct {
MasterSecret string `yaml:"masterSecret"`
PushUrl string `yaml:"pushUrl"`
PushIntent string `yaml:"pushIntent"`
Enable bool `yaml:"enable"`
}
Getui struct {
PushUrl string `yaml:"pushUrl"` PushUrl string `yaml:"pushUrl"`
AppKey string `yaml:"appKey"` AppKey string `yaml:"appKey"`
Enable bool `yaml:"enable"`
Intent string `yaml:"intent"` Intent string `yaml:"intent"`
MasterSecret string `yaml:"masterSecret"` MasterSecret string `yaml:"masterSecret"`
ChannelID string `yaml:"channelID"` ChannelID string `yaml:"channelID"`
ChannelName string `yaml:"channelName"` ChannelName string `yaml:"channelName"`
} } `yaml:"geTui"`
Fcm struct { Fcm struct {
ServiceAccount string `yaml:"serviceAccount"` ServiceAccount string `yaml:"serviceAccount"`
Enable bool `yaml:"enable"` } `yaml:"fcm"`
} Jpns struct {
AppKey string `yaml:"appKey"`
MasterSecret string `yaml:"masterSecret"`
PushUrl string `yaml:"pushUrl"`
PushIntent string `yaml:"pushIntent"`
} `yaml:"jpns"`
} }
Manager struct { Manager struct {
AppManagerUid []string `yaml:"appManagerUid"` AppManagerUserID []string `yaml:"appManagerUserID"`
Nickname []string `yaml:"nickname"` Nickname []string `yaml:"nickname"`
} } `yaml:"manager"`
Kafka struct { MultiLoginPolicy int `yaml:"multiLoginPolicy"`
SASLUserName string `yaml:"SASLUserName"` ChatPersistenceMysql bool `yaml:"chatPersistenceMysql"`
SASLPassword string `yaml:"SASLPassword"` MsgCacheTimeout int `yaml:"msgCacheTimeout"`
Ws2mschat struct { GroupMessageHasReadReceiptEnable bool `yaml:"groupMessageHasReadReceiptEnable"`
Addr []string `yaml:"addr"` SingleMessageHasReadReceiptEnable bool `yaml:"singleMessageHasReadReceiptEnable"`
Topic string `yaml:"topic"`
}
MsgToMongo struct {
Addr []string `yaml:"addr"`
Topic string `yaml:"topic"`
}
Ms2pschat struct {
Addr []string `yaml:"addr"`
Topic string `yaml:"topic"`
}
MsgToModify struct {
Addr []string `yaml:"addr"`
Topic string `yaml:"topic"`
}
ConsumerGroupID struct {
MsgToRedis string `yaml:"msgToTransfer"`
MsgToMongo string `yaml:"msgToMongo"`
MsgToMySql string `yaml:"msgToMySql"`
MsgToPush string `yaml:"msgToPush"`
MsgToModify string `yaml:"msgToModify"`
}
}
Secret string `yaml:"secret"`
MultiLoginPolicy int `yaml:"multiloginpolicy"`
ChatPersistenceMysql bool `yaml:"chatpersistencemysql"`
MsgCacheTimeout int `yaml:"msgCacheTimeout"`
GroupMessageHasReadReceiptEnable bool `yaml:"groupMessageHasReadReceiptEnable"`
SingleMessageHasReadReceiptEnable bool `yaml:"singleMessageHasReadReceiptEnable"`
TokenPolicy struct { TokenPolicy struct {
AccessSecret string `yaml:"accessSecret"` AccessSecret string `yaml:"accessSecret"`
AccessExpire int64 `yaml:"accessExpire"` AccessExpire int64 `yaml:"accessExpire"`
} } `yaml:"tokenPolicy"`
MessageVerify struct { MessageVerify struct {
FriendVerify *bool `yaml:"friendVerify"` FriendVerify *bool `yaml:"friendVerify"`
} } `yaml:"messageVerify"`
IOSPush struct { IOSPush struct {
PushSound string `yaml:"pushSound"` PushSound string `yaml:"pushSound"`
BadgeCount bool `yaml:"badgeCount"` BadgeCount bool `yaml:"badgeCount"`
Production bool `yaml:"production"` Production bool `yaml:"production"`
} } `yaml:"iosPush"`
Callback struct { Callback struct {
CallbackUrl string `yaml:"callbackUrl"` CallbackUrl string `yaml:"url"`
CallbackBeforeSendSingleMsg CallBackConfig `yaml:"callbackBeforeSendSingleMsg"` CallbackBeforeSendSingleMsg CallBackConfig `yaml:"beforeSendSingleMsg"`
CallbackAfterSendSingleMsg CallBackConfig `yaml:"callbackAfterSendSingleMsg"` CallbackAfterSendSingleMsg CallBackConfig `yaml:"afterSendSingleMsg"`
CallbackBeforeSendGroupMsg CallBackConfig `yaml:"callbackBeforeSendGroupMsg"` CallbackBeforeSendGroupMsg CallBackConfig `yaml:"beforeSendGroupMsg"`
CallbackAfterSendGroupMsg CallBackConfig `yaml:"callbackAfterSendGroupMsg"` CallbackAfterSendGroupMsg CallBackConfig `yaml:"afterSendGroupMsg"`
CallbackMsgModify CallBackConfig `yaml:"callbackMsgModify"` CallbackMsgModify CallBackConfig `yaml:"msgModify"`
CallbackUserOnline CallBackConfig `yaml:"callbackUserOnline"` CallbackUserOnline CallBackConfig `yaml:"userOnline"`
CallbackUserOffline CallBackConfig `yaml:"callbackUserOffline"` CallbackUserOffline CallBackConfig `yaml:"userOffline"`
CallbackUserKickOff CallBackConfig `yaml:"callbackUserKickOff"` CallbackUserKickOff CallBackConfig `yaml:"userKickOff"`
CallbackOfflinePush CallBackConfig `yaml:"callbackOfflinePush"` CallbackOfflinePush CallBackConfig `yaml:"offlinePush"`
CallbackOnlinePush CallBackConfig `yaml:"callbackOnlinePush"` CallbackOnlinePush CallBackConfig `yaml:"onlinePush"`
CallbackBeforeSuperGroupOnlinePush CallBackConfig `yaml:"callbackSuperGroupOnlinePush"` CallbackBeforeSuperGroupOnlinePush CallBackConfig `yaml:"superGroupOnlinePush"`
CallbackBeforeAddFriend CallBackConfig `yaml:"callbackBeforeAddFriend"` CallbackBeforeAddFriend CallBackConfig `yaml:"beforeAddFriend"`
CallbackBeforeCreateGroup CallBackConfig `yaml:"callbackBeforeCreateGroup"` CallbackBeforeCreateGroup CallBackConfig `yaml:"beforeCreateGroup"`
CallbackBeforeMemberJoinGroup CallBackConfig `yaml:"callbackBeforeMemberJoinGroup"` CallbackBeforeMemberJoinGroup CallBackConfig `yaml:"beforeMemberJoinGroup"`
CallbackBeforeSetGroupMemberInfo CallBackConfig `yaml:"callbackBeforeSetGroupMemberInfo"` CallbackBeforeSetGroupMemberInfo CallBackConfig `yaml:"beforeSetGroupMemberInfo"`
} `yaml:"callback"` } `yaml:"callback"`
Notification Notification `yaml:"notification"` Notification Notification `yaml:"notification"`

@ -2,6 +2,7 @@ package controller
import ( import (
"fmt" "fmt"
"github.com/go-redis/redis"
"time" "time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
@ -20,7 +21,6 @@ import (
pbMsg "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg" pbMsg "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws" "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils" "github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"github.com/redis/go-redis/v9"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
) )
@ -98,10 +98,10 @@ func NewCommonMsgDatabase(msgDocModel unRelationTb.MsgDocModelInterface, cacheMo
return &commonMsgDatabase{ return &commonMsgDatabase{
msgDocDatabase: msgDocModel, msgDocDatabase: msgDocModel,
cache: cacheModel, cache: cacheModel,
producer: kafka.NewKafkaProducer(config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.Ws2mschat.Topic), producer: kafka.NewKafkaProducer(config.Config.Kafka.Addr, config.Config.Kafka.LatestMsgToRedis.Topic),
producerToMongo: kafka.NewKafkaProducer(config.Config.Kafka.MsgToMongo.Addr, config.Config.Kafka.MsgToMongo.Topic), producerToMongo: kafka.NewKafkaProducer(config.Config.Kafka.Addr, config.Config.Kafka.MsgToMongo.Topic),
producerToPush: kafka.NewKafkaProducer(config.Config.Kafka.Ms2pschat.Addr, config.Config.Kafka.Ms2pschat.Topic), producerToPush: kafka.NewKafkaProducer(config.Config.Kafka.Addr, config.Config.Kafka.Ms2pschat.Topic),
producerToModify: kafka.NewKafkaProducer(config.Config.Kafka.MsgToModify.Addr, config.Config.Kafka.MsgToModify.Topic), producerToModify: kafka.NewKafkaProducer(config.Config.Kafka.Addr, config.Config.Kafka.MsgToModify.Topic),
} }
} }

@ -26,7 +26,7 @@ func init() {
func initAesKey() { func initAesKey() {
once.Do(func() { once.Do(func() {
key := md5.Sum([]byte("openim:" + config.Config.Secret)) key := md5.Sum([]byte("openim:" + config.Config.TokenPolicy.AccessSecret))
var err error var err error
block, err = aes.NewCipher(key[:]) block, err = aes.NewCipher(key[:])
if err != nil { if err != nil {

@ -7,7 +7,7 @@ import (
) )
func TestCheck(t *testing.T) { func TestCheck(t *testing.T) {
config.Config.Secret = "123456" config.Config.TokenPolicy.Secret = "123456"
args := []string{"1", "2", "3"} args := []string{"1", "2", "3"}

@ -21,7 +21,7 @@ import (
func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error, options ...grpc.ServerOption) error { func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error, options ...grpc.ServerOption) error {
fmt.Println("start", rpcRegisterName, "server, port: ", rpcPort, "prometheusPort:", prometheusPort, ", OpenIM version: ", config.Version) fmt.Println("start", rpcRegisterName, "server, port: ", rpcPort, "prometheusPort:", prometheusPort, ", OpenIM version: ", config.Version)
listener, err := net.Listen("tcp", net.JoinHostPort(config.Config.ListenIP, strconv.Itoa(rpcPort))) listener, err := net.Listen("tcp", net.JoinHostPort(network.GetListenIP(config.Config.Rpc.ListenIP), strconv.Itoa(rpcPort)))
if err != nil { if err != nil {
return err return err
} }
@ -34,7 +34,7 @@ func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(c
} }
defer zkClient.CloseZK() defer zkClient.CloseZK()
zkClient.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials())) zkClient.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()))
registerIP, err := network.GetRpcRegisterIP(config.Config.RpcRegisterIP) registerIP, err := network.GetRpcRegisterIP(config.Config.Rpc.RegisterIP)
if err != nil { if err != nil {
return err return err
} }

Loading…
Cancel
Save