diff --git a/README_moquette.md b/README_moquette.md deleted file mode 100644 index 62a3c5af..00000000 --- a/README_moquette.md +++ /dev/null @@ -1,18 +0,0 @@ - -# 野火IM社区版 - -## 运行 -在[release](https://github.com/wildfirechat/wildfirechat/releases),下载最新版本。然后按照[部署说明](http://docs.wildfirechat.cn/quick_start/server.html)部署 - -## 源码编译 -下载最新代码后,进入到工程目录,执行`mvn clean install -Dmaven.test.skip=true`。编译成功后,在`distribution/target`目录找到版本。 - -## 特别说明 -本服务软件基于或使用了如下开源软件,对他们的贡献表示感谢 -* [Moquette](https://github.com/moquette-io/moquette) -* [LoServer](https://github.com/looly/loServer) -* [mqtt-jmeter](https://github.com/emqx/mqtt-jmeter) - -## 版权说明 -This work is licensed under a Creative Commons Attribution-NoDerivs 3.0 Unported License. -本工程遵循CC-BY-ND-3.0(Creative Commons Attribution-NoDerivs 3.0 Unported)协议,使用的开源组件版权说明请参考工程中的license文件 diff --git a/broker/config/wildfirechat.conf b/broker/config/wildfirechat.conf index e6a9eb72..6ae63653 100755 --- a/broker/config/wildfirechat.conf +++ b/broker/config/wildfirechat.conf @@ -9,7 +9,7 @@ server.ip 0.0.0.0 port 1883 ##客户端短链接端口 -http_port 8080 +http_port 80 ##WEB客户端长链接端口 websocket_port 8083 @@ -24,7 +24,7 @@ node_id 1 host 0.0.0.0 ##本地绑定端口 -local_port 8080 +local_port 80 ##是否使用内置DB。0使用mysql;1使用h2db embed.db 1 @@ -32,9 +32,12 @@ embed.db 1 ##服务器管理接口密钥 http.admin.secret_key 123456 -##客户端协议栈密钥,需要与客户端协议栈文件libemqq.cc文件中的aes_key值保持一致,16进制byte用逗号分割 +##客户端协议栈密钥,需要与客户端协议栈文件libemqq.cc文件中的aes_key值保持一致,16进制byte用逗号分割。重要性没有那么大,可以不用修改。 client.proto.secret_key 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F +##用来生产im token的私钥,只在服务器使用,客户端不用。正式使用时为了安全一定要修改这个值,切记切记 +token.key testim + #********************************************************************* # hazelcase configuration #********************************************************************* diff --git a/broker/src/main/java/cn/wildfirechat/server/MechineCode.java b/broker/src/main/java/cn/wildfirechat/server/MechineCode.java deleted file mode 100644 index 5a6bd776..00000000 --- a/broker/src/main/java/cn/wildfirechat/server/MechineCode.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file is part of the Wildfire Chat package. - * (c) Heavyrain2012 - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -package cn.wildfirechat.server; - -import win.liyufan.im.Utility; - -import java.util.Base64; - -public class MechineCode { - public static void main(String[] args) throws Exception { - for (String arg: args - ) { - System.out.println(arg); - } - - if (args.length != 2) { - System.out.println("Usage: ip port"); - System.exit(-1); - } - String mac = Utility.getMacAddress(); - mac += "|"; - mac += args[0]; - mac += "|"; - mac += args[1]; - mac = Base64.getEncoder().encodeToString(mac.getBytes()); - System.out.println(mac); - } -} diff --git a/broker/src/main/java/io/moquette/BrokerConstants.java b/broker/src/main/java/io/moquette/BrokerConstants.java index 715ed178..0bc8a0a5 100755 --- a/broker/src/main/java/io/moquette/BrokerConstants.java +++ b/broker/src/main/java/io/moquette/BrokerConstants.java @@ -101,6 +101,7 @@ public final class BrokerConstants { public static final String HZ_Cluster_Node_ID = "node_id"; public static final String HTTP_SERVER_SECRET_KEY = "http.admin.secret_key"; public static final String CLIENT_PROTO_SECRET_KEY = "client.proto.secret_key"; + public static final String TOKEN_SECRET_KEY = "token.key "; public static final String EMBED_DB_PROPERTY_NAME = "embed.db"; diff --git a/broker/src/main/java/io/moquette/server/Server.java b/broker/src/main/java/io/moquette/server/Server.java index 3c4e62e5..80633aa5 100755 --- a/broker/src/main/java/io/moquette/server/Server.java +++ b/broker/src/main/java/io/moquette/server/Server.java @@ -38,6 +38,7 @@ import io.moquette.spi.impl.security.AES; import io.moquette.spi.security.IAuthenticator; import io.moquette.spi.security.IAuthorizator; import io.moquette.spi.security.ISslContextCreator; +import io.moquette.spi.security.Tokenor; import io.netty.util.ResourceLeakDetector; import win.liyufan.im.DBUtil; @@ -379,6 +380,7 @@ public class Server { hazelcastInstance.getCluster().getLocalMember().setStringAttribute(HZ_Cluster_Node_External_Short_Port, shortPort); hazelcastInstance.getCluster().getLocalMember().setIntAttribute(HZ_Cluster_Node_ID, nodeId); hazelcastInstance.getCluster().getLocalMember().setStringAttribute(HZ_Cluster_Node_External_IP, serverIp); + Tokenor.setKey(config.getProperty(BrokerConstants.TOKEN_SECRET_KEY)); RPCCenter.getInstance().init(this); return true; } diff --git a/broker/src/main/java/io/moquette/spi/security/Tokenor.java b/broker/src/main/java/io/moquette/spi/security/Tokenor.java index 9b367c6e..1922f5b4 100755 --- a/broker/src/main/java/io/moquette/spi/security/Tokenor.java +++ b/broker/src/main/java/io/moquette/spi/security/Tokenor.java @@ -1,10 +1,17 @@ package io.moquette.spi.security; +import com.hazelcast.util.StringUtil; import io.moquette.spi.impl.security.AES; public class Tokenor { - private static final String KEY = "testim"; + private static String KEY = "testim"; + + public static void setKey(String key) { + if (!StringUtil.isNullOrEmpty(key)) { + KEY = key; + } + } public static String getUserId(byte[] password) { try { diff --git a/distribution/src/main/resources/wildfirechat.conf b/distribution/src/main/resources/wildfirechat.conf index 8e1b01f3..5eb0916d 100755 --- a/distribution/src/main/resources/wildfirechat.conf +++ b/distribution/src/main/resources/wildfirechat.conf @@ -32,9 +32,12 @@ embed.db 1 ##服务器管理接口密钥 http.admin.secret_key 123456 -##客户端协议栈密钥,需要与客户端协议栈文件libemqq.cc文件中的aes_key值保持一致,16进制byte用逗号分割 +##客户端协议栈密钥,需要与客户端协议栈文件libemqq.cc文件中的aes_key值保持一致,16进制byte用逗号分割。重要性没有那么大,可以不用修改。 client.proto.secret_key 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F +##用来生产im token的私钥,只在服务器使用,客户端不用。正式使用时为了安全一定要修改这个值,切记切记 +token.key testim + #********************************************************************* # hazelcase configuration #*********************************************************************