Compare commits

...
31 Commits
Author SHA1 Message Date
heavyrian2012 1486b19ce1 更新版本和release note 2022-11-19 09:44:09 +08:00
heavyrian2012 3e1095f745 移动release note文件的位置 2022-11-19 09:38:26 +08:00
heavyrian2012 17039bd3c1 http请求错误时不打印数据内容,防止内容泄露 2022-11-19 09:31:22 +08:00
heavyrian2012 b5d8feab62 客户端连接时检查是否跟获取token的平台一致 2022-11-18 22:10:53 +08:00
heavyrian2012 95b08ff7a3 Revert "mqtt proto version error"
This reverts commit ab8ae9d0c9.
2022-11-18 21:55:49 +08:00
heavyrian2012 ab8ae9d0c9 mqtt proto version error 2022-11-18 21:27:18 +08:00
heavyrian2012 b4d163e144 添加android客户端签名验证功能 2022-11-18 16:01:17 +08:00
heavyrian2012 3ccfd9a29b 解决user setting并发问题,fix #566 2022-11-15 17:12:51 +08:00
heavyrian2012 90504d1305 打包dockerfile 2022-11-14 15:47:42 +08:00
heavyrian2012 88199189a2 当禁止陌生人聊天时,添加例外允许用户id,用于比如管理员、文件助手等场景 2022-11-14 15:23:03 +08:00
heavyrian2012 0b6612eacc 内置对象存储支持绝对路径和相对路径 2022-11-14 15:13:06 +08:00
heavyrian2012 d706f545d2 解决启动脚本中的小错误 2022-11-14 15:04:51 +08:00
heavyrian2012 ae8d63b162 update docker readme 2022-11-14 14:42:04 +08:00
heavyrian2012 77e742e812 添加server sdk检查server api的工具 2022-11-12 19:25:24 +08:00
heavyrian2012 b2ee8b8d94 linux安装包创建日志目录 2022-11-12 19:24:57 +08:00
heavyrian2012 7080d85605 只有server api才能创建组织群 2022-11-12 15:01:57 +08:00
heavyrian2012 1275b2109f fix build error 2022-11-12 14:18:26 +08:00
heavyrian2012 b2eab28cb9 组织群客户端不能自主退出 2022-11-12 14:17:15 +08:00
heavyrian2012 67234ceaa6 添加新的群组类型:组织群 2022-11-12 14:00:24 +08:00
heavyrian2012 45f9e20e97 支持转发消息include/exclude类型,支持配置消息区间 2022-11-12 12:51:25 +08:00
heavyrian2012 6b7edc713a API获取用户信息时,过滤掉被删除的用户 2022-11-09 10:36:52 +08:00
heavyrian2012 1ef8f94d67 忽略掉无效的请求和日志 2022-11-05 17:05:31 +08:00
heavyrian2012 9b0b644cd1 update version and release note 2022-11-01 08:47:34 +08:00
heavyrian2012 b233c49d73 解决字符编码错误问题 2022-11-01 08:40:07 +08:00
heavyrian2012 b8d8d2f8ed 群组成员表添加成员索引和获取2个人共同群组的接口 2022-10-28 21:56:20 +08:00
heavyrian2012 731020ba0f update readme 2022-10-27 08:40:47 +08:00
heavyrian2012 4c00955639 更新readme 2022-10-27 08:33:09 +08:00
heavyrian2012 cbc150905f update screenshots 2022-10-26 10:32:48 +08:00
heavyrian2012 a71b8cef73 add more screenshots 2022-10-26 10:27:03 +08:00
heavyrian2012 66c67fa8d1 pc 截图大小 2022-10-26 09:29:36 +08:00
heavyrian2012 3ca7c70faa add screenshots 2022-10-26 09:26:43 +08:00
71 changed files with 784 additions and 195 deletions
+108 -32
View File
@@ -28,7 +28,7 @@
## 野火开源项目 ## 野火开源项目
主要包括以下项目: 主要包括以下项目:
| [GitHub仓库地址](https://github.com/wildfirechat) | [码云仓库地址](https://gitee.com/wfchat) | 说明 | [GitHub仓库](https://github.com/wildfirechat) | [码云仓库](https://gitee.com/wfchat) | 说明
| ------------------------------------------------------------ | ----------------------------------------------------- | -------------------------------------------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------------- | --------------------------------------------------------------------------
| [im-server](https://github.com/wildfirechat/im-server) | [im-server](https://gitee.com/wfchat/im-server) | 野火社区版IM服务,野火IM的核心服务,处理所有IM相关业务。 | | [im-server](https://github.com/wildfirechat/im-server) | [im-server](https://gitee.com/wfchat/im-server) | 野火社区版IM服务,野火IM的核心服务,处理所有IM相关业务。 |
| [app-server](https://github.com/wildfirechat/app-server) | [app-server](https://gitee.com/wfchat/app-server) | Demo应用服务,模拟客户的应用服登陆处理逻辑及部分二次开发示例。 | | [app-server](https://github.com/wildfirechat/app-server) | [app-server](https://gitee.com/wfchat/app-server) | Demo应用服务,模拟客户的应用服登陆处理逻辑及部分二次开发示例。 |
@@ -45,7 +45,7 @@
| [web-chat](https://github.com/wildfirechat/vue-chat) | [web-chat](https://gitee.com/wfchat/vue-chat) | 野火IM Web 端, [体验地址](https://web.wildfirechat.cn)。 | | [web-chat](https://github.com/wildfirechat/vue-chat) | [web-chat](https://gitee.com/wfchat/vue-chat) | 野火IM Web 端, [体验地址](https://web.wildfirechat.cn)。 |
| [wx-chat](https://github.com/wildfirechat/wx-chat) | [wx-chat](https://gitee.com/wfchat/wx-chat) | 小程序平台的Demo(支持微信、百度、阿里、字节、QQ 等小程序平台)。 | | [wx-chat](https://github.com/wildfirechat/wx-chat) | [wx-chat](https://gitee.com/wfchat/wx-chat) | 小程序平台的Demo(支持微信、百度、阿里、字节、QQ 等小程序平台)。 |
| [uni-chat](https://github.com/wildfirechat/uni-chat) | [uni-chat](https://gitee.com/wfchat/uni-chat) | UniApp平台移动端应用(使用原生插件)。 | | [uni-chat](https://github.com/wildfirechat/uni-chat) | [uni-chat](https://gitee.com/wfchat/uni-chat) | UniApp平台移动端应用(使用原生插件)。 |
| [uni-wfc-client](https://github.com/wildfirechat/uni-wfc-client) | [uni-wfc-client](https://gitee.com/wfchat/uni-wfc-client) | UniApp平台原生插件。 | | [uni-wfc-client](https://github.com/wildfirechat/uni-wfc-client) | [uni-wfc-client](https://gitee.com/wfchat/uni-wfc-client) | UniApp平台原生插件。已[商店](https://ext.dcloud.net.cn/plugin?id=7895)上架 |
| [flutter_imclient](https://github.com/wildfirechat/flutter_imclient) | [flutter_imclient](https://gitee.com/wfchat/flutter_imclient) | Flutter平台原生插件。 | | [flutter_imclient](https://github.com/wildfirechat/flutter_imclient) | [flutter_imclient](https://gitee.com/wfchat/flutter_imclient) | Flutter平台原生插件。 |
| [docs](https://github.com/wildfirechat/docs) | [docs](https://gitee.com/wfchat/docs) | 野火IM相关文档,包含设计、概念、开发、使用说明,[在线查看](https://docs.wildfirechat.cn/)。 | | [docs](https://github.com/wildfirechat/docs) | [docs](https://gitee.com/wfchat/docs) | 野火IM相关文档,包含设计、概念、开发、使用说明,[在线查看](https://docs.wildfirechat.cn/)。 |
@@ -73,34 +73,24 @@ PC客户端点[这里](https://github.com/wildfirechat/vue-pc-chat/releases)下
之后再部署开放平台服务、频道(公众号)服务、机器人服务、推送服务、Turn服务(音视频服务)来实现完整的应用功能,详情可以详细阅读文档。 之后再部署开放平台服务、频道(公众号)服务、机器人服务、推送服务、Turn服务(音视频服务)来实现完整的应用功能,详情可以详细阅读文档。
## 应用截图 ## 联系我们
![ios-demo](http://static.wildfirechat.cn/ios-demo.gif) 商务合作请微信联系:
<img src="http://static.wildfirechat.cn/ios-message-view.png" width = 50% height = 50% /> * 微信1:wildfirechat
* 微信2:wfchat
<img src="http://static.wildfirechat.cn/ios-contact-view.png" width = 50% height = 50% /> ## 问题交流
<img src="http://static.wildfirechat.cn/ios-discover-view.png" width = 50% height = 50% /> 1. 如果大家发现bug,请在GitHub或码云提issue;如果有需求也请给我们提issue。
2. 其他问题,请到[野火IM论坛](http://bbs.wildfirechat.cn/)进行交流学习
3. 关注我们的公众号。我们有新版本发布或者有重大更新会通过公众号通知大家,另外我们也会不定期的发布一些关于野火IM的技术介绍。
<img src="http://static.wildfirechat.cn/ios-settings-view.png" width = 50% height = 50% /> <img src="http://static.wildfirechat.cn/wx_wfc_qrcode.jpg" width = 50% height = 50% />
<img src="http://static.wildfirechat.cn/ios-messagelist-view.png" width = 50% height = 50% /> 我们有核心研发工程师轮流值班处理issue和论坛,会及时处理的,疑难Bug的修改和新需求的开发我们也会尽快解决。
<img src="http://static.wildfirechat.cn/ios-chat-setting-view.png" width = 50% height = 50% />
<img src="http://static.wildfirechat.cn/ios-takephoto-view.png" width = 50% height = 50% />
<img src="http://static.wildfirechat.cn/ios-record-voice-view.png" width = 50% height = 50% />
<img src="http://static.wildfirechat.cn/ios-location-view.png" width = 50% height = 50% />
<img src="http://static.wildfirechat.cn/ios-voip-view.png" width = 50% height = 50% />
## 编译 ## 编译
由于```distribution/pom.xml```中使用了生成RPM包的plugin,所以需要本地安装有rpm。如果不需要RPM包,可以删除掉```distribution/pom.xml```文件中的RPM plugin。
在安装RPM后或者删除```distribution/pom.xml```文件中的RPM plugin后,执行下面命令:
``` ```
mvn clean package mvn clean package
``` ```
@@ -119,6 +109,11 @@ mvn clean package
1. 在浏览器中输入地址 ```http://${ip}/api/version```可以看到返回一个json文件。 1. 在浏览器中输入地址 ```http://${ip}/api/version```可以看到返回一个json文件。
2. 部署[应用服务](https://github.com/wildfirechat/app-server),配置和编译[Android客户端](https://github.com/wildfirechat/android-chat)和[iOS客户端](https://github.com/wildfirechat/ios-chat)进行验证。详情可参考[快速开始](https://docs.wildfirechat.cn/quick_start/)。 2. 部署[应用服务](https://github.com/wildfirechat/app-server),配置和编译[Android客户端](https://github.com/wildfirechat/android-chat)和[iOS客户端](https://github.com/wildfirechat/ios-chat)进行验证。详情可参考[快速开始](https://docs.wildfirechat.cn/quick_start/)。
## 打包RPM格式
打包会生成Java包和deb安装包,如果需要rpm安装包,请在```distribution/pom.xml```中取消注释生成rpm包的plugin。另外还需要本地安装有rpm,在linux或者mac系统中很容易安装,在windows系统需要安装cygwin并安装rpm,具体信息请百度查询。
修改之后运行编译命令```mvn clean package```,rpm包生成在```distribution/target```目录下。
## 升级说明 ## 升级说明
1. 从0.42 版本增加了群成员数限制,默认为2000。如果您从之前的版本升级到这个版本或以后,需要注意到群成员数的限制。升级之后超出限制的群不受影响,但不能继续加人,如果您想修改默认值,可以在升级版本之后,修改t_setting表,把默认的大小改为您期望的人数。另外修改t_group表,把已经存在的群组max_member_count改成您期望的,然后重启。 1. 从0.42 版本增加了群成员数限制,默认为2000。如果您从之前的版本升级到这个版本或以后,需要注意到群成员数的限制。升级之后超出限制的群不受影响,但不能继续加人,如果您想修改默认值,可以在升级版本之后,修改t_setting表,把默认的大小改为您期望的人数。另外修改t_group表,把已经存在的群组max_member_count改成您期望的,然后重启。
2. 0.50版本添加了是否允许客户端发送群操作通知的配置。如果您在客户端自定义群通知,需要在服务器端配置允许,没有使用自定义群操作通知的不受影响。*** 2. 0.50版本添加了是否允许客户端发送群操作通知的配置。如果您在客户端自定义群通知,需要在服务器端配置允许,没有使用自定义群操作通知的不受影响。***
@@ -131,23 +126,104 @@ mvn clean package
9. 从0.79 版本起把log4j升级到log4j2,因为log4j已经不再维护而且还有已知的漏洞,建议所有客户都升级,升级时注意更新log4j2的配置文件 9. 从0.79 版本起把log4j升级到log4j2,因为log4j已经不再维护而且还有已知的漏洞,建议所有客户都升级,升级时注意更新log4j2的配置文件
10. 0.97版本更改了启动脚本```wildfirechat.sh```,如果是升级服务,请注意更新启动脚本。 10. 0.97版本更改了启动脚本```wildfirechat.sh```,如果是升级服务,请注意更新启动脚本。
## 应用截图
登录界面
## 联系我们 <img src="./screenshots/1_login.png" width = 50% height = 50% />
商务合作请微信联系: 会话列表
* 微信1:wildfirechat <img src="./screenshots/2_conversation_list.png" width = 50% height = 50% />
* 微信2:wfchat
## 问题交流 好友列表
1. 如果大家发现bug,请在GitHub或码云提issue;如果有需求也请给我们提issue。 <img src="./screenshots/3_contacts_list.png" width = 50% height = 50% />
2. 其他问题,请到[野火IM论坛](http://bbs.wildfirechat.cn/)进行交流学习
3. 关注我们的公众号。我们有新版本发布或者有重大更新会通过公众号通知大家,另外我们也会不定期的发布一些关于野火IM的技术介绍。
<img src="http://static.wildfirechat.cn/wx_wfc_qrcode.jpg" width = 50% height = 50% /> 工作台
我们有核心研发工程师轮流值班处理issue和论坛,会及时处理的,疑难Bug的修改和新需求的开发我们也会尽快解决。 <img src="./screenshots/4_workplatform.png" width = 50% height = 50% />
发现
<img src="./screenshots/5_discover.png" width = 50% height = 50% />
我的页面
<img src="./screenshots/6_settings.png" width = 50% height = 50% />
消息聊天
<img src="./screenshots/7_conversation.png" width = 50% height = 50% />
动态表情
<img src="./screenshots/8_conversation_sticker.png" width = 50% height = 50% />
语音消息
<img src="./screenshots/9_conversation_voice_msg.png" width = 50% height = 50% />
位置消息
<img src="./screenshots/10_conversation_location.png" width = 50% height = 50% />
拍摄图片或者小视频
<img src="./screenshots/11_conversation_capture.jpeg" width = 50% height = 50% />
会话设置
<img src="./screenshots/13_conversation_settings.png" width = 50% height = 50% />
朋友圈
<img src="./screenshots/14_moments.png" width = 50% height = 50% />
新好友
<img src="./screenshots/15_new_friends.png" width = 50% height = 50% />
多人视频通话
<img src="./screenshots/16_videocall.png" width = 50% height = 50% />
会议主页
<img src="./screenshots/17_conference_home.png" width = 50% height = 50% />
会议详情
<img src="./screenshots/18_conference_info.png" width = 50% height = 50% />
会议界面
<img src="./screenshots/19_conference.png" width = 50% height = 50% />
PC客户端界面
<img src="./screenshots/20_pc.png"/>
移动客户端、PC客户端和Web客户端三端同框
<img src="./screenshots/21_three_platform.png" />
小程序客户端
<img src="./screenshots/22_micro_app.jpeg" width = 50% height = 50% />
公众号管理后台
<img src="./screenshots/23_channel.png"/>
开放平台管理后台
<img src="./screenshots/24_open_platform.png" />
IM服务管理后台
<img src="./screenshots/25_im_admin.png" />
> 更多详细信息请下载demo进行体验。
## 特别感谢 ## 特别感谢
1. [moquette](https://github.com/moquette-io/moquette) 本项目是基于此项目二次开发而来,处理MQTT相关业务。 1. [moquette](https://github.com/moquette-io/moquette) 本项目是基于此项目二次开发而来,处理MQTT相关业务。
+15 -3
View File
@@ -59,6 +59,12 @@ token.key testim
##token的过期时间,单位为毫秒,默认为无限期。如果需要设置无限期,客户端上一定需要加上token过期的处理。token过期的处理请参考文档的常见问题 ##token的过期时间,单位为毫秒,默认为无限期。如果需要设置无限期,客户端上一定需要加上token过期的处理。token过期的处理请参考文档的常见问题
##token.expire_time 2592000000 ##token.expire_time 2592000000
##客户端(目前只有android)的应用签名(一个应用最取第一个签名),如果有多个签名(多个客户端),用英文逗号分开。获取签名方法请参考文档:https://docs.wildfirechat.cn/blogs/签名验证.html
#connect.client_signature_list eNkezQ1g9OsnhfLSFUY1vzKDzhs=,xykezQ1g9OsnhfLSFUY1vzKDzhs=
##是否拒绝空签名的android客户端, 默认为true。当有旧的客户端需要兼容时改成false,当所有都是新客户端时,改成true。
#connect.reject_empty_signature true
##首次登录,是否接收之前的历史消息。 ##首次登录,是否接收之前的历史消息。
##0 不接收历史消息,只接收${message.compensate_time_limit}毫秒以内的消息,由于服务器没有保存已经收取记录,所以如果有超过${message.compensate_time_limit}毫秒之前未收取的消息也不会收取下拉; ##0 不接收历史消息,只接收${message.compensate_time_limit}毫秒以内的消息,由于服务器没有保存已经收取记录,所以如果有超过${message.compensate_time_limit}毫秒之前未收取的消息也不会收取下拉;
##1接收,会接收 message.max_queue 配置的条数的历史消息 ##1接收,会接收 message.max_queue 配置的条数的历史消息
@@ -79,6 +85,9 @@ message.chatroom_remote_history_message 1
##是否禁止陌生人聊天 ##是否禁止陌生人聊天
message.disable_stranger_chat false message.disable_stranger_chat false
##当禁止陌生人聊天时,允许聊天的用户id,比如管理员或者文件传输助手等。用户id以英文逗号分割。
message.allow_stranger_chat_list admin,FireRobot,wfc_file_transfer
##黑名单策略,0 发送失败,返回被拉黑的错误码;1 发送成功但消息被服务器直接丢弃 ##黑名单策略,0 发送失败,返回被拉黑的错误码;1 发送成功但消息被服务器直接丢弃
message.blacklist.strategy 0 message.blacklist.strategy 0
@@ -293,14 +302,17 @@ push.ios.server.address http://localhost:8085/ios/push
##消息转发地址 ##消息转发地址
##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!! ##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!!
#message.forward.url http://localhost:8888/im_event/message #message.forward.url http://localhost:8888/im_event/message
##需要转发的消息类型,当有多个时以英文逗号分割。如果转发所有消息,请注释掉配置或者设置为空 ##需要转发的消息类型,当有多个时以英文逗号分割,可以用-来指定区间,注意区间不能太大,因为要把区间内的所有数字都放入到Set中。如果转发所有消息,请注释掉配置或者设置为空
#message.forward.types 1,2,3 #message.forward.types 1,2,3,5-10
##需要转发的消息类型,当有多个时以英文逗号分割,可以用-来指定区间,注意区间不能太大,因为要把区间内的所有数字都放入到Set中。
#message.forward.exclude_types 1,2,3,5-10
##敏感消息转发地址 ##敏感消息转发地址
##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!! ##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!!
#message.sensitive.forward.url http://localhost:8888/im_event/message #message.sensitive.forward.url http://localhost:8888/im_event/message
##提醒消息转发地址,@全体用户和@某个用户消息会回调此地址。此转发不受${message.forward.types}限制。 ##提醒消息转发地址,@全体用户和@某个用户消息会回调此地址。
##此转发不受${message.forward.types}和${message.forward.exclude_types}限制。
##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!! ##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!!
#message.mentionmsg.forward.url http://localhost:8888/im_event/message #message.mentionmsg.forward.url http://localhost:8888/im_event/message
+1
View File
@@ -0,0 +1 @@
alter table `t_group_member` add INDEX `group_member_mid_index` (`_mid`);
+1
View File
@@ -0,0 +1 @@
alter table `t_group_member` add INDEX `group_member_mid_index` (`_mid`);
+1 -1
View File
@@ -5,7 +5,7 @@
<relativePath>../</relativePath> <relativePath>../</relativePath>
<artifactId>wildfirechat-parent</artifactId> <artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId> <groupId>cn.wildfirechat</groupId>
<version>0.97</version> <version>0.99</version>
</parent> </parent>
<artifactId>moquette-broker</artifactId> <artifactId>moquette-broker</artifactId>
@@ -240,7 +240,12 @@ public class UploadFileAction extends Action {
datePath = "fs/" + bucket[0] + "/" + datePath; //add bucket datePath = "fs/" + bucket[0] + "/" + datePath; //add bucket
String dir = "./" + MediaServerConfig.FILE_STROAGE_ROOT + "/" + datePath; String dir;
if(MediaServerConfig.FILE_STROAGE_ROOT.startsWith("/") || MediaServerConfig.FILE_STROAGE_ROOT.startsWith("~/") || MediaServerConfig.FILE_STROAGE_ROOT.startsWith("./")) {
dir = MediaServerConfig.FILE_STROAGE_ROOT + "/" + datePath;
} else {
dir = "./" + MediaServerConfig.FILE_STROAGE_ROOT + "/" + datePath;
}
File dirFile = new File(dir); File dirFile = new File(dir);
boolean bFile = dirFile.exists(); boolean bFile = dirFile.exists();
@@ -0,0 +1,55 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package com.xiaoleilu.loServer.action.admin;
import cn.wildfirechat.common.APIPath;
import cn.wildfirechat.common.ErrorCode;
import cn.wildfirechat.pojos.InputUserId;
import cn.wildfirechat.pojos.OutputGroupIds;
import cn.wildfirechat.pojos.StringPairPojo;
import com.xiaoleilu.loServer.RestResult;
import com.xiaoleilu.loServer.annotation.HttpMethod;
import com.xiaoleilu.loServer.annotation.Route;
import com.xiaoleilu.loServer.handler.Request;
import com.xiaoleilu.loServer.handler.Response;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.util.internal.StringUtil;
import java.util.ArrayList;
import java.util.Set;
@Route(APIPath.Get_Common_Groups)
@HttpMethod("POST")
public class GetCommonGroupsAction extends AdminAction {
@Override
public boolean isTransactionAction() {
return true;
}
@Override
public boolean action(Request request, Response response) {
if (request.getNettyRequest() instanceof FullHttpRequest) {
StringPairPojo input = getRequestBody(request.getNettyRequest(), StringPairPojo.class);
if (input != null
&& (!StringUtil.isNullOrEmpty(input.getFirst())) && (!StringUtil.isNullOrEmpty(input.getSecond()))) {
Set<String> groupIds = messagesStore.getCommonGroupIds(input.getFirst(), input.getSecond());
OutputGroupIds outputGroupIds = new OutputGroupIds();
outputGroupIds.setGroupIds(new ArrayList<>(groupIds));
RestResult result = RestResult.ok(outputGroupIds);
setResponseContent(result, response);
} else {
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
}
}
return true;
}
}
@@ -49,7 +49,7 @@ public class GetUserAction extends AdminAction {
} }
RestResult result; RestResult result;
if (user == null) { if (user == null || user.getDeleted() > 0) {
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST); result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
} else { } else {
result = RestResult.ok(InputOutputUserInfo.fromPbUser(user)); result = RestResult.ok(InputOutputUserInfo.fromPbUser(user));
@@ -44,7 +44,7 @@ public class GetUserAction extends ChannelAction {
RestResult result; RestResult result;
if (user == null || StringUtil.isNullOrEmpty(user.getName())) { if (user == null || StringUtil.isNullOrEmpty(user.getName()) || user.getDeleted() > 0) {
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST); result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
} else { } else {
if (channelInfo.getOwner().equals(inputUserId.getUserId()) || if (channelInfo.getOwner().equals(inputUserId.getUserId()) ||
@@ -44,7 +44,7 @@ public class GetUserAction extends RobotAction {
} }
RestResult result; RestResult result;
if (user == null) { if (user == null || user.getDeleted() > 0) {
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST); result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
} else { } else {
result = RestResult.ok(InputOutputUserInfo.fromPbUser(user)); result = RestResult.ok(InputOutputUserInfo.fromPbUser(user));
@@ -34,7 +34,6 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest fullHttpRequest) throws Exception { protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest fullHttpRequest) throws Exception {
Logger.info("Http request whit url {}", fullHttpRequest.uri());
final Request request = Request.build(ctx, fullHttpRequest); final Request request = Request.build(ctx, fullHttpRequest);
final Response response = Response.build(ctx, request); final Response response = Response.build(ctx, request);
@@ -124,6 +123,9 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
Action action; Action action;
if (isValidePath(request.getPath())) { if (isValidePath(request.getPath())) {
action = ServerSetting.getAction(request.getPath(), request.getMethod().toUpperCase()); action = ServerSetting.getAction(request.getPath(), request.getMethod().toUpperCase());
if (action != null) {
Logger.info("Http request whit url {}", request.getPath());
}
} else { } else {
action = ServerSetting.getErrorAction(ServerSetting.MAPPING_ERROR); action = ServerSetting.getErrorAction(ServerSetting.MAPPING_ERROR);
} }
@@ -137,7 +139,11 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
action = ServerSetting.getAction(ServerSetting.MAPPING_ALL, request.getMethod()); action = ServerSetting.getAction(ServerSetting.MAPPING_ALL, request.getMethod());
if(null == action){ if(null == action){
// 非Action方法,调用静态文件读取 // 非Action方法,调用静态文件读取
action = Singleton.get(FileAction.class); if(request.getPath().startsWith("/fs")) {
action = Singleton.get(FileAction.class);
} else {
action = ServerSetting.getErrorAction(ServerSetting.MAPPING_ERROR);
}
} }
} }
action.ctx = ctx; action.ctx = ctx;
@@ -110,6 +110,9 @@ public final class BrokerConstants {
public static final String TOKEN_SECRET_KEY = "token.key"; public static final String TOKEN_SECRET_KEY = "token.key";
public static final String TOKEN_EXPIRE_TIME = "token.expire_time"; public static final String TOKEN_EXPIRE_TIME = "token.expire_time";
public static final String CONNECT_CLIENT_SIGNATURE_LIST = "connect.client_signature_list";
public static final String CONNECT_REJECT_EMPTY_SIGNATURE = "connect.reject_empty_signature";
public static final String EMBED_DB_PROPERTY_NAME = "embed.db"; public static final String EMBED_DB_PROPERTY_NAME = "embed.db";
public static final String DB_AUTO_CLEAN_HISTORY_MESSAGES = "db.auto_clean_history_messages"; public static final String DB_AUTO_CLEAN_HISTORY_MESSAGES = "db.auto_clean_history_messages";
public static final String H2DB_PATH = "h2db.path"; public static final String H2DB_PATH = "h2db.path";
@@ -124,6 +127,7 @@ public final class BrokerConstants {
public static final String MESSAGE_Forward_Url = "message.forward.url"; public static final String MESSAGE_Forward_Url = "message.forward.url";
public static final String MESSAGE_Sensitive_Forward_Url = "message.sensitive.forward.url"; public static final String MESSAGE_Sensitive_Forward_Url = "message.sensitive.forward.url";
public static final String MESSAGE_Forward_Types = "message.forward.types"; public static final String MESSAGE_Forward_Types = "message.forward.types";
public static final String MESSAGE_Forward_Exclude_Types = "message.forward.exclude_types";
public static final String MESSAGE_MentionMsg_Forward_Url = "message.mentionmsg.forward.url"; public static final String MESSAGE_MentionMsg_Forward_Url = "message.mentionmsg.forward.url";
@@ -141,6 +145,7 @@ public final class BrokerConstants {
public static final String MESSAGE_Max_Queue = "message.max_queue"; public static final String MESSAGE_Max_Queue = "message.max_queue";
public static final String MESSAGE_Disable_Stranger_Chat = "message.disable_stranger_chat"; public static final String MESSAGE_Disable_Stranger_Chat = "message.disable_stranger_chat";
public static final String MESSAGE_Allow_Stranger_Chat_List = "message.allow_stranger_chat_list";
public static final String MESSAGE_Blacklist_Strategy = "message.blacklist.strategy"; public static final String MESSAGE_Blacklist_Strategy = "message.blacklist.strategy";
@@ -40,6 +40,10 @@ public class CreateGroupHandler extends GroupHandler<WFCMessage.CreateGroupReque
return ErrorCode.ERROR_CODE_NOT_RIGHT; return ErrorCode.ERROR_CODE_NOT_RIGHT;
} }
if(!isAdmin && request.getGroup().getGroupInfo().getType() == ProtoConstants.GroupType.GroupType_Organization) {
return ErrorCode.ERROR_CODE_NOT_RIGHT;
}
WFCMessage.GroupInfo groupInfo = m_messagesStore.createGroup(fromUser, request.getGroup().getGroupInfo(), request.getGroup().getMembersList(), request.getMemberExtra(), isAdmin); WFCMessage.GroupInfo groupInfo = m_messagesStore.createGroup(fromUser, request.getGroup().getGroupInfo(), request.getGroup().getMembersList(), request.getMemberExtra(), isAdmin);
if (groupInfo != null) { if (groupInfo != null) {
if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0) { if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
@@ -0,0 +1,33 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package io.moquette.imhandler;
import cn.wildfirechat.common.ErrorCode;
import cn.wildfirechat.proto.ProtoConstants;
import cn.wildfirechat.proto.WFCMessage;
import io.moquette.spi.impl.Qos1PublishHandler;
import io.netty.buffer.ByteBuf;
import win.liyufan.im.IMTopic;
import java.util.Set;
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
@Handler(IMTopic.GetCommonGroupsTopic)
public class GetCommonGroupsHandler extends IMHandler<WFCMessage.IDBuf> {
@Override
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, WFCMessage.IDBuf request, Qos1PublishHandler.IMCallback callback) {
WFCMessage.PullUserResult.Builder resultBuilder = WFCMessage.PullUserResult.newBuilder();
Set<String> strings = m_messagesStore.getCommonGroupIds(fromUser, request.getId());
WFCMessage.IDListBuf idListBuf = WFCMessage.IDListBuf.newBuilder().addAllId(strings).build();
byte[] data = idListBuf.toByteArray();
ackPayload.ensureWritable(data.length).writeBytes(data);
return ERROR_CODE_SUCCESS;
}
}
@@ -0,0 +1,33 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package io.moquette.imhandler;
import cn.wildfirechat.common.ErrorCode;
import cn.wildfirechat.proto.ProtoConstants;
import cn.wildfirechat.proto.WFCMessage;
import io.moquette.spi.impl.Qos1PublishHandler;
import io.netty.buffer.ByteBuf;
import win.liyufan.im.IMTopic;
import java.util.Set;
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
@Handler(IMTopic.GetMyGroupsTopic)
public class GetMyGroupsHandler extends IMHandler<Void> {
@Override
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, Void request, Qos1PublishHandler.IMCallback callback) {
WFCMessage.PullUserResult.Builder resultBuilder = WFCMessage.PullUserResult.newBuilder();
Set<String> strings = m_messagesStore.getUserGroupIds(fromUser);
WFCMessage.IDListBuf idListBuf = WFCMessage.IDListBuf.newBuilder().addAllId(strings).build();
byte[] data = idListBuf.toByteArray();
ackPayload.ensureWritable(data.length).writeBytes(data);
return ERROR_CODE_SUCCESS;
}
}
@@ -29,6 +29,10 @@ public class KickoffGroupMember extends GroupHandler<WFCMessage.RemoveGroupMembe
errorCode = ErrorCode.ERROR_CODE_NOT_EXIST; errorCode = ErrorCode.ERROR_CODE_NOT_EXIST;
} else { } else {
boolean isAdmin = requestSourceType == ProtoConstants.RequestSourceType.Request_From_Admin; boolean isAdmin = requestSourceType == ProtoConstants.RequestSourceType.Request_From_Admin;
if (!isAdmin && groupInfo.getType() == ProtoConstants.GroupType.GroupType_Organization) {
return ErrorCode.ERROR_CODE_NOT_RIGHT;
}
boolean isAllow = isAdmin; boolean isAllow = isAdmin;
if (!isAllow) { if (!isAllow) {
if (groupInfo.getOwner() != null) { if (groupInfo.getOwner() != null) {
@@ -31,7 +31,7 @@ public class QuitGroupHandler extends GroupHandler<WFCMessage.QuitGroupRequest>
return ErrorCode.ERROR_CODE_NOT_RIGHT; return ErrorCode.ERROR_CODE_NOT_RIGHT;
} }
ErrorCode errorCode = m_messagesStore.quitGroup(fromUser, request.getGroupId()); ErrorCode errorCode = m_messagesStore.quitGroup(fromUser, request.getGroupId(), isAdmin);
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) { if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
if (request.hasNotifyContent() && request.getNotifyContent().getType() > 0) { if (request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), request.getNotifyContent()); sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), request.getNotifyContent());
@@ -40,6 +40,11 @@ public class RouteHandler extends IMHandler<WFCMessage.RouteRequest> {
return ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH; return ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH;
} }
if(request.getPlatform() != session.getPlatform() && m_messagesStore.existSignatures()) {
LOG.error("Session <{}, {}> platform is {} mismatch the request {}", session.getUsername(), session.getClientID(), session.getPlatform(), request.getPlatform());
return ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH;
}
String serverIp = mServer.getServerIp(); String serverIp = mServer.getServerIp();
String longPort = mServer.getLongPort(); String longPort = mServer.getLongPort();
String shortPort = mServer.getShortPort(); String shortPort = mServer.getShortPort();
@@ -22,6 +22,7 @@ import cn.wildfirechat.common.ErrorCode;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import win.liyufan.im.*; import win.liyufan.im.*;
import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@@ -33,6 +34,7 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
private String mForwardUrl = null; private String mForwardUrl = null;
private String mSensitiveMessageForwardUrl = null; private String mSensitiveMessageForwardUrl = null;
private Set<Integer> mForwardMessageTypes = new HashSet<>(); private Set<Integer> mForwardMessageTypes = new HashSet<>();
private Set<Integer> mForwardExcludeMessageTypes = new HashSet<>();
private String mMentionForwardUrl = null; private String mMentionForwardUrl = null;
private int mBlacklistStrategy = 0; //黑名单中时,0失败,1吞掉。 private int mBlacklistStrategy = 0; //黑名单中时,0失败,1吞掉。
private boolean mNoForwardAdminMessage = false; private boolean mNoForwardAdminMessage = false;
@@ -47,12 +49,9 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
mForwardUrl = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Forward_Url); mForwardUrl = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Forward_Url);
if (!StringUtil.isNullOrEmpty(mForwardUrl)) { if (!StringUtil.isNullOrEmpty(mForwardUrl)) {
String forwardTypes = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Forward_Types); String forwardTypes = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Forward_Types);
if (!StringUtil.isNullOrEmpty(forwardTypes)) { parseTypes(mForwardMessageTypes, forwardTypes);
String[] tss = forwardTypes.split(","); String excludeTypes = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Forward_Exclude_Types);
for (String ts:tss) { parseTypes(mForwardExcludeMessageTypes, excludeTypes);
mForwardMessageTypes.add(Integer.parseInt(ts.trim()));
}
}
} }
mSensitiveMessageForwardUrl = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Sensitive_Forward_Url); mSensitiveMessageForwardUrl = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_Sensitive_Forward_Url);
mMentionForwardUrl = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_MentionMsg_Forward_Url); mMentionForwardUrl = mServer.getConfig().getProperty(BrokerConstants.MESSAGE_MentionMsg_Forward_Url);
@@ -97,6 +96,30 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
} }
private void parseTypes(Collection<Integer> collection, String types) {
try {
if (!StringUtil.isNullOrEmpty(types)) {
String[] tss = types.split(",");
for (String ts:tss) {
if(ts.contains("-")) {
String[] ss = ts.split("-");
if(ss.length == 2) {
int begin = Integer.parseInt(ss[0]);
int end = Integer.parseInt(ss[1]);
for (int i = begin; i <= end ; i++) {
collection.add(i);
}
}
} else {
collection.add(Integer.parseInt(ts.trim()));
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override @Override
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, WFCMessage.Message message, Qos1PublishHandler.IMCallback callback) { public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, ProtoConstants.RequestSourceType requestSourceType, WFCMessage.Message message, Qos1PublishHandler.IMCallback callback) {
ErrorCode errorCode = ErrorCode.ERROR_CODE_SUCCESS; ErrorCode errorCode = ErrorCode.ERROR_CODE_SUCCESS;
@@ -179,7 +202,7 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
} }
} }
if (!StringUtil.isNullOrEmpty(mForwardUrl) && (mForwardMessageTypes.isEmpty() || mForwardMessageTypes.contains(message.getContent().getType())) && !(isAdmin && mNoForwardAdminMessage)) { if (!StringUtil.isNullOrEmpty(mForwardUrl) && (mForwardMessageTypes.isEmpty() || mForwardMessageTypes.contains(message.getContent().getType())) && !(isAdmin && mNoForwardAdminMessage) && !mForwardExcludeMessageTypes.contains(message.getContent().getType())) {
publisher.forwardMessage(message, mForwardUrl, outputClient); publisher.forwardMessage(message, mForwardUrl, outputClient);
} }
@@ -1712,6 +1712,35 @@ public class DatabaseStore {
return null; return null;
} }
Set<String> getCommonGroupIds(String userId1, String userId2) {
Connection connection = null;
PreparedStatement statement = null;
ResultSet rs = null;
try {
connection = DBUtil.getConnection();
String sql = "select t1._gid from t_group_member t1, t_group_member t2 where t1._mid = ? and t2._mid = ? and t1._type <> 4 and t2._type <> 4 and t1._gid = t2._gid";
statement = connection.prepareStatement(sql);
statement.setString(1, userId1);
statement.setString(2, userId2);
rs = statement.executeQuery();
Set<String> out = new HashSet<>();
while (rs.next()) {
String uid = rs.getString(1);
out.add(uid);
}
return out;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Utility.printExecption(LOG, e, RDBS_Exception);
} finally {
DBUtil.closeDB(connection, statement, rs);
}
return null;
}
void updateGroupMemberDt(final String groupId, final long dt) { void updateGroupMemberDt(final String groupId, final long dt) {
Connection connection = null; Connection connection = null;
PreparedStatement statement = null; PreparedStatement statement = null;
@@ -49,6 +49,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.Consumer; import java.util.function.Consumer;
@@ -121,6 +122,8 @@ public class MemoryMessagesStore implements IMessagesStore {
private Lock mReadLock = mLock.readLock(); private Lock mReadLock = mLock.readLock();
private Lock mWriteLock = mLock.writeLock(); private Lock mWriteLock = mLock.writeLock();
private Lock mUserSettingLock = new ReentrantLock();
private final DatabaseStore databaseStore; private final DatabaseStore databaseStore;
private ConcurrentHashMap<String, Long> userMaxPullSeq = new ConcurrentHashMap<>(); private ConcurrentHashMap<String, Long> userMaxPullSeq = new ConcurrentHashMap<>();
@@ -142,6 +145,10 @@ public class MemoryMessagesStore implements IMessagesStore {
private boolean mMultiPlatformNotification = false; private boolean mMultiPlatformNotification = false;
private boolean mMobileDefaultSilentWhenPCOnline = true; private boolean mMobileDefaultSilentWhenPCOnline = true;
private boolean mDisableStrangerChat = false; private boolean mDisableStrangerChat = false;
private Set<String> mAllowStrangerChatSet = new HashSet<>();
private Set<String> mClientSignatureSet = new HashSet<>();
private boolean mRejectEmptySignature = true;
private long mChatroomParticipantIdleTime = 900000; private long mChatroomParticipantIdleTime = 900000;
private boolean mChatroomRejoinWhenActive = true; private boolean mChatroomRejoinWhenActive = true;
@@ -187,6 +194,27 @@ public class MemoryMessagesStore implements IMessagesStore {
IS_CHATROOM_MESSAGE_REMOTE_HISTORY_MESSAGE = "1".equals(m_Server.getConfig().getProperty(MESSAGE_Remote_Chatroom_History_Message, "1")); IS_CHATROOM_MESSAGE_REMOTE_HISTORY_MESSAGE = "1".equals(m_Server.getConfig().getProperty(MESSAGE_Remote_Chatroom_History_Message, "1"));
Constants.MAX_MESSAGE_QUEUE = Integer.parseInt(m_Server.getConfig().getProperty(MESSAGE_Max_Queue)); Constants.MAX_MESSAGE_QUEUE = Integer.parseInt(m_Server.getConfig().getProperty(MESSAGE_Max_Queue));
try {
String signatureList = m_Server.getConfig().getProperty(BrokerConstants.CONNECT_CLIENT_SIGNATURE_LIST);
if(!StringUtil.isNullOrEmptyAfterTrim(signatureList)) {
signatureList = signatureList.replace(",", ",");
for (String s : signatureList.split(",")) {
mClientSignatureSet.add(s.trim());
}
}
} catch (Exception e) {
e.printStackTrace();
}
try {
if(!mClientSignatureSet.isEmpty()) {
mRejectEmptySignature = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.CONNECT_REJECT_EMPTY_SIGNATURE, "true"));
} else {
mRejectEmptySignature = false;
}
} catch (Exception e) {
}
try { try {
mDisableStrangerChat = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.MESSAGE_Disable_Stranger_Chat)); mDisableStrangerChat = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.MESSAGE_Disable_Stranger_Chat));
} catch (Exception e) { } catch (Exception e) {
@@ -195,6 +223,18 @@ public class MemoryMessagesStore implements IMessagesStore {
printMissConfigLog(MESSAGE_Disable_Stranger_Chat, mDisableStrangerChat + ""); printMissConfigLog(MESSAGE_Disable_Stranger_Chat, mDisableStrangerChat + "");
} }
try {
String allowStrangerList = m_Server.getConfig().getProperty(BrokerConstants.MESSAGE_Allow_Stranger_Chat_List);
if(!StringUtil.isNullOrEmptyAfterTrim(allowStrangerList)) {
allowStrangerList = allowStrangerList.replace(",", ",");
for (String s : allowStrangerList.split(",")) {
mAllowStrangerChatSet.add(s.trim());
}
}
} catch (Exception e) {
e.printStackTrace();
}
try { try {
mMultiPlatformNotification = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.SERVER_MULTI_PLATFROM_NOTIFICATION, "false")); mMultiPlatformNotification = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.SERVER_MULTI_PLATFROM_NOTIFICATION, "false"));
} catch (Exception e) { } catch (Exception e) {
@@ -1266,6 +1306,9 @@ public class MemoryMessagesStore implements IMessagesStore {
int maxCount = Integer.MAX_VALUE; int maxCount = Integer.MAX_VALUE;
if (!isAdmin) { if (!isAdmin) {
if (groupInfo.getType() == ProtoConstants.GroupType.GroupType_Organization) {
return ErrorCode.ERROR_CODE_NOT_RIGHT;
}
boolean isMember = false; boolean isMember = false;
boolean isManager = false; boolean isManager = false;
WFCMessage.GroupMember gm = getGroupMember(groupId, operator); WFCMessage.GroupMember gm = getGroupMember(groupId, operator);
@@ -1406,18 +1449,22 @@ public class MemoryMessagesStore implements IMessagesStore {
void removeFavGroup(String groupId, List<String> memberIds) { void removeFavGroup(String groupId, List<String> memberIds) {
HazelcastInstance hzInstance = m_Server.getHazelcastInstance(); HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
MultiMap<String, WFCMessage.UserSettingEntry> userSettingMap = hzInstance.getMultiMap(USER_SETTING);
databaseStore.removeFavGroup(groupId, memberIds); databaseStore.removeFavGroup(groupId, memberIds);
try {
for (String member : memberIds) { mUserSettingLock.lock();
userSettingMap.remove(member); MultiMap<String, WFCMessage.UserSettingEntry> userSettingMap = hzInstance.getMultiMap(USER_SETTING);
for (String member : memberIds) {
userSettingMap.remove(member);
}
} finally {
mUserSettingLock.unlock();
} }
} }
@Override @Override
public ErrorCode quitGroup(String operator, String groupId) { public ErrorCode quitGroup(String operator, String groupId, boolean admin) {
HazelcastInstance hzInstance = m_Server.getHazelcastInstance(); HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
IMap<String, WFCMessage.GroupInfo> mIMap = hzInstance.getMap(GROUPS_MAP); IMap<String, WFCMessage.GroupInfo> mIMap = hzInstance.getMap(GROUPS_MAP);
@@ -1437,6 +1484,10 @@ public class MemoryMessagesStore implements IMessagesStore {
return ErrorCode.ERROR_CODE_NOT_EXIST; return ErrorCode.ERROR_CODE_NOT_EXIST;
} }
if(!admin && groupInfo.getType() == ProtoConstants.GroupType.GroupType_Organization) {
return ErrorCode.ERROR_CODE_NOT_RIGHT;
}
if (groupInfo.getType() != ProtoConstants.GroupType.GroupType_Free && groupInfo.getOwner() != null && groupInfo.getOwner().equals(operator)) { if (groupInfo.getType() != ProtoConstants.GroupType.GroupType_Free && groupInfo.getOwner() != null && groupInfo.getOwner().equals(operator)) {
MultiMap<String, WFCMessage.GroupMember> groupMembers = hzInstance.getMultiMap(GROUP_MEMBERS); MultiMap<String, WFCMessage.GroupMember> groupMembers = hzInstance.getMultiMap(GROUP_MEMBERS);
Collection<WFCMessage.GroupMember> members = groupMembers.get(groupId); Collection<WFCMessage.GroupMember> members = groupMembers.get(groupId);
@@ -1479,7 +1530,7 @@ public class MemoryMessagesStore implements IMessagesStore {
int[] removedCount = new int[1]; int[] removedCount = new int[1];
for (String groupId : groupIds) { for (String groupId : groupIds) {
removedCount[0] = 0; removedCount[0] = 0;
ErrorCode errorCode = quitGroup(userId, groupId); ErrorCode errorCode = quitGroup(userId, groupId, true);
LOG.info("clear user {} group {} result {}", userId, groupId, errorCode); LOG.info("clear user {} group {} result {}", userId, groupId, errorCode);
} }
} }
@@ -1487,13 +1538,17 @@ public class MemoryMessagesStore implements IMessagesStore {
private void removeGroupUserSettings(String groupId, List<String> users) { private void removeGroupUserSettings(String groupId, List<String> users) {
HazelcastInstance hzInstance = m_Server.getHazelcastInstance(); HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
MultiMap<String, WFCMessage.UserSettingEntry> userSettingMap = hzInstance.getMultiMap(USER_SETTING);
databaseStore.removeGroupUserSettings(groupId, users); databaseStore.removeGroupUserSettings(groupId, users);
for (String userId:users) { try {
userSettingMap.remove(userId); mUserSettingLock.lock();
MultiMap<String, WFCMessage.UserSettingEntry> userSettingMap = hzInstance.getMultiMap(USER_SETTING);
for (String userId:users) {
userSettingMap.remove(userId);
}
} finally {
mUserSettingLock.unlock();
} }
} }
@Override @Override
@@ -1511,6 +1566,7 @@ public class MemoryMessagesStore implements IMessagesStore {
} }
if (!isAdmin && (groupInfo.getType() == ProtoConstants.GroupType.GroupType_Free || if (!isAdmin && (groupInfo.getType() == ProtoConstants.GroupType.GroupType_Free ||
groupInfo.getType() == ProtoConstants.GroupType.GroupType_Organization ||
(groupInfo.getType() == ProtoConstants.GroupType.GroupType_Restricted || groupInfo.getType() == ProtoConstants.GroupType.GroupType_Normal) (groupInfo.getType() == ProtoConstants.GroupType.GroupType_Restricted || groupInfo.getType() == ProtoConstants.GroupType.GroupType_Normal)
&& (groupInfo.getOwner() == null || !groupInfo.getOwner().equals(operator)))) { && (groupInfo.getOwner() == null || !groupInfo.getOwner().equals(operator)))) {
return ErrorCode.ERROR_CODE_NOT_RIGHT; return ErrorCode.ERROR_CODE_NOT_RIGHT;
@@ -1554,7 +1610,11 @@ public class MemoryMessagesStore implements IMessagesStore {
} }
if (!isAdmin) { if (!isAdmin) {
if (oldInfo.getType() == ProtoConstants.GroupType.GroupType_Restricted) { if (oldInfo.getType() == ProtoConstants.GroupType.GroupType_Organization && modifyType != Modify_Group_Extra && modifyType != Modify_Group_Mute && modifyType != Modify_Group_PrivateChat) {
return ErrorCode.ERROR_CODE_NOT_RIGHT;
}
if (oldInfo.getType() == ProtoConstants.GroupType.GroupType_Restricted || oldInfo.getType() == ProtoConstants.GroupType.GroupType_Organization) {
boolean isAllow = false; boolean isAllow = false;
if ((oldInfo.getOwner() != null && oldInfo.getOwner().equals(operator))) { if ((oldInfo.getOwner() != null && oldInfo.getOwner().equals(operator))) {
isAllow = true; isAllow = true;
@@ -1831,6 +1891,11 @@ public class MemoryMessagesStore implements IMessagesStore {
return databaseStore.getUserGroupIds(userId); return databaseStore.getUserGroupIds(userId);
} }
@Override
public Set<String> getCommonGroupIds(String userId1, String userId2) {
return databaseStore.getCommonGroupIds(userId1, userId2);
}
@Override @Override
public ErrorCode getGroupMembers(String fromUser, String groupId, long maxDt, List<WFCMessage.GroupMember> members) { public ErrorCode getGroupMembers(String fromUser, String groupId, long maxDt, List<WFCMessage.GroupMember> members) {
HazelcastInstance hzInstance = m_Server.getHazelcastInstance(); HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
@@ -1915,6 +1980,10 @@ public class MemoryMessagesStore implements IMessagesStore {
return ErrorCode.ERROR_CODE_NOT_RIGHT; return ErrorCode.ERROR_CODE_NOT_RIGHT;
} }
if (!isAdmin && groupInfo.getType() == ProtoConstants.GroupType.GroupType_Organization) {
return ErrorCode.ERROR_CODE_NOT_RIGHT;
}
//check the new owner is in member list? is that necessary? //check the new owner is in member list? is that necessary?
long updateDt = System.currentTimeMillis(); long updateDt = System.currentTimeMillis();
groupInfo = groupInfo.toBuilder().setOwner(newOwner).setUpdateDt(updateDt).setMemberUpdateDt(updateDt).build(); groupInfo = groupInfo.toBuilder().setOwner(newOwner).setUpdateDt(updateDt).setMemberUpdateDt(updateDt).build();
@@ -2779,6 +2848,11 @@ public class MemoryMessagesStore implements IMessagesStore {
if (mDisableStrangerChat) { if (mDisableStrangerChat) {
//在禁止私聊时,是否是允许私聊的用户id
if(mAllowStrangerChatSet.contains(targetUser)) {
return ErrorCode.ERROR_CODE_SUCCESS;
}
//在禁止私聊时,允许机器人,物联网设备及管理员进行私聊。 //在禁止私聊时,允许机器人,物联网设备及管理员进行私聊。
IMap<String, WFCMessage.User> mUserMap = hzInstance.getMap(USERS); IMap<String, WFCMessage.User> mUserMap = hzInstance.getMap(USERS);
WFCMessage.User target = mUserMap.get(targetUser); WFCMessage.User target = mUserMap.get(targetUser);
@@ -3548,9 +3622,15 @@ public class MemoryMessagesStore implements IMessagesStore {
IMap<String, WFCMessage.GroupInfo> mGroups = hzInstance.getMap(GROUPS_MAP); IMap<String, WFCMessage.GroupInfo> mGroups = hzInstance.getMap(GROUPS_MAP);
IMap<String, WFCMessage.ChannelInfo> mChannels = hzInstance.getMap(CHANNELS); IMap<String, WFCMessage.ChannelInfo> mChannels = hzInstance.getMap(CHANNELS);
Collection<WFCMessage.UserSettingEntry> entries = userSettingMap.get(userId); Collection<WFCMessage.UserSettingEntry> entries;
if (entries == null || entries.size() == 0) { try {
entries = loadPersistedUserSettings(userId, userSettingMap); mUserSettingLock.lock();
entries = userSettingMap.get(userId);
if (entries == null || entries.size() == 0) {
entries = loadPersistedUserSettings(userId, userSettingMap);
}
} finally {
mUserSettingLock.unlock();
} }
ErrorCode ec = ErrorCode.ERROR_CODE_NOT_MODIFIED; ErrorCode ec = ErrorCode.ERROR_CODE_NOT_MODIFIED;
@@ -3629,17 +3709,22 @@ public class MemoryMessagesStore implements IMessagesStore {
HazelcastInstance hzInstance = m_Server.getHazelcastInstance(); HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
MultiMap<String, WFCMessage.UserSettingEntry> userSettingMap = hzInstance.getMultiMap(USER_SETTING); MultiMap<String, WFCMessage.UserSettingEntry> userSettingMap = hzInstance.getMultiMap(USER_SETTING);
Collection<WFCMessage.UserSettingEntry> entries = userSettingMap.get(userId); try {
if (entries == null || entries.size() == 0) { mUserSettingLock.lock();
entries = loadPersistedUserSettings(userId, userSettingMap); Collection<WFCMessage.UserSettingEntry> entries = userSettingMap.get(userId);
} if (entries == null || entries.size() == 0) {
entries = loadPersistedUserSettings(userId, userSettingMap);
}
if (entries != null) { if (entries != null) {
for (WFCMessage.UserSettingEntry entry : entries) { for (WFCMessage.UserSettingEntry entry : entries) {
if (entry.getScope() == scope && (key== null || key.equals(entry.getKey()))) { if (entry.getScope() == scope && (key== null || key.equals(entry.getKey()))) {
return entry; return entry;
}
} }
} }
} finally {
mUserSettingLock.unlock();
} }
return null; return null;
@@ -3650,19 +3735,25 @@ public class MemoryMessagesStore implements IMessagesStore {
HazelcastInstance hzInstance = m_Server.getHazelcastInstance(); HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
MultiMap<String, WFCMessage.UserSettingEntry> userSettingMap = hzInstance.getMultiMap(USER_SETTING); MultiMap<String, WFCMessage.UserSettingEntry> userSettingMap = hzInstance.getMultiMap(USER_SETTING);
Collection<WFCMessage.UserSettingEntry> entries = userSettingMap.get(userId); List<WFCMessage.UserSettingEntry> result;
if (entries == null || entries.size() == 0) { try {
entries = loadPersistedUserSettings(userId, userSettingMap); mUserSettingLock.lock();
} Collection<WFCMessage.UserSettingEntry> entries = userSettingMap.get(userId);
if (entries == null || entries.size() == 0) {
entries = loadPersistedUserSettings(userId, userSettingMap);
}
List<WFCMessage.UserSettingEntry> result = new ArrayList<>(); result = new ArrayList<>();
if (entries != null) { if (entries != null) {
for (WFCMessage.UserSettingEntry entry : entries for (WFCMessage.UserSettingEntry entry : entries
) { ) {
if (entry.getScope() == scope) { if (entry.getScope() == scope) {
result.add(entry); result.add(entry);
}
} }
} }
} finally {
mUserSettingLock.unlock();
} }
return result; return result;
@@ -3673,28 +3764,34 @@ public class MemoryMessagesStore implements IMessagesStore {
HazelcastInstance hzInstance = m_Server.getHazelcastInstance(); HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
MultiMap<String, WFCMessage.UserSettingEntry> userSettingMap = hzInstance.getMultiMap(USER_SETTING); MultiMap<String, WFCMessage.UserSettingEntry> userSettingMap = hzInstance.getMultiMap(USER_SETTING);
Collection<WFCMessage.UserSettingEntry> entries = userSettingMap.get(userId); long updateDt = 0;
if (entries == null || entries.size() == 0) { try {
entries = loadPersistedUserSettings(userId, userSettingMap); mUserSettingLock.lock();
if (entries == null) { Collection<WFCMessage.UserSettingEntry> entries = userSettingMap.get(userId);
entries = new ArrayList<>(); if (entries == null || entries.size() == 0) {
entries = loadPersistedUserSettings(userId, userSettingMap);
if (entries == null) {
entries = new ArrayList<>();
}
} }
}
long updateDt = System.currentTimeMillis(); updateDt = System.currentTimeMillis();
WFCMessage.UserSettingEntry settingEntry = WFCMessage.UserSettingEntry.newBuilder().setScope(request.getScope()).setKey(request.getKey()).setValue(request.getValue()).setUpdateDt(updateDt).build(); WFCMessage.UserSettingEntry settingEntry = WFCMessage.UserSettingEntry.newBuilder().setScope(request.getScope()).setKey(request.getKey()).setValue(request.getValue()).setUpdateDt(updateDt).build();
databaseStore.persistUserSetting(userId, settingEntry); databaseStore.persistUserSetting(userId, settingEntry);
for (WFCMessage.UserSettingEntry entry : entries for (WFCMessage.UserSettingEntry entry : entries
) { ) {
if (entry.getScope() == request.getScope() && entry.getKey().equals(request.getKey())) { if (entry.getScope() == request.getScope() && entry.getKey().equals(request.getKey())) {
userSettingMap.remove(userId, entry); userSettingMap.remove(userId, entry);
userSettingMap.put(userId, settingEntry); userSettingMap.put(userId, settingEntry);
break; break;
}
} }
}
userSettingMap.put(userId, settingEntry); userSettingMap.put(userId, settingEntry);
} finally {
mUserSettingLock.unlock();
}
if(request.getScope() == UserSettingScope.kUserSettingConversationSilent) { if(request.getScope() == UserSettingScope.kUserSettingConversationSilent) {
int firstSplit = request.getKey().indexOf("-"); int firstSplit = request.getKey().indexOf("-");
@@ -3719,8 +3816,14 @@ public class MemoryMessagesStore implements IMessagesStore {
public void clearUserSettings(String userId) { public void clearUserSettings(String userId) {
databaseStore.clearUserSetting(userId); databaseStore.clearUserSetting(userId);
HazelcastInstance hzInstance = m_Server.getHazelcastInstance(); HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
MultiMap<String, WFCMessage.UserSettingEntry> userSettingMap = hzInstance.getMultiMap(USER_SETTING);
userSettingMap.remove(userId); try {
mUserSettingLock.lock();
MultiMap<String, WFCMessage.UserSettingEntry> userSettingMap = hzInstance.getMultiMap(USER_SETTING);
userSettingMap.remove(userId);
} finally {
mUserSettingLock.unlock();
}
} }
@Override @Override
@@ -4251,6 +4354,34 @@ public class MemoryMessagesStore implements IMessagesStore {
return UUIDGenerator.getUUID(); return UUIDGenerator.getUUID();
} }
@Override
public boolean checkSignature(String signature) {
if(mClientSignatureSet.isEmpty()) {
return true;
}
if(StringUtil.isNullOrEmptyAfterTrim(signature)) {
if(mRejectEmptySignature) {
LOG.info("Failed check signature, no signature");
return false;
} else {
return true;
}
} else {
if(mClientSignatureSet.contains(signature)) {
return true;
} else {
LOG.info("Failed check signature, signature no matched");
return false;
}
}
}
@Override
public boolean existSignatures() {
return !mClientSignatureSet.isEmpty();
}
@Override @Override
public void storeRetained(Topic topic, StoredMessage storedMessage) { public void storeRetained(Topic topic, StoredMessage storedMessage) {
LOG.debug("Store retained message for topic={}, CId={}", topic, storedMessage.getClientID()); LOG.debug("Store retained message for topic={}, CId={}", topic, storedMessage.getClientID());
@@ -110,7 +110,7 @@ public interface IMessagesStore {
WFCMessage.GroupInfo createGroup(String operator, WFCMessage.GroupInfo groupInfo, List<WFCMessage.GroupMember> memberList, String memberExtra, boolean isAdmin); WFCMessage.GroupInfo createGroup(String operator, WFCMessage.GroupInfo groupInfo, List<WFCMessage.GroupMember> memberList, String memberExtra, boolean isAdmin);
ErrorCode addGroupMembers(String operator, boolean isAdmin, String groupId, List<WFCMessage.GroupMember> memberList, String extra); ErrorCode addGroupMembers(String operator, boolean isAdmin, String groupId, List<WFCMessage.GroupMember> memberList, String extra);
ErrorCode kickoffGroupMembers(String operator, boolean isAdmin, String groupId, List<String> memberList); ErrorCode kickoffGroupMembers(String operator, boolean isAdmin, String groupId, List<String> memberList);
ErrorCode quitGroup(String operator, String groupId); ErrorCode quitGroup(String operator, String groupId, boolean admin);
void clearUserGroups(String userId); void clearUserGroups(String userId);
ErrorCode dismissGroup(String operator, String groupId, boolean isAdmin); ErrorCode dismissGroup(String operator, String groupId, boolean isAdmin);
ErrorCode modifyGroupInfo(String operator, String groupId, int modifyType, String value, boolean isAdmin); ErrorCode modifyGroupInfo(String operator, String groupId, int modifyType, String value, boolean isAdmin);
@@ -119,6 +119,7 @@ public interface IMessagesStore {
List<WFCMessage.GroupInfo> getGroupInfos(List<WFCMessage.UserRequest> requests); List<WFCMessage.GroupInfo> getGroupInfos(List<WFCMessage.UserRequest> requests);
WFCMessage.GroupInfo getGroupInfo(String groupId); WFCMessage.GroupInfo getGroupInfo(String groupId);
Set<String> getUserGroupIds(String userId); Set<String> getUserGroupIds(String userId);
Set<String> getCommonGroupIds(String userId1, String userId2);
ErrorCode getGroupMembers(String fromUser, String groupId, long maxDt, List<WFCMessage.GroupMember> members); ErrorCode getGroupMembers(String fromUser, String groupId, long maxDt, List<WFCMessage.GroupMember> members);
WFCMessage.GroupMember getGroupMember(String groupId, String memberId); WFCMessage.GroupMember getGroupMember(String groupId, String memberId);
ErrorCode transferGroup(String operator, String groupId, String newOwner, boolean isAdmin); ErrorCode transferGroup(String operator, String groupId, String newOwner, boolean isAdmin);
@@ -248,6 +249,9 @@ public interface IMessagesStore {
//使用了数据库,会比较慢,仅能用户用户/群组等id的生成 //使用了数据库,会比较慢,仅能用户用户/群组等id的生成
String getShortUUID(); String getShortUUID();
boolean checkSignature(String signature);
boolean existSignatures();
/** /**
* Used to initialize all persistent store structures * Used to initialize all persistent store structures
*/ */
@@ -48,6 +48,7 @@ import win.liyufan.im.HttpUtils;
import win.liyufan.im.IMTopic; import win.liyufan.im.IMTopic;
import win.liyufan.im.Utility; import win.liyufan.im.Utility;
import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@@ -339,6 +340,24 @@ public class ProtocolProcessor {
failedCredentials(channel); failedCredentials(channel);
return false; return false;
} }
if(session.getPlatform() == ProtoConstants.Platform.Platform_Android || session.getPlatform() == ProtoConstants.Platform.Platform_APad) {
byte[] signature = msg.payload().signatureInBytes();
String basedSign = null;
if (signature != null && signature.length > 0) {
signature = AES.AESDecrypt(signature, session.getSecret(), true);
}
if (signature != null && signature.length > 0) {
basedSign = Base64.getEncoder().encodeToString(signature);
}
if (!m_messagesStore.checkSignature(basedSign)) {
LOG.error("Bad signature of session <{}, {}>", session.getUsername(), session.getClientID());
failedBadSignature(channel);
return false;
}
}
session.setMqttVersion(mqttVersion); session.setMqttVersion(mqttVersion);
} else { } else {
LOG.error("Client didn't supply any password and MQTT anonymous mode is disabled CId={}", clientId); LOG.error("Client didn't supply any password and MQTT anonymous mode is disabled CId={}", clientId);
@@ -446,6 +465,11 @@ public class ProtocolProcessor {
LOG.info("Client {} failed to connect with bad username or password.", session); LOG.info("Client {} failed to connect with bad username or password.", session);
} }
private void failedBadSignature(Channel session) {
session.writeAndFlush(connAck(CONNECTION_REFUSED_SIGNATURE_FAILURE));
LOG.info("Client {} failed to connect with bad signature.", session);
}
private void setIdleTime(ChannelPipeline pipeline, int idleTime) { private void setIdleTime(ChannelPipeline pipeline, int idleTime) {
if (pipeline.names().contains("idleStateHandler")) { if (pipeline.names().contains("idleStateHandler")) {
pipeline.remove("idleStateHandler"); pipeline.remove("idleStateHandler");
@@ -32,6 +32,7 @@ public final class MqttConnectPayload {
private final byte[] willMessage; private final byte[] willMessage;
private final String userName; private final String userName;
private final byte[] password; private final byte[] password;
private final byte[] signature;
/** /**
* @deprecated use {@link MqttConnectPayload#MqttConnectPayload(String, * @deprecated use {@link MqttConnectPayload#MqttConnectPayload(String,
@@ -50,7 +51,7 @@ public final class MqttConnectPayload {
willTopic, willTopic,
willMessage.getBytes(CharsetUtil.UTF_8), willMessage.getBytes(CharsetUtil.UTF_8),
userName, userName,
password.getBytes(CharsetUtil.UTF_8)); password.getBytes(CharsetUtil.UTF_8), null);
} }
public MqttConnectPayload( public MqttConnectPayload(
@@ -64,7 +65,7 @@ public final class MqttConnectPayload {
willTopic, willTopic,
willMessage, willMessage,
userName, userName,
password); password, null);
} }
public MqttConnectPayload( public MqttConnectPayload(
@@ -73,13 +74,15 @@ public final class MqttConnectPayload {
String willTopic, String willTopic,
byte[] willMessage, byte[] willMessage,
String userName, String userName,
byte[] password) { byte[] password,
byte[] signature) {
this.clientIdentifier = clientIdentifier; this.clientIdentifier = clientIdentifier;
this.willProperties = MqttProperties.withEmptyDefaults(willProperties); this.willProperties = MqttProperties.withEmptyDefaults(willProperties);
this.willTopic = willTopic; this.willTopic = willTopic;
this.willMessage = willMessage; this.willMessage = willMessage;
this.userName = userName; this.userName = userName;
this.password = password; this.password = password;
this.signature = signature;
} }
public String clientIdentifier() { public String clientIdentifier() {
@@ -122,6 +125,10 @@ public final class MqttConnectPayload {
return password; return password;
} }
public byte[] signatureInBytes() {
return signature;
}
@Override @Override
public String toString() { public String toString() {
return new StringBuilder(StringUtil.simpleClassName(this)) return new StringBuilder(StringUtil.simpleClassName(this))
@@ -29,6 +29,7 @@ public enum MqttConnectReturnCode {
CONNECTION_REFUSED_NOT_AUTHORIZED((byte) 0x05), CONNECTION_REFUSED_NOT_AUTHORIZED((byte) 0x05),
CONNECTION_REFUSED_UNEXPECT_NODE((byte) 0X06), CONNECTION_REFUSED_UNEXPECT_NODE((byte) 0X06),
CONNECTION_REFUSED_SESSION_NOT_EXIST((byte) 0x07), CONNECTION_REFUSED_SESSION_NOT_EXIST((byte) 0x07),
CONNECTION_REFUSED_SIGNATURE_FAILURE((byte) 0x08),
//MQTT 5 codes //MQTT 5 codes
CONNECTION_REFUSED_UNSPECIFIED_ERROR((byte) 0x80), CONNECTION_REFUSED_UNSPECIFIED_ERROR((byte) 0x80),
CONNECTION_REFUSED_MALFORMED_PACKET((byte) 0x81), CONNECTION_REFUSED_MALFORMED_PACKET((byte) 0x81),
@@ -146,7 +146,7 @@ public final class MqttDecoder extends ReplayingDecoder<MqttDecoder.DecoderState
* bytes for the remaining length. * bytes for the remaining length.
* *
* @see * @see
* https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/errata01/os/mqtt-v3.1.1-errata01-os-complete.html#_Toc442180841 * <a href="https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/errata01/os/mqtt-v3.1.1-errata01-os-complete.html#_Toc442180841">...</a>
* *
* @param buffer the buffer to decode from * @param buffer the buffer to decode from
* @return the fixed header * @return the fixed header
@@ -534,7 +534,7 @@ public final class MqttDecoder extends ReplayingDecoder<MqttDecoder.DecoderState
final MqttProperties willProperties; final MqttProperties willProperties;
if (mqttConnectVariableHeader.isWillFlag()) { if (mqttConnectVariableHeader.isWillFlag()) {
if (mqttVersion == MqttVersion.MQTT_5) { if (mqttVersion.protocolLevel() <= MqttVersion.MQTT_5.protocolLevel()) {
final Result<MqttProperties> propertiesResult = decodeProperties(buffer); final Result<MqttProperties> propertiesResult = decodeProperties(buffer);
willProperties = propertiesResult.value; willProperties = propertiesResult.value;
numberOfBytesConsumed += propertiesResult.numberOfBytesConsumed; numberOfBytesConsumed += propertiesResult.numberOfBytesConsumed;
@@ -550,6 +550,7 @@ public final class MqttDecoder extends ReplayingDecoder<MqttDecoder.DecoderState
} }
Result<String> decodedUserName = null; Result<String> decodedUserName = null;
byte[] decodedPassword = null; byte[] decodedPassword = null;
byte[] decodedSignature = null;
if (mqttConnectVariableHeader.hasUserName()) { if (mqttConnectVariableHeader.hasUserName()) {
decodedUserName = decodeString(buffer); decodedUserName = decodeString(buffer);
numberOfBytesConsumed += decodedUserName.numberOfBytesConsumed; numberOfBytesConsumed += decodedUserName.numberOfBytesConsumed;
@@ -558,6 +559,10 @@ public final class MqttDecoder extends ReplayingDecoder<MqttDecoder.DecoderState
decodedPassword = decodeByteArray(buffer); decodedPassword = decodeByteArray(buffer);
numberOfBytesConsumed += decodedPassword.length + 2; numberOfBytesConsumed += decodedPassword.length + 2;
} }
if (mqttConnectVariableHeader.isWillRetain()) {
decodedSignature = decodeByteArray(buffer);
numberOfBytesConsumed += decodedSignature.length + 2;
}
final MqttConnectPayload mqttConnectPayload = final MqttConnectPayload mqttConnectPayload =
new MqttConnectPayload( new MqttConnectPayload(
@@ -566,7 +571,9 @@ public final class MqttDecoder extends ReplayingDecoder<MqttDecoder.DecoderState
decodedWillTopic != null ? decodedWillTopic.value : null, decodedWillTopic != null ? decodedWillTopic.value : null,
decodedWillMessage, decodedWillMessage,
decodedUserName != null ? decodedUserName.value : null, decodedUserName != null ? decodedUserName.value : null,
decodedPassword); decodedPassword,
decodedSignature
);
return new Result<MqttConnectPayload>(mqttConnectPayload, numberOfBytesConsumed); return new Result<MqttConnectPayload>(mqttConnectPayload, numberOfBytesConsumed);
} }
@@ -208,7 +208,7 @@ public final class MqttMessageBuilders {
keepAliveSecs, keepAliveSecs,
properties); properties);
MqttConnectPayload mqttConnectPayload = MqttConnectPayload mqttConnectPayload =
new MqttConnectPayload(clientId, willProperties, willTopic, willMessage, username, password); new MqttConnectPayload(clientId, willProperties, willTopic, willMessage, username, password, null);
return new MqttConnectMessage(mqttFixedHeader, mqttConnectVariableHeader, mqttConnectPayload); return new MqttConnectMessage(mqttFixedHeader, mqttConnectVariableHeader, mqttConnectPayload);
} }
} }
@@ -88,7 +88,7 @@ public class HttpUtils {
System.out.println(logText); System.out.println(logText);
e.printStackTrace(); e.printStackTrace();
LOG.error(logText); LOG.error(logText);
LOG.error("POST to {} with data {} failure", url, jsonStr); LOG.error("POST to {} failed", url);
if(httpCallback != null) { if(httpCallback != null) {
httpCallback.onFailure(-1, e.getMessage()); httpCallback.onFailure(-1, e.getMessage());
} }
@@ -37,6 +37,8 @@ public interface IMTopic {
String GetGroupMemberTopic = "GPGM"; String GetGroupMemberTopic = "GPGM";
String TransferGroupTopic = "GTG"; String TransferGroupTopic = "GTG";
String SetGroupManagerTopic = "GSM"; String SetGroupManagerTopic = "GSM";
String GetMyGroupsTopic = "GMGS";
String GetCommonGroupsTopic = "GCGS";
String GetUserInfoTopic = "UPUI"; String GetUserInfoTopic = "UPUI";
String ModifyMyInfoTopic = "MMI"; String ModifyMyInfoTopic = "MMI";
+1 -1
View File
@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>wildfirechat-parent</artifactId> <artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId> <groupId>cn.wildfirechat</groupId>
<version>0.97</version> <version>0.99</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@@ -77,6 +77,7 @@ public interface APIPath {
String Get_User_Groups = "/admin/group/of_user"; String Get_User_Groups = "/admin/group/of_user";
String Group_Set_Member_Alias = "/admin/group/member/set_alias"; String Group_Set_Member_Alias = "/admin/group/member/set_alias";
String Group_Set_Member_Extra = "/admin/group/member/set_extra"; String Group_Set_Member_Extra = "/admin/group/member/set_extra";
String Get_Common_Groups = "/admin/group/common_group";
String Create_Channel = "/admin/channel/create"; String Create_Channel = "/admin/channel/create";
String Destroy_Channel = "/admin/channel/destroy"; String Destroy_Channel = "/admin/channel/destroy";
@@ -19,6 +19,8 @@ public class ProtoConstants {
int GroupType_Free = 1; int GroupType_Free = 1;
//member can only quit, owner can do all the operations //member can only quit, owner can do all the operations
int GroupType_Restricted = 2; int GroupType_Restricted = 2;
//member can not do anything, server api manage the group
int GroupType_Organization = 3;
} }
//message GroupMember -> type //message GroupMember -> type
+64 -67
View File
@@ -6,7 +6,7 @@
<!--<relativePath>../pom.xml</relativePath>--> <!--<relativePath>../pom.xml</relativePath>-->
<artifactId>wildfirechat-parent</artifactId> <artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId> <groupId>cn.wildfirechat</groupId>
<version>0.97</version> <version>0.99</version>
</parent> </parent>
<artifactId>distribution</artifactId> <artifactId>distribution</artifactId>
@@ -130,73 +130,70 @@
</executions> </executions>
</plugin> </plugin>
<!-- 打包RPM 开始-->
<!-- 打包RPM 包需要本地有rpm命令才可以,linux和mac都可以安装rpm。如果是windows需要cygwin安装rpm才可以,如果不需要rpm包,可以把这个plugin注释掉--> <!-- 打包RPM 包需要本地有rpm命令才可以,linux和mac都可以安装rpm。如果是windows需要cygwin安装rpm才可以,如果不需要rpm包,可以把这个plugin注释掉-->
<plugin> <!-- 打包RPM插件,如果需要打包RPM格式请打开下面注释 -->
<groupId>org.codehaus.mojo</groupId> <!-- <plugin>-->
<artifactId>rpm-maven-plugin</artifactId> <!-- <groupId>org.codehaus.mojo</groupId>-->
<version>2.2.0</version> <!-- <artifactId>rpm-maven-plugin</artifactId>-->
<executions> <!-- <version>2.2.0</version>-->
<execution> <!-- <executions>-->
<id>generate-rpm</id> <!-- <execution>-->
<goals> <!-- <id>generate-rpm</id>-->
<goal>rpm</goal> <!-- <goals>-->
</goals> <!-- <goal>rpm</goal>-->
</execution> <!-- </goals>-->
</executions> <!-- </execution>-->
<!-- </executions>-->
<configuration> <!-- <configuration>-->
<group>Applications/Chat</group> <!-- <group>Applications/Chat</group>-->
<name>im-server</name> <!-- <name>im-server</name>-->
<needarch>noarch</needarch> <!-- <needarch>noarch</needarch>-->
<targetOS>linux</targetOS> <!-- <targetOS>linux</targetOS>-->
<prefix>/opt/im-server</prefix> <!-- <prefix>/opt/im-server</prefix>-->
<defineStatements> <!-- <defineStatements>-->
<defineStatement>_unpackaged_files_terminate_build 0</defineStatement> <!-- <defineStatement>_unpackaged_files_terminate_build 0</defineStatement>-->
</defineStatements> <!-- </defineStatements>-->
<copyTo> <!-- <copyTo>-->
target/im-server-${project.version}.rpm <!-- target/im-server-${project.version}.rpm-->
</copyTo> <!-- </copyTo>-->
<requires> <!-- <requires>-->
<require>java-1.8.0-openjdk-headless</require> <!-- <require>java-1.8.0-openjdk-headless</require>-->
</requires> <!-- </requires>-->
<!-- <mappings>-->
<mappings> <!-- <mapping>-->
<mapping> <!-- <directory>/opt/im-server</directory>-->
<directory>/opt/im-server</directory> <!-- <filemode>755</filemode>-->
<filemode>755</filemode> <!-- <sources>-->
<sources> <!-- <source>-->
<source> <!-- <location>${project.build.directory}/distribution-${project.version}-bundle-tar.tar.gz</location>-->
<location>${project.build.directory}/distribution-${project.version}-bundle-tar.tar.gz</location> <!-- </source>-->
</source> <!-- </sources>-->
</sources> <!-- </mapping>-->
</mapping> <!-- <mapping>-->
<!-- <directory>/usr/lib/systemd/system</directory>-->
<mapping> <!-- <filemode>644</filemode>-->
<directory>/usr/lib/systemd/system</directory> <!-- <username>root</username>-->
<filemode>644</filemode> <!-- <groupname>root</groupname>-->
<username>root</username> <!-- <directoryIncluded>false</directoryIncluded>-->
<groupname>root</groupname> <!-- <sources>-->
<directoryIncluded>false</directoryIncluded> <!-- <source>-->
<sources> <!-- <location>${project.basedir}/../systemd/im-server.service</location>-->
<source> <!-- </source>-->
<location>${project.basedir}/../systemd/im-server.service</location> <!-- </sources>-->
</source> <!-- </mapping>-->
</sources> <!-- </mappings>-->
</mapping> <!-- <postinstallScriptlet>-->
</mappings> <!-- <scriptFile>${project.basedir}/src/main/rpm/install.sh</scriptFile>-->
<postinstallScriptlet> <!-- <fileEncoding>utf-8</fileEncoding>-->
<scriptFile>${project.basedir}/src/main/rpm/install.sh</scriptFile> <!-- <filter>true</filter>-->
<fileEncoding>utf-8</fileEncoding> <!-- </postinstallScriptlet>-->
<filter>true</filter> <!-- <postremoveScriptlet>-->
</postinstallScriptlet> <!-- <scriptFile>${project.basedir}/src/main/rpm/uninstall.sh</scriptFile>-->
<postremoveScriptlet> <!-- <fileEncoding>utf-8</fileEncoding>-->
<scriptFile>${project.basedir}/src/main/rpm/uninstall.sh</scriptFile> <!-- <filter>true</filter>-->
<fileEncoding>utf-8</fileEncoding> <!-- </postremoveScriptlet>-->
<filter>true</filter> <!-- </configuration>-->
</postremoveScriptlet> <!-- </plugin>-->
</configuration>
</plugin>
<!-- 打包RPM 结束--> <!-- 打包RPM 结束-->
</plugins> </plugins>
+21 -2
View File
@@ -29,6 +29,11 @@
<directory>../systemd/</directory> <directory>../systemd/</directory>
<outputDirectory>/systemd</outputDirectory> <outputDirectory>/systemd</outputDirectory>
</fileSet> </fileSet>
<fileSet>
<directory>src/main/checker/</directory>
<outputDirectory>checker/</outputDirectory>
</fileSet>
</fileSets> </fileSets>
<files> <files>
@@ -49,7 +54,7 @@
</file> </file>
<file> <file>
<source>src/main/files/release_note.md</source> <source>../release_note.md</source>
</file> </file>
<file> <file>
@@ -75,8 +80,22 @@
<outputDirectory>server_sdk/</outputDirectory> <outputDirectory>server_sdk/</outputDirectory>
<destName>common-${project.version}.jar</destName> <destName>common-${project.version}.jar</destName>
</file> </file>
</files>
<file>
<source>../sdk/target/checker.jar</source>
<outputDirectory>checker/</outputDirectory>
</file>
<file>
<source>../docker/Dockerfile</source>
<outputDirectory>docker/</outputDirectory>
</file>
<file>
<source>../docker/README.md</source>
<outputDirectory>docker/</outputDirectory>
</file>
</files>
<dependencySets> <dependencySets>
<dependencySet> <dependencySet>
+5
View File
@@ -0,0 +1,5 @@
部署IM服务后,可以使用Server SDK通过API来检查服务的部署情况,可以执行:
```shell
java -jar checker.jar http://127.0.0.1:18080 123456 http://127.0.0.1 true false
```
来检查。检查之后会产生垃圾数据,请在检查之后停掉IM服务后,再删除掉IM服务数据库。此检查仅检查API,检查通过并不代表部署肯定成功,还需要客户端来验证。
@@ -8,8 +8,13 @@ if [ ! -d /etc/im-server ]; then
mkdir /etc/im-server mkdir /etc/im-server
fi fi
if [ ! -d /var/log/im-server ]; then
mkdir /var/log/im-server
fi
mv -f /opt/im-server/config /etc/im-server mv -f /opt/im-server/config /etc/im-server
systemctl daemon-reload systemctl daemon-reload
echo "IM server folders:" echo "IM server folders:"
echo "/etc/im-server/config config" echo "/etc/im-server/config config"
echo "/opt/im-server binary files" echo "/opt/im-server binary files"
@@ -56,6 +56,12 @@ token.key testim
##token的过期时间,单位为毫秒,默认为无限期。如果需要设置无限期,客户端上一定需要加上token过期的处理。token过期的处理请参考文档的常见问题 ##token的过期时间,单位为毫秒,默认为无限期。如果需要设置无限期,客户端上一定需要加上token过期的处理。token过期的处理请参考文档的常见问题
##token.expire_time 2592000000 ##token.expire_time 2592000000
##客户端(目前只有android)的应用签名(一个应用最取第一个签名),如果有多个签名(多个客户端),用英文逗号分开。获取签名方法请参考文档:https://docs.wildfirechat.cn/blogs/签名验证.html
#connect.client_signature_list eNkezQ1g9OsnhfLSFUY1vzKDzhs=,xykezQ1g9OsnhfLSFUY1vzKDzhs=
##是否拒绝空签名的android客户端, 默认为true。当有旧的客户端需要兼容时改成false,当所有都是新客户端时,改成true。
#connect.reject_empty_signature true
##首次登录,是否接收之前的历史消息。 ##首次登录,是否接收之前的历史消息。
##0 不接收历史消息,只接收${message.compensate_time_limit}毫秒以内的消息,由于服务器没有保存已经收取记录,所以如果有超过${message.compensate_time_limit}毫秒之前未收取的消息也不会收取下拉; ##0 不接收历史消息,只接收${message.compensate_time_limit}毫秒以内的消息,由于服务器没有保存已经收取记录,所以如果有超过${message.compensate_time_limit}毫秒之前未收取的消息也不会收取下拉;
##1接收,会接收 message.max_queue 配置的条数的历史消息 ##1接收,会接收 message.max_queue 配置的条数的历史消息
@@ -76,6 +82,9 @@ message.chatroom_remote_history_message 1
##是否禁止陌生人聊天 ##是否禁止陌生人聊天
message.disable_stranger_chat false message.disable_stranger_chat false
##当禁止陌生人聊天时,允许聊天的用户id,比如管理员或者文件传输助手等。用户id以英文逗号分割。
message.allow_stranger_chat_list admin,FireRobot,wfc_file_transfer
##黑名单策略,0 发送失败,返回被拉黑的错误码;1 发送成功但消息被服务器直接丢弃 ##黑名单策略,0 发送失败,返回被拉黑的错误码;1 发送成功但消息被服务器直接丢弃
message.blacklist.strategy 0 message.blacklist.strategy 0
@@ -289,15 +298,18 @@ push.ios.server.address http://localhost:8085/ios/push
##消息转发地址 ##消息转发地址
##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!! ##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!!
#message.forward.url http://localhost:8087/im_event/message #message.forward.url http://localhost:8888/im_event/message
##需要转发的消息类型,当有多个时以英文逗号分割。如果转发所有消息,请注释掉配置或者设置为空 ##需要转发的消息类型,当有多个时以英文逗号分割,可以用-来指定区间,注意区间不能太大,因为要把区间内的所有数字都放入到Set中。如果转发所有消息,请注释掉配置或者设置为空
#message.forward.types 1,2,3 #message.forward.types 1,2,3,5-10
##需要转发的消息类型,当有多个时以英文逗号分割,可以用-来指定区间,注意区间不能太大,因为要把区间内的所有数字都放入到Set中。
#message.forward.exclude_types 1,2,3,5-10
##敏感消息转发地址 ##敏感消息转发地址
##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!! ##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!!
#message.sensitive.forward.url http://localhost:8888/im_event/message #message.sensitive.forward.url http://localhost:8888/im_event/message
##提醒消息转发地址,@全体用户和@某个用户消息会回调此地址。此转发不受${message.forward.types}限制。 ##提醒消息转发地址,@全体用户和@某个用户消息会回调此地址。
##此转发不受${message.forward.types}和${message.forward.exclude_types}限制。
##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!! ##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!!
#message.mentionmsg.forward.url http://localhost:8888/im_event/message #message.mentionmsg.forward.url http://localhost:8888/im_event/message
+4
View File
@@ -12,6 +12,10 @@ if [ ! -d /etc/im-server ]; then
mkdir /etc/im-server mkdir /etc/im-server
fi fi
if [ ! -d /var/log/im-server ]; then
mkdir /var/log/im-server
fi
mv -f /opt/im-server/config /etc/im-server mv -f /opt/im-server/config /etc/im-server
systemctl daemon-reload systemctl daemon-reload
@@ -14,11 +14,11 @@ goto end
:okHome :okHome
rem Set JavaHome if it exists rem Set JavaHome if it exists
if exist { "%JAVA_HOME%\bin\java" } ( if exist [ "%JAVA_HOME%\bin\java" ] (
set "JAVA="%JAVA_HOME%\bin\java"" set "JAVA="%JAVA_HOME%\bin\java""
) else { ) else (
set "JAVA="java"" set "JAVA="java""
} )
echo Using JAVA_HOME: "%JAVA_HOME%" echo Using JAVA_HOME: "%JAVA_HOME%"
echo Using WILDFIRECHAT_HOME: "%WILDFIRECHAT_HOME%" echo Using WILDFIRECHAT_HOME: "%WILDFIRECHAT_HOME%"
@@ -73,7 +73,9 @@ rem set JAVA_OPTS=%JAVA_OPTS% -XX:NumberOfGCLogFiles=10
rem set JAVA_OPTS=%JAVA_OPTS% -XX:GCLogFileSize=10M" rem set JAVA_OPTS=%JAVA_OPTS% -XX:GCLogFileSize=10M"
echo echo
echo 请设置JVM参数Xmx和Xms!!! echo "Please set Xmx and Xms parameters!"
echo "Please set Xmx and Xms parameters!"
echo "Please set Xmx and Xms parameters!"
echo echo
rem set JAVA_OPTS=%JAVA_OPTS% -Xmx2G rem set JAVA_OPTS=%JAVA_OPTS% -Xmx2G
@@ -18,7 +18,6 @@ while [ -h "$PRG" ]; do
done done
PRGDIR=`dirname "$PRG"` PRGDIR=`dirname "$PRG"`
cd $PRGDIR
cd .. cd ..
WILDFIRECHAT_HOME=`pwd` WILDFIRECHAT_HOME=`pwd`
+1 -1
View File
@@ -1,6 +1,6 @@
FROM openjdk:8-jre-alpine FROM openjdk:8-jre-alpine
ADD ../distribution/target/distribution-*-bundle-tar.tar.gz /opt/im-server/ ADD distribution-*-bundle-tar.tar.gz /opt/im-server/
RUN sed -i 's/#JAVA_OPTS="$JAVA_OPTS -Xmx128M"/JAVA_OPTS="$JAVA_OPTS -Xmx$JVM_XMX"/g' /opt/im-server/bin/wildfirechat.sh RUN sed -i 's/#JAVA_OPTS="$JAVA_OPTS -Xmx128M"/JAVA_OPTS="$JAVA_OPTS -Xmx$JVM_XMX"/g' /opt/im-server/bin/wildfirechat.sh
RUN sed -i 's/#JAVA_OPTS="$JAVA_OPTS -Xms128M"/JAVA_OPTS="$JAVA_OPTS -Xms$JVM_XMS"/g' /opt/im-server/bin/wildfirechat.sh RUN sed -i 's/#JAVA_OPTS="$JAVA_OPTS -Xms128M"/JAVA_OPTS="$JAVA_OPTS -Xms$JVM_XMS"/g' /opt/im-server/bin/wildfirechat.sh
+3 -2
View File
@@ -5,17 +5,18 @@
``` ```
mvn clean package mvn clean package
``` ```
生成的软件包在```distribution/target/distribution-XX-bundle-tar.tar.gz```,把此软件包拷贝到docker目录下。
然后进入到docker目录下,编译镜像 然后进入到docker目录下,编译镜像
``` ```
sudo docker build -t im-server -f Dockerfile .. sudo docker build -t im-server .
``` ```
## 运行 ## 运行
配置: 配置:
运行需要手动指定配置目录,手动指定配置目录的方法如下,其中$PATH_TO_CONFIG为im配置目录,需要为绝对路径,模版为```distribution/src/main/resources```目录。另外需要创建h2数据库目录(如果用mysql就不需要了)、日志目录、内置存储服务目录(如果使用其它对象存储服务就不需要了)。 运行需要手动指定配置目录,手动指定配置目录的方法如下,其中$PATH_TO_CONFIG为im配置目录,需要为绝对路径,模版为```distribution/src/main/resources```目录。另外需要创建h2数据库目录(如果用mysql就不需要了)、日志目录、内置存储服务目录(如果使用其它对象存储服务就不需要了)。
``` ```
sudo docker run -it -v $PATH_TO_CONFIG:/opt/im-server/config -v $PATH_TO_LOGS:/opt/im-server/logs -v $PATH_TO_H2DB:/opt/im-server/h2db -v $PATH_TO_MEDIA:/opt/im-server/media -e JVM_XMX=256M -e JVM_XMS=256M -p 80:80 -p 1883:1883 -p 8083:8083 -p 8084:8084 -p 18080:18080 im-server sudo docker run -it --name im-server -v $PATH_TO_CONFIG:/opt/im-server/config -v $PATH_TO_LOGS:/opt/im-server/logs -v $PATH_TO_H2DB:/opt/im-server/h2db -v $PATH_TO_MEDIA:/opt/im-server/media -e JVM_XMX=256M -e JVM_XMS=256M -p 80:80 -p 1883:1883 -p 8083:8083 -p 8084:8084 -p 18080:18080 im-server
``` ```
## 导出镜像 ## 导出镜像
+1 -1
View File
@@ -12,7 +12,7 @@
<artifactId>wildfirechat-parent</artifactId> <artifactId>wildfirechat-parent</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>0.97</version> <version>0.99</version>
<name>Wildfire Chat</name> <name>Wildfire Chat</name>
<description>Wildfire Chat Server</description> <description>Wildfire Chat Server</description>
<inceptionYear>2019</inceptionYear> <inceptionYear>2019</inceptionYear>
@@ -12,12 +12,27 @@
# 更新记录 # 更新记录
--------------
Release note 0.99:
1. API获取用户信息时,过滤掉已经删除用户。
2. 消息转发功能支持设置include/exclude功能,支持按区间过滤。
3. 添加新的群组类型:组织群。组织群适用于公司部门群场景。
4. 内置对象存储支持绝对路径和相对路径配置
5. 当开启禁止陌生人聊天时,可以添加例外人员
6. 解决user setting并发问题
7. 添加可选的android平台签名验证功能。
--------------
Release note 0.98:
1. 解决linux多端登录错误问题
2. 添加获取用户群组和共同群组功能
3. 解决windows下脚本编码错误问题
-------------- --------------
Release note 0.97: Release note 0.97:
1. 升级部分依赖库到最新版本 1. 升级部分依赖库到最新版本
2. 添加名片消息默认推送信息 2. 添加名片消息默认推送信息
3. 添加deb和rpm格式软件包 3. 添加deb和rpm格式软件包
4. 解决linux平台多端的问题
-------------- --------------
Release note 0.96: Release note 0.96:
Binary file not shown.

After

Width:  |  Height:  |  Size: 998 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 535 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 846 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 KiB

+33 -1
View File
@@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>wildfirechat-parent</artifactId> <artifactId>wildfirechat-parent</artifactId>
<groupId>cn.wildfirechat</groupId> <groupId>cn.wildfirechat</groupId>
<version>0.97</version> <version>0.99</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@@ -81,4 +81,36 @@
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<finalName>${project.artifactId}-${version}</finalName>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>checker</finalName>
<appendAssemblyId>false</appendAssemblyId>
<archive>
<manifest>
<mainClass>cn.wildfirechat.sdk.Main</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>assemble-all</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> </project>
@@ -170,4 +170,10 @@ public class GroupAdmin {
return AdminHttpUtils.httpJsonPost(path, inputUserId, OutputGroupIds.class); return AdminHttpUtils.httpJsonPost(path, inputUserId, OutputGroupIds.class);
} }
public static IMResult<OutputGroupIds> getCommonGroups(String user1, String user2) throws Exception {
String path = APIPath.Get_Common_Groups;
StringPairPojo intput = new StringPairPojo(user1, user2);
return AdminHttpUtils.httpJsonPost(path, intput, OutputGroupIds.class);
}
} }
@@ -31,6 +31,20 @@ public class Main {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
if (args.length == 5) {
AdminUrl = args[0];
AdminSecret = args[1];
IMUrl = args[2];
commercialServer = Boolean.parseBoolean(args[3]);
advanceVoip = Boolean.parseBoolean(args[4]);
} else {
System.out.println("Usage: java -jar checker.jar adminUrl adminSecret imUrl commercialServer advanceVoip \n e.g. java -jar checker.jar http://192.168.1.80:18080 123456 http://192.168.1.80 false false");
System.out.println();
System.out.println();
System.out.println("Use default value: java -jar checker.jar http://127.0.0.1:18080 123456 http://127.0.0.1 false false");
}
//admin使用的是18080端口,超级管理接口,理论上不能对外开放端口,也不能让非内部服务知悉密钥。 //admin使用的是18080端口,超级管理接口,理论上不能对外开放端口,也不能让非内部服务知悉密钥。
testAdmin(); testAdmin();
@@ -617,6 +631,13 @@ public class Main {
System.exit(-1); System.exit(-1);
} }
groupIdsIMResult = GroupAdmin.getCommonGroups("user1", "user2");
if (groupIdsIMResult != null && groupIdsIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("get user common groups success");
} else {
System.out.println("get user common groups failure");
System.exit(-1);
}
//仅专业版支持 //仅专业版支持
if (commercialServer) { if (commercialServer) {