From 030e0c2b5dc33d91e34f15c8a1d66de18f6613e3 Mon Sep 17 00:00:00 2001 From: sdvdxl Date: Thu, 13 May 2021 22:52:37 +0800 Subject: [PATCH 1/7] add mqtt server Signed-off-by: sdvdxl --- example/pom.xml | 25 +++- .../softgateway/sample/MqttServerSample.java | 23 ++++ framework-core/pom.xml | 12 +- .../network/common/coder/PacketCoder.java | 15 ++ framework-network-mqtt/pom.xml | 31 +++++ .../network/mqtt/ConnectionContext.java | 48 +++++++ .../network/mqtt/MqttConnections.java | 32 +++++ .../softgateway/network/mqtt/MqttServer.java | 129 ++++++++++++++++++ .../listener/AbstractListenerAdapter.java | 32 +++++ .../listener/AcceptAllListenerAdapter.java | 15 ++ .../network/mqtt/listener/Listener.java | 53 +++++++ .../listener/RejectAllListenerAdapter.java | 15 ++ pom.xml | 20 ++- 13 files changed, 437 insertions(+), 13 deletions(-) create mode 100644 example/src/main/java/me/hekr/iotos/softgateway/sample/MqttServerSample.java create mode 100644 framework-network-mqtt/pom.xml create mode 100644 framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/ConnectionContext.java create mode 100644 framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/MqttConnections.java create mode 100644 framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/MqttServer.java create mode 100644 framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/AbstractListenerAdapter.java create mode 100644 framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/AcceptAllListenerAdapter.java create mode 100644 framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/Listener.java create mode 100644 framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/RejectAllListenerAdapter.java diff --git a/example/pom.xml b/example/pom.xml index fedfb78..9843549 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -7,6 +7,11 @@ me.hekr.iotos.softgateway 3.0.2 + + 8 + 8 + 3.0.2 + 4.0.0 example @@ -14,18 +19,26 @@ me.hekr.iotos.softgateway framework-network-tcp - 3.0.2 + ${iotos.softgateway.version} me.hekr.iotos.softgateway framework-network-udp - 3.0.2 + ${iotos.softgateway.version} + + + me.hekr.iotos.softgateway + framework-network-mqtt + ${iotos.softgateway.version} + + + ch.qos.logback + logback-classic + 1.2.3 + + - - 8 - 8 - \ No newline at end of file diff --git a/example/src/main/java/me/hekr/iotos/softgateway/sample/MqttServerSample.java b/example/src/main/java/me/hekr/iotos/softgateway/sample/MqttServerSample.java new file mode 100644 index 0000000..cd42adb --- /dev/null +++ b/example/src/main/java/me/hekr/iotos/softgateway/sample/MqttServerSample.java @@ -0,0 +1,23 @@ +package me.hekr.iotos.softgateway.sample; + +import java.util.concurrent.CountDownLatch; +import lombok.extern.slf4j.Slf4j; +import me.hekr.iotos.softgateway.network.common.coder.PacketCoder; +import me.hekr.iotos.softgateway.network.mqtt.MqttServer; +import me.hekr.iotos.softgateway.network.mqtt.listener.AcceptAllListenerAdapter; + +/** @author iotos */ +@Slf4j +public class MqttServerSample { + public static void main(String[] args) { + try { + MqttServer mqttServer = new MqttServer<>(); + mqttServer.setPacketCoder(PacketCoder.STRING_CODER); + mqttServer.setListener(new AcceptAllListenerAdapter<>()); + mqttServer.start(); + new CountDownLatch(1).await(); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + } +} diff --git a/framework-core/pom.xml b/framework-core/pom.xml index a5b2aef..0f0b8e2 100644 --- a/framework-core/pom.xml +++ b/framework-core/pom.xml @@ -16,7 +16,17 @@ 8 - + + + + org.springframework.boot + spring-boot-starter-parent + 2.1.6.RELEASE + pom + import + + + org.springframework.boot diff --git a/framework-network-common/src/main/java/me/hekr/iotos/softgateway/network/common/coder/PacketCoder.java b/framework-network-common/src/main/java/me/hekr/iotos/softgateway/network/common/coder/PacketCoder.java index e082393..4156f42 100644 --- a/framework-network-common/src/main/java/me/hekr/iotos/softgateway/network/common/coder/PacketCoder.java +++ b/framework-network-common/src/main/java/me/hekr/iotos/softgateway/network/common/coder/PacketCoder.java @@ -1,10 +1,25 @@ package me.hekr.iotos.softgateway.network.common.coder; +import java.nio.charset.StandardCharsets; import me.hekr.iotos.softgateway.network.common.DecodePacket; /** @author iotos */ public interface PacketCoder { + /** 如果传输数据是 String,可以使用这个编解码实现 */ + PacketCoder STRING_CODER = + new PacketCoder() { + + @Override + public byte[] encode(String s) { + return s.getBytes(StandardCharsets.UTF_8); + } + + @Override + public DecodePacket decode(byte[] bytes) { + return DecodePacket.wrap(new String(bytes, StandardCharsets.UTF_8), bytes.length); + } + }; /** * 编码 * diff --git a/framework-network-mqtt/pom.xml b/framework-network-mqtt/pom.xml new file mode 100644 index 0000000..fe5a57a --- /dev/null +++ b/framework-network-mqtt/pom.xml @@ -0,0 +1,31 @@ + + + + iotos-soft-gateway + me.hekr.iotos.softgateway + 3.0.2 + + 4.0.0 + + framework-network-mqtt + + + 8 + 8 + + + + + io.vertx + vertx-mqtt + 4.0.3 + + + me.hekr.iotos.softgateway + framework-network-common + 3.0.2 + + + \ No newline at end of file diff --git a/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/ConnectionContext.java b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/ConnectionContext.java new file mode 100644 index 0000000..115bc9d --- /dev/null +++ b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/ConnectionContext.java @@ -0,0 +1,48 @@ +package me.hekr.iotos.softgateway.network.mqtt; + +import io.netty.handler.codec.mqtt.MqttQoS; +import io.vertx.core.buffer.Buffer; +import io.vertx.mqtt.MqttEndpoint; +import java.net.InetSocketAddress; +import java.time.LocalDateTime; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import me.hekr.iotos.softgateway.network.common.coder.PacketCoder; + +/** @author iotos */ +@Slf4j +public class ConnectionContext { + MqttEndpoint endpoint; + @Setter private PacketCoder packetCoder; + @Setter @Getter private String clientId; + @Setter @Getter private String username; + @Setter @Getter private String password; + @Setter @Getter private InetSocketAddress address; + @Setter @Getter private LocalDateTime connectTime; + @Setter @Getter private LocalDateTime authTime; + @Setter @Getter private boolean auth; + + public void publish(String topic, T payload) { + publish(topic, MqttQoS.AT_MOST_ONCE, payload); + } + + public void publish(String topic, MqttQoS qos, T payload) { + endpoint + .publish(topic, Buffer.buffer(packetCoder.encode(payload)), qos, false, false) + .onComplete( + ar -> { + if (ar.succeeded() && log.isDebugEnabled()) { + log.debug("发送消息成功, topic:{}, qos: {} , payload: {}", topic, qos, payload); + } else { + log.error( + "发送消息失败, topic:{}, qos: {} , payload: {} , error: {}", + topic, + qos, + payload, + ar.cause().getMessage()); + } + }); + } + ; +} diff --git a/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/MqttConnections.java b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/MqttConnections.java new file mode 100644 index 0000000..0c0b903 --- /dev/null +++ b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/MqttConnections.java @@ -0,0 +1,32 @@ +package me.hekr.iotos.softgateway.network.mqtt; + +import io.vertx.core.net.impl.SocketAddressImpl; +import io.vertx.mqtt.MqttEndpoint; +import java.net.InetSocketAddress; +import java.time.LocalDateTime; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +public class MqttConnections { + private static final ConcurrentMap> CONTEXTS = + new ConcurrentHashMap<>(); + + public static ConnectionContext add(MqttEndpoint endpoint) { + ConnectionContext context = new ConnectionContext<>(); + context.setClientId(endpoint.clientIdentifier()); + context.endpoint = endpoint; + SocketAddressImpl socketAddress = (SocketAddressImpl) endpoint.remoteAddress(); + context.setAddress(new InetSocketAddress(socketAddress.host(), socketAddress.port())); + context.setConnectTime(LocalDateTime.now()); + CONTEXTS.put(endpoint, context); + return context; + } + + public static ConnectionContext remove(MqttEndpoint endpoint) { + return (ConnectionContext) CONTEXTS.remove(endpoint); + } + + public static ConnectionContext get(MqttEndpoint endpoint) { + return (ConnectionContext) CONTEXTS.get(endpoint); + } +} diff --git a/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/MqttServer.java b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/MqttServer.java new file mode 100644 index 0000000..a852111 --- /dev/null +++ b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/MqttServer.java @@ -0,0 +1,129 @@ +package me.hekr.iotos.softgateway.network.mqtt; + +import io.netty.handler.codec.mqtt.MqttConnectReturnCode; +import io.vertx.core.Vertx; +import io.vertx.core.VertxOptions; +import io.vertx.mqtt.MqttAuth; +import io.vertx.mqtt.MqttEndpoint; +import java.time.LocalDateTime; +import java.util.Objects; +import java.util.concurrent.ExecutionException; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import me.hekr.iotos.softgateway.network.common.coder.PacketCoder; +import me.hekr.iotos.softgateway.network.mqtt.listener.Listener; + +/** @author iotos */ +@Slf4j +public class MqttServer { + private final int poolSize = Runtime.getRuntime().availableProcessors() * 4; + @Setter PacketCoder packetCoder; + private Vertx vertx; + private io.vertx.mqtt.MqttServer server; + @Setter private int port; + @Setter private Listener listener; + + public MqttServer(int port) { + this.port = port; + } + + public MqttServer() { + this(1883); + } + + public void start() throws ExecutionException, InterruptedException { + Objects.requireNonNull(packetCoder, "packetCoder 必填"); + Objects.requireNonNull(listener, "listener 必填"); + VertxOptions options = new VertxOptions(); + options.setEventLoopPoolSize(poolSize); + options.setWorkerPoolSize(poolSize); + vertx = Vertx.vertx(options); + server = io.vertx.mqtt.MqttServer.create(vertx); + server.exceptionHandler(t -> log.error(t.getMessage(), t)); + server.endpointHandler( + endpoint -> { + ConnectionContext context = MqttConnections.add(endpoint); + context.setPacketCoder(packetCoder); + endpoint.autoKeepAlive(true); + endpoint.publishAutoAck(true); + handleClose(endpoint); + handlePublishMessage(endpoint); + handleAuth(endpoint); + handleException(endpoint); + }); + server + .listen(1883, "localhost") + .onComplete( + ar -> { + if (ar.succeeded()) { + log.info("mqtt server 启动成功,绑定端口:{}", server.actualPort()); + } else { + log.error("mqtt server 启动失败," + ar.cause().getMessage(), ar.cause()); + } + }); + } + + private void handleException(MqttEndpoint endpoint) { + endpoint.exceptionHandler( + t -> { + log.error(t.getMessage(), t); + }); + } + + /** + * 处理关闭连接 + * + * @param endpoint + */ + private void handleClose(MqttEndpoint endpoint) { + endpoint.closeHandler(v -> listener.onClose(MqttConnections.remove(endpoint))); + } + + /** + * 处理客户端发布的消息 + * + * @param endpoint + */ + private void handlePublishMessage(MqttEndpoint endpoint) { + endpoint.publishHandler( + m -> { + listener.onMessage( + MqttConnections.get(endpoint), + m.topicName(), + m.qosLevel(), + (T) packetCoder.decode(m.payload().getBytes()).getResult()); + }); + } + + /** + * 处理鉴权 + * + * @param endpoint + */ + private void handleAuth(MqttEndpoint endpoint) { + MqttAuth auth = endpoint.auth(); + String username = auth == null ? null : auth.getUsername(); + String password = auth == null ? null : auth.getPassword(); + ConnectionContext context = MqttConnections.get(endpoint); + context.setUsername(username); + context.setPassword(password); + boolean authResult = listener.auth(context); + context.setAuth(authResult); + context.setAuthTime(LocalDateTime.now()); + if (authResult) { + endpoint.accept(false); + } else { + endpoint.reject(MqttConnectReturnCode.CONNECTION_REFUSED_BAD_USER_NAME_OR_PASSWORD); + } + } + + public void close() { + if (server != null) { + server.close(); + } + + if (vertx != null) { + vertx.close(); + } + } +} diff --git a/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/AbstractListenerAdapter.java b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/AbstractListenerAdapter.java new file mode 100644 index 0000000..7e82d48 --- /dev/null +++ b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/AbstractListenerAdapter.java @@ -0,0 +1,32 @@ +package me.hekr.iotos.softgateway.network.mqtt.listener; + +import io.netty.handler.codec.mqtt.MqttQoS; +import lombok.extern.slf4j.Slf4j; +import me.hekr.iotos.softgateway.network.mqtt.ConnectionContext; + +/** @author iotos */ +@Slf4j +public abstract class AbstractListenerAdapter implements Listener { + + @Override + public void onConnect(ConnectionContext context) { + log.info("建立连接,clientid:{}, address:{}", context.getClientId(), context.getAddress()); + } + + @Override + public void onDisconnect(ConnectionContext context) { + log.info("断开连接,clientId:{}", context.getClientId()); + } + + @Override + public void onMessage(ConnectionContext context, String topic, MqttQoS qos, T payload) { + log.info( + "收到消息,clientId:{},topic:{},qos:{},message:{}", context.getClientId(), topic, qos, payload); + context.publish(topic + "/resp", payload); + } + + @Override + public void onClose(ConnectionContext context) { + log.info("关闭连接,clientId:{}", context.getClientId()); + } +} diff --git a/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/AcceptAllListenerAdapter.java b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/AcceptAllListenerAdapter.java new file mode 100644 index 0000000..6bcf2ee --- /dev/null +++ b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/AcceptAllListenerAdapter.java @@ -0,0 +1,15 @@ +package me.hekr.iotos.softgateway.network.mqtt.listener; + +import lombok.extern.slf4j.Slf4j; +import me.hekr.iotos.softgateway.network.mqtt.ConnectionContext; + +/** @author iotos */ +@Slf4j +public class AcceptAllListenerAdapter extends AbstractListenerAdapter { + + @Override + public boolean auth(ConnectionContext context) { + log.info("接受连接,clientId:{},address:{}", context.getClientId(), context.getAddress()); + return true; + } +} diff --git a/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/Listener.java b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/Listener.java new file mode 100644 index 0000000..1308524 --- /dev/null +++ b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/Listener.java @@ -0,0 +1,53 @@ +package me.hekr.iotos.softgateway.network.mqtt.listener; + +import io.netty.handler.codec.mqtt.MqttQoS; +import me.hekr.iotos.softgateway.network.mqtt.ConnectionContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * 监听器 + * + * @author iotos + */ +public interface Listener { + Logger log = LoggerFactory.getLogger(Listener.class); + /** + * 建立连接 + * + * @param context + */ + void onConnect(ConnectionContext context); + + /** + * 断开连接 + * + * @param context + */ + void onDisconnect(ConnectionContext context); + + /** + * 收到消息 + * + * @param context + * @param topic + * @param qos + * @param payload + */ + void onMessage(ConnectionContext context, String topic, MqttQoS qos, T payload); + + /** + * 连接关闭 + * + * @param context + */ + void onClose(ConnectionContext context); + + /** + * 认证 + * + * @param context + * @return + */ + boolean auth(ConnectionContext context); +} diff --git a/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/RejectAllListenerAdapter.java b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/RejectAllListenerAdapter.java new file mode 100644 index 0000000..eb12b11 --- /dev/null +++ b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/RejectAllListenerAdapter.java @@ -0,0 +1,15 @@ +package me.hekr.iotos.softgateway.network.mqtt.listener; + +import lombok.extern.slf4j.Slf4j; +import me.hekr.iotos.softgateway.network.mqtt.ConnectionContext; + +/** @author iotos */ +@Slf4j +public class RejectAllListenerAdapter extends AbstractListenerAdapter { + + @Override + public boolean auth(ConnectionContext context) { + log.info("(默认实现)拒绝(所有)连接,clientId:{},address:{}", context.getClientId(), context.getAddress()); + return false; + } +} diff --git a/pom.xml b/pom.xml index 53cb76d..e75b699 100644 --- a/pom.xml +++ b/pom.xml @@ -11,13 +11,9 @@ framework-network-common example framework-common-utils + framework-network-mqtt - - org.springframework.boot - spring-boot-starter-parent - 2.1.6.RELEASE - - + me.hekr.iotos.softgateway iotos-soft-gateway @@ -31,22 +27,34 @@ 1.8 + + + + io.netty + netty-all + 4.1.60.Final + + + org.projectlombok lombok + 1.18.8 provided org.slf4j slf4j-api + 1.7.26 junit junit + 4.12 test -- Gitee From 59579f59c1212c4e57f9f62323f8c1027d928681 Mon Sep 17 00:00:00 2001 From: sdvdxl Date: Thu, 13 May 2021 22:54:21 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E4=B8=BA3.1.0-SNAPSHOT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: sdvdxl --- deploy.sh | 2 +- example/pom.xml | 2 +- framework-common-utils/pom.xml | 2 +- framework-core/pom.xml | 4 ++-- framework-network-common/pom.xml | 4 ++-- framework-network-mqtt/pom.xml | 4 ++-- framework-network-tcp/pom.xml | 6 +++--- framework-network-udp/pom.xml | 6 +++--- pom.xml | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/deploy.sh b/deploy.sh index 17e22fb..0785901 100755 --- a/deploy.sh +++ b/deploy.sh @@ -3,7 +3,7 @@ # ./deploy deploy 生成 maven jar包 # ./deploy upload 生成 maven jar 包并 commit -VERSION="3.0.2" +VERSION="3.1.0-SNAPSHOT" echo "版本号:$VERSION" updateVersion(){ diff --git a/example/pom.xml b/example/pom.xml index 9843549..2d6b5c5 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -5,7 +5,7 @@ iotos-soft-gateway me.hekr.iotos.softgateway - 3.0.2 + 3.1.0-SNAPSHOT 8 diff --git a/framework-common-utils/pom.xml b/framework-common-utils/pom.xml index 9986852..cca1c2b 100644 --- a/framework-common-utils/pom.xml +++ b/framework-common-utils/pom.xml @@ -5,7 +5,7 @@ iotos-soft-gateway me.hekr.iotos.softgateway - 3.0.2 + 3.1.0-SNAPSHOT 4.0.0 diff --git a/framework-core/pom.xml b/framework-core/pom.xml index 0f0b8e2..0057836 100644 --- a/framework-core/pom.xml +++ b/framework-core/pom.xml @@ -5,7 +5,7 @@ iotos-soft-gateway me.hekr.iotos.softgateway - 3.0.2 + 3.1.0-SNAPSHOT 4.0.0 jar @@ -52,7 +52,7 @@ me.hekr.iotos.softgateway framework-common-utils - 3.0.2 + 3.1.0-SNAPSHOT diff --git a/framework-network-common/pom.xml b/framework-network-common/pom.xml index 16b151b..4b60014 100644 --- a/framework-network-common/pom.xml +++ b/framework-network-common/pom.xml @@ -5,7 +5,7 @@ iotos-soft-gateway me.hekr.iotos.softgateway - 3.0.2 + 3.1.0-SNAPSHOT 4.0.0 @@ -24,7 +24,7 @@ me.hekr.iotos.softgateway framework-common-utils - 3.0.2 + 3.1.0-SNAPSHOT \ No newline at end of file diff --git a/framework-network-mqtt/pom.xml b/framework-network-mqtt/pom.xml index fe5a57a..430fb52 100644 --- a/framework-network-mqtt/pom.xml +++ b/framework-network-mqtt/pom.xml @@ -5,7 +5,7 @@ iotos-soft-gateway me.hekr.iotos.softgateway - 3.0.2 + 3.1.0-SNAPSHOT 4.0.0 @@ -25,7 +25,7 @@ me.hekr.iotos.softgateway framework-network-common - 3.0.2 + 3.1.0-SNAPSHOT \ No newline at end of file diff --git a/framework-network-tcp/pom.xml b/framework-network-tcp/pom.xml index f126f0d..81989f9 100644 --- a/framework-network-tcp/pom.xml +++ b/framework-network-tcp/pom.xml @@ -5,12 +5,12 @@ iotos-soft-gateway me.hekr.iotos.softgateway - 3.0.2 + 3.1.0-SNAPSHOT 4.0.0 framework-network-tcp - 3.0.2 + 3.1.0-SNAPSHOT 8 @@ -21,7 +21,7 @@ me.hekr.iotos.softgateway framework-network-common - 3.0.2 + 3.1.0-SNAPSHOT diff --git a/framework-network-udp/pom.xml b/framework-network-udp/pom.xml index 4ac7246..682faf0 100644 --- a/framework-network-udp/pom.xml +++ b/framework-network-udp/pom.xml @@ -5,12 +5,12 @@ iotos-soft-gateway me.hekr.iotos.softgateway - 3.0.2 + 3.1.0-SNAPSHOT 4.0.0 framework-network-udp - 3.0.2 + 3.1.0-SNAPSHOT 8 @@ -21,7 +21,7 @@ me.hekr.iotos.softgateway framework-network-common - 3.0.2 + 3.1.0-SNAPSHOT diff --git a/pom.xml b/pom.xml index e75b699..7d8078c 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ me.hekr.iotos.softgateway iotos-soft-gateway - 3.0.2 + 3.1.0-SNAPSHOT iotos-soft-gateway IoTOS 软网关 -- Gitee From d9752f1155afe449d35f4e6600eaf89d7f6a18bd Mon Sep 17 00:00:00 2001 From: sdvdxl Date: Fri, 14 May 2021 10:33:06 +0800 Subject: [PATCH 3/7] =?UTF-8?q?add=20=E5=8F=91=E5=B8=83=E5=88=B0=E4=B8=AD?= =?UTF-8?q?=E5=A4=AE=E4=BB=93=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: sdvdxl --- pom.xml | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7d8078c..32701bc 100644 --- a/pom.xml +++ b/pom.xml @@ -59,6 +59,66 @@ - + + + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + ossrh + https://s01.oss.sonatype.org/ + true + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + + + + + + + + + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + + + -- Gitee From 99217551a035e02b7120a63d697633eb69ddcefb Mon Sep 17 00:00:00 2001 From: sdvdxl Date: Fri, 14 May 2021 11:34:54 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=20acl=20=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: sdvdxl --- example/pom.xml | 2 +- .../softgateway/sample/MqttServerSample.java | 40 +++++++++++- framework-common-utils/pom.xml | 5 ++ .../softgateway/network/mqtt/MqttServer.java | 64 ++++++++++++++++--- .../listener/AbstractListenerAdapter.java | 20 ++++++ ...> AcceptAllConnectionListenerAdapter.java} | 2 +- .../network/mqtt/listener/Listener.java | 24 +++++++ ...> RejectAllConnectionListenerAdapter.java} | 2 +- 8 files changed, 144 insertions(+), 15 deletions(-) rename framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/{AcceptAllListenerAdapter.java => AcceptAllConnectionListenerAdapter.java} (81%) rename framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/{RejectAllListenerAdapter.java => RejectAllConnectionListenerAdapter.java} (82%) diff --git a/example/pom.xml b/example/pom.xml index 2d6b5c5..599130d 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -10,7 +10,7 @@ 8 8 - 3.0.2 + 3.1.0-SNAPSHOT 4.0.0 diff --git a/example/src/main/java/me/hekr/iotos/softgateway/sample/MqttServerSample.java b/example/src/main/java/me/hekr/iotos/softgateway/sample/MqttServerSample.java index cd42adb..c56fc27 100644 --- a/example/src/main/java/me/hekr/iotos/softgateway/sample/MqttServerSample.java +++ b/example/src/main/java/me/hekr/iotos/softgateway/sample/MqttServerSample.java @@ -1,10 +1,15 @@ package me.hekr.iotos.softgateway.sample; +import io.netty.handler.codec.mqtt.MqttQoS; +import io.vertx.mqtt.MqttTopicSubscription; +import java.util.List; import java.util.concurrent.CountDownLatch; +import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; import me.hekr.iotos.softgateway.network.common.coder.PacketCoder; +import me.hekr.iotos.softgateway.network.mqtt.ConnectionContext; import me.hekr.iotos.softgateway.network.mqtt.MqttServer; -import me.hekr.iotos.softgateway.network.mqtt.listener.AcceptAllListenerAdapter; +import me.hekr.iotos.softgateway.network.mqtt.listener.AcceptAllConnectionListenerAdapter; /** @author iotos */ @Slf4j @@ -13,7 +18,38 @@ public class MqttServerSample { try { MqttServer mqttServer = new MqttServer<>(); mqttServer.setPacketCoder(PacketCoder.STRING_CODER); - mqttServer.setListener(new AcceptAllListenerAdapter<>()); + mqttServer.setListener( + new AcceptAllConnectionListenerAdapter() { + @Override + public boolean aclPubTopic( + ConnectionContext context, String topicName, MqttQoS qosLevel) { + // 自定义 publish acl + // 如果是 admin/# 只允许 username 是 admin 的发布,否则不允许 + if (topicName.startsWith("admin")) { + return "admin".equals(context.getUsername()); + } + + return true; + } + + @Override + public List aclSubTopic( + ConnectionContext context, List topicSubscriptions) { + // 自定义 publish acl + // 如果是 admin/# 只允许 username 是 admin 的发布,否则不允许 + return topicSubscriptions.stream() + .map( + t -> { + if (t.topicName().startsWith("admin")) { + boolean allow = "admin".equals(context.getUsername()); + return allow ? t.qualityOfService() : MqttQoS.FAILURE; + } + + return t.qualityOfService(); + }) + .collect(Collectors.toList()); + } + }); mqttServer.start(); new CountDownLatch(1).await(); } catch (Exception e) { diff --git a/framework-common-utils/pom.xml b/framework-common-utils/pom.xml index cca1c2b..a8c65c8 100644 --- a/framework-common-utils/pom.xml +++ b/framework-common-utils/pom.xml @@ -36,6 +36,11 @@ 2.9.9 + + com.fasterxml.jackson.core + jackson-annotations + 2.9.9 + cn.hutool hutool-all diff --git a/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/MqttServer.java b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/MqttServer.java index a852111..74cc715 100644 --- a/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/MqttServer.java +++ b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/MqttServer.java @@ -1,13 +1,15 @@ package me.hekr.iotos.softgateway.network.mqtt; import io.netty.handler.codec.mqtt.MqttConnectReturnCode; +import io.netty.handler.codec.mqtt.MqttQoS; import io.vertx.core.Vertx; import io.vertx.core.VertxOptions; import io.vertx.mqtt.MqttAuth; import io.vertx.mqtt.MqttEndpoint; +import io.vertx.mqtt.MqttTopicSubscription; import java.time.LocalDateTime; +import java.util.List; import java.util.Objects; -import java.util.concurrent.ExecutionException; import lombok.Setter; import lombok.extern.slf4j.Slf4j; import me.hekr.iotos.softgateway.network.common.coder.PacketCoder; @@ -31,7 +33,7 @@ public class MqttServer { this(1883); } - public void start() throws ExecutionException, InterruptedException { + public void start() { Objects.requireNonNull(packetCoder, "packetCoder 必填"); Objects.requireNonNull(listener, "listener 必填"); VertxOptions options = new VertxOptions(); @@ -50,6 +52,7 @@ public class MqttServer { handlePublishMessage(endpoint); handleAuth(endpoint); handleException(endpoint); + handleSubscribe(endpoint); }); server .listen(1883, "localhost") @@ -63,17 +66,44 @@ public class MqttServer { }); } - private void handleException(MqttEndpoint endpoint) { - endpoint.exceptionHandler( - t -> { - log.error(t.getMessage(), t); + /** + * 订阅 topic 认证 + * + * @param endpoint 连接信息 + */ + private void handleSubscribe(MqttEndpoint endpoint) { + endpoint.subscribeHandler( + m -> { + ConnectionContext context = MqttConnections.get(endpoint); + List qosList = listener.aclSubTopic(context, m.topicSubscriptions()); + if (log.isDebugEnabled()) { + for (int i = 0; i < m.topicSubscriptions().size(); i++) { + MqttTopicSubscription topic = m.topicSubscriptions().get(i); + MqttQoS qos = qosList.get(i); + log.debug( + (qos == MqttQoS.FAILURE ? "不允许 " : "允许 ") + + context.getClientId() + + " 订阅 " + + topic.topicName() + + " qos:" + + topic.qualityOfService() + + " 协商 qos:" + + qos); + } + } + + endpoint.subscribeAcknowledge(m.messageId(), qosList); }); } + private void handleException(MqttEndpoint endpoint) { + endpoint.exceptionHandler(t -> log.error(t.getMessage(), t)); + } + /** * 处理关闭连接 * - * @param endpoint + * @param endpoint 连接信息 */ private void handleClose(MqttEndpoint endpoint) { endpoint.closeHandler(v -> listener.onClose(MqttConnections.remove(endpoint))); @@ -82,13 +112,27 @@ public class MqttServer { /** * 处理客户端发布的消息 * - * @param endpoint + * @param endpoint 连接信息 */ + @SuppressWarnings("unchecked") private void handlePublishMessage(MqttEndpoint endpoint) { endpoint.publishHandler( m -> { + ConnectionContext context = MqttConnections.get(endpoint); + boolean pass = listener.aclPubTopic(context, m.topicName(), m.qosLevel()); + if (!pass) { + if (log.isDebugEnabled()) { + log.debug( + "publish topic 拒绝,丢弃消息, clientId: {}, username: {}, topic: {}, qos:{}", + context.getClientId(), + context.getUsername(), + m.topicName(), + m.qosLevel()); + return; + } + } listener.onMessage( - MqttConnections.get(endpoint), + context, m.topicName(), m.qosLevel(), (T) packetCoder.decode(m.payload().getBytes()).getResult()); @@ -98,7 +142,7 @@ public class MqttServer { /** * 处理鉴权 * - * @param endpoint + * @param endpoint 连接信息 */ private void handleAuth(MqttEndpoint endpoint) { MqttAuth auth = endpoint.auth(); diff --git a/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/AbstractListenerAdapter.java b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/AbstractListenerAdapter.java index 7e82d48..dd22685 100644 --- a/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/AbstractListenerAdapter.java +++ b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/AbstractListenerAdapter.java @@ -1,6 +1,9 @@ package me.hekr.iotos.softgateway.network.mqtt.listener; import io.netty.handler.codec.mqtt.MqttQoS; +import io.vertx.mqtt.MqttTopicSubscription; +import java.util.List; +import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; import me.hekr.iotos.softgateway.network.mqtt.ConnectionContext; @@ -29,4 +32,21 @@ public abstract class AbstractListenerAdapter implements Listener { public void onClose(ConnectionContext context) { log.info("关闭连接,clientId:{}", context.getClientId()); } + + @Override + public boolean aclPubTopic(ConnectionContext context, String topicName, MqttQoS qosLevel) { + if (log.isDebugEnabled()) { + log.debug("publish acl,clientId:{}", context.getClientId()); + } + return true; + } + + @Override + public List aclSubTopic( + ConnectionContext context, List topicSubscriptions) { + // 默认允许所有订阅 + return topicSubscriptions.stream() + .map(MqttTopicSubscription::qualityOfService) + .collect(Collectors.toList()); + } } diff --git a/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/AcceptAllListenerAdapter.java b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/AcceptAllConnectionListenerAdapter.java similarity index 81% rename from framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/AcceptAllListenerAdapter.java rename to framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/AcceptAllConnectionListenerAdapter.java index 6bcf2ee..d848038 100644 --- a/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/AcceptAllListenerAdapter.java +++ b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/AcceptAllConnectionListenerAdapter.java @@ -5,7 +5,7 @@ import me.hekr.iotos.softgateway.network.mqtt.ConnectionContext; /** @author iotos */ @Slf4j -public class AcceptAllListenerAdapter extends AbstractListenerAdapter { +public class AcceptAllConnectionListenerAdapter extends AbstractListenerAdapter { @Override public boolean auth(ConnectionContext context) { diff --git a/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/Listener.java b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/Listener.java index 1308524..048e1af 100644 --- a/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/Listener.java +++ b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/Listener.java @@ -1,6 +1,8 @@ package me.hekr.iotos.softgateway.network.mqtt.listener; import io.netty.handler.codec.mqtt.MqttQoS; +import io.vertx.mqtt.MqttTopicSubscription; +import java.util.List; import me.hekr.iotos.softgateway.network.mqtt.ConnectionContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,4 +52,26 @@ public interface Listener { * @return */ boolean auth(ConnectionContext context); + + /** + * publish topic acl + * + * @param context + * @param topicName + * @param qosLevel + * @return true 允许发布,会进入消息回调;false 不会进入消息回调 + */ + boolean aclPubTopic(ConnectionContext context, String topicName, MqttQoS qosLevel); + + /** + * 客户端订阅 topic 权限 + * + *

返回的 topic 列表个数要一致,可以根据 clientId 等信息进行判断,赋予不同的 client 不同订阅权限。如果拒绝返回 FAILURE + * + * @param context + * @param topicSubscriptions 订阅的 topic + * @return 对应的订阅的 topic 信息 + */ + List aclSubTopic( + ConnectionContext context, List topicSubscriptions); } diff --git a/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/RejectAllListenerAdapter.java b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/RejectAllConnectionListenerAdapter.java similarity index 82% rename from framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/RejectAllListenerAdapter.java rename to framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/RejectAllConnectionListenerAdapter.java index eb12b11..b179110 100644 --- a/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/RejectAllListenerAdapter.java +++ b/framework-network-mqtt/src/main/java/me/hekr/iotos/softgateway/network/mqtt/listener/RejectAllConnectionListenerAdapter.java @@ -5,7 +5,7 @@ import me.hekr.iotos.softgateway.network.mqtt.ConnectionContext; /** @author iotos */ @Slf4j -public class RejectAllListenerAdapter extends AbstractListenerAdapter { +public class RejectAllConnectionListenerAdapter extends AbstractListenerAdapter { @Override public boolean auth(ConnectionContext context) { -- Gitee From e6500e9b793e37d0c8b91fa68a3d1234e41fb4c9 Mon Sep 17 00:00:00 2001 From: sdvdxl Date: Fri, 14 May 2021 15:33:44 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: sdvdxl --- deploy.sh | 4 +- example/pom.xml | 6 +- framework-common-utils/pom.xml | 2 +- .../softgateway/common/utils/MapUtil.java | 45 ------ .../softgateway/common/utils/ParseUtil.java | 18 ++- .../softgateway/common/utils/SignUtil.java | 24 --- framework-core/pom.xml | 7 +- .../softgateway/core/config/IotOsConfig.java | 9 +- .../softgateway/core/dto/DeviceMapper.java | 2 +- .../iotos/softgateway/core/enums/Action.java | 2 +- .../core/exception/HttpResponseException.java | 14 -- .../softgateway/core/klink/DevSendResp.java | 1 - .../softgateway/core/klink/KlinkService.java | 153 +++++++++++++++--- .../core/klink/processor/Processor.java | 2 - framework-network-common/pom.xml | 3 +- .../network/common/client/AbstractClient.java | 5 +- .../network/common/client/EventListener.java | 10 +- .../common/listener/MessageListener.java | 2 +- framework-network-mqtt/pom.xml | 4 +- framework-network-tcp/pom.xml | 5 +- .../softgateway/network/tcp/TcpServer.java | 2 +- .../network/tcp/listener/EventListener.java | 9 +- framework-network-udp/pom.xml | 5 +- pom.xml | 90 +++++++++-- 24 files changed, 246 insertions(+), 178 deletions(-) delete mode 100644 framework-common-utils/src/main/java/me/hekr/iotos/softgateway/common/utils/MapUtil.java delete mode 100644 framework-common-utils/src/main/java/me/hekr/iotos/softgateway/common/utils/SignUtil.java delete mode 100644 framework-core/src/main/java/me/hekr/iotos/softgateway/core/exception/HttpResponseException.java diff --git a/deploy.sh b/deploy.sh index 0785901..dde7578 100755 --- a/deploy.sh +++ b/deploy.sh @@ -3,11 +3,11 @@ # ./deploy deploy 生成 maven jar包 # ./deploy upload 生成 maven jar 包并 commit -VERSION="3.1.0-SNAPSHOT" +VERSION="3.1.0" echo "版本号:$VERSION" updateVersion(){ - mvn versions:set -DnewVersion=$VERSION versions:update-child-modules + mvn versions:set -DnewVersion=$VERSION versions:update-child-modules versions:update-properties } act=$1 diff --git a/example/pom.xml b/example/pom.xml index 599130d..fcb1924 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -5,12 +5,11 @@ iotos-soft-gateway me.hekr.iotos.softgateway - 3.1.0-SNAPSHOT + 3.1.0 8 8 - 3.1.0-SNAPSHOT 4.0.0 @@ -19,17 +18,14 @@ me.hekr.iotos.softgateway framework-network-tcp - ${iotos.softgateway.version} me.hekr.iotos.softgateway framework-network-udp - ${iotos.softgateway.version} me.hekr.iotos.softgateway framework-network-mqtt - ${iotos.softgateway.version} diff --git a/framework-common-utils/pom.xml b/framework-common-utils/pom.xml index a8c65c8..06dba71 100644 --- a/framework-common-utils/pom.xml +++ b/framework-common-utils/pom.xml @@ -5,7 +5,7 @@ iotos-soft-gateway me.hekr.iotos.softgateway - 3.1.0-SNAPSHOT + 3.1.0 4.0.0 diff --git a/framework-common-utils/src/main/java/me/hekr/iotos/softgateway/common/utils/MapUtil.java b/framework-common-utils/src/main/java/me/hekr/iotos/softgateway/common/utils/MapUtil.java deleted file mode 100644 index 6fac5b0..0000000 --- a/framework-common-utils/src/main/java/me/hekr/iotos/softgateway/common/utils/MapUtil.java +++ /dev/null @@ -1,45 +0,0 @@ -package me.hekr.iotos.softgateway.common.utils; - -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; - -public class MapUtil { - /** - * @Title: objectToMap @Description: 将object转换为map,默认不保留空值 - * - * @param @param obj - * @return Map 返回类型 - * @throws - */ - public static Map objectToMap(Object obj) { - - Map map = new HashMap(); - map = objectToMap(obj, false); - return map; - } - - public static Map objectToMap(Object obj, boolean keepNullVal) { - if (obj == null) { - return null; - } - - Map map = new HashMap(); - try { - Field[] declaredFields = obj.getClass().getDeclaredFields(); - for (Field field : declaredFields) { - field.setAccessible(true); - if (keepNullVal) { - map.put(field.getName(), field.get(obj)); - } else { - if (field.get(obj) != null && !"".equals(field.get(obj).toString())) { - map.put(field.getName(), field.get(obj)); - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - return map; - } -} diff --git a/framework-common-utils/src/main/java/me/hekr/iotos/softgateway/common/utils/ParseUtil.java b/framework-common-utils/src/main/java/me/hekr/iotos/softgateway/common/utils/ParseUtil.java index 251cd9a..1869221 100644 --- a/framework-common-utils/src/main/java/me/hekr/iotos/softgateway/common/utils/ParseUtil.java +++ b/framework-common-utils/src/main/java/me/hekr/iotos/softgateway/common/utils/ParseUtil.java @@ -8,8 +8,16 @@ import javax.crypto.spec.SecretKeySpec; public class ParseUtil { /** hash加密方法 */ public static final String HASH_METHOD = "HmacSHA1"; - /** sign值计算 */ - public static byte[] HmacSHA1Encrypt(String encryptText, String encryptKey) throws Exception { + + /** + * sign值计算 + * + * @param encryptText 要哈希的值 + * @param encryptKey key + * @return 哈希后的字节数组 + * @throws Exception 异常 + */ + public static byte[] hmacSHA1Encrypt(String encryptText, String encryptKey) throws Exception { byte[] data = encryptKey.getBytes(); // 根据给定的字节数组构造一个密钥,第二参数指定一个密钥算法的名称 SecretKey secretKey = new SecretKeySpec(data, HASH_METHOD); @@ -29,9 +37,9 @@ public class ParseUtil { return null; } - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < buf.length; i++) { - String hex = Integer.toHexString(buf[i] & 0xFF); + StringBuilder sb = new StringBuilder(); + for (byte b : buf) { + String hex = Integer.toHexString(b & 0xFF); if (hex.length() == 1) { hex = '0' + hex; } diff --git a/framework-common-utils/src/main/java/me/hekr/iotos/softgateway/common/utils/SignUtil.java b/framework-common-utils/src/main/java/me/hekr/iotos/softgateway/common/utils/SignUtil.java deleted file mode 100644 index 88b305e..0000000 --- a/framework-common-utils/src/main/java/me/hekr/iotos/softgateway/common/utils/SignUtil.java +++ /dev/null @@ -1,24 +0,0 @@ -package me.hekr.iotos.softgateway.common.utils; - -/** - * @author iotos - * @date 2020/7/29 - */ -public class SignUtil { - public static String getSignature(String timeStamp, String nonce, String tokenKey, String data) { - String s = data.replaceAll("=", "").replaceAll("&", ""); - // 拼接签名数据 - String signStr = timeStamp + nonce + tokenKey + s; - byte[] bytes = signStr.getBytes(); - return dataSummary(bytes); - } - - private static String dataSummary(byte[] sourceBytes) { - // 简单求和 - byte resultByte = 0x00; - for (byte sourceByte : sourceBytes) { - resultByte += sourceByte; - } - return ParseUtil.parseByte2HexStr(new byte[] {resultByte}); - } -} diff --git a/framework-core/pom.xml b/framework-core/pom.xml index 0057836..5960932 100644 --- a/framework-core/pom.xml +++ b/framework-core/pom.xml @@ -5,7 +5,7 @@ iotos-soft-gateway me.hekr.iotos.softgateway - 3.1.0-SNAPSHOT + 3.1.0 4.0.0 jar @@ -32,10 +32,6 @@ org.springframework.boot spring-boot-starter - - org.springframework - spring-web - org.springframework.boot @@ -52,7 +48,6 @@ me.hekr.iotos.softgateway framework-common-utils - 3.1.0-SNAPSHOT diff --git a/framework-core/src/main/java/me/hekr/iotos/softgateway/core/config/IotOsConfig.java b/framework-core/src/main/java/me/hekr/iotos/softgateway/core/config/IotOsConfig.java index 20fa068..8f345c2 100644 --- a/framework-core/src/main/java/me/hekr/iotos/softgateway/core/config/IotOsConfig.java +++ b/framework-core/src/main/java/me/hekr/iotos/softgateway/core/config/IotOsConfig.java @@ -5,14 +5,12 @@ import lombok.Getter; import lombok.SneakyThrows; import me.hekr.iotos.softgateway.common.utils.ParseUtil; import me.hekr.iotos.softgateway.core.constant.Constants; +import org.apache.commons.codec.binary.Hex; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -/** - * @author iotos - * @date 2020/7/9 - */ +/** @author iotos */ @ComponentScan("me.hekr.iotos.softgateway.core") @Configuration public class IotOsConfig { @@ -57,7 +55,6 @@ public class IotOsConfig { @SneakyThrows private String getPassword(String pk, String devId, String devSecret, String random) { - return ParseUtil.parseByte2HexStr( - (ParseUtil.HmacSHA1Encrypt(pk + devId + devId + random, devSecret))); + return Hex.encodeHexString((ParseUtil.hmacSHA1Encrypt(pk + devId + devId + random, devSecret))); } } diff --git a/framework-core/src/main/java/me/hekr/iotos/softgateway/core/dto/DeviceMapper.java b/framework-core/src/main/java/me/hekr/iotos/softgateway/core/dto/DeviceMapper.java index c207849..d56bc6d 100644 --- a/framework-core/src/main/java/me/hekr/iotos/softgateway/core/dto/DeviceMapper.java +++ b/framework-core/src/main/java/me/hekr/iotos/softgateway/core/dto/DeviceMapper.java @@ -10,7 +10,7 @@ public interface DeviceMapper { /** * 获取映射关系的属性 * - * @return + * @return 自定义属性 */ @Transient @JsonIgnore diff --git a/framework-core/src/main/java/me/hekr/iotos/softgateway/core/enums/Action.java b/framework-core/src/main/java/me/hekr/iotos/softgateway/core/enums/Action.java index 8ffbc67..7980db7 100644 --- a/framework-core/src/main/java/me/hekr/iotos/softgateway/core/enums/Action.java +++ b/framework-core/src/main/java/me/hekr/iotos/softgateway/core/enums/Action.java @@ -128,7 +128,7 @@ public enum Action { /** * 返回相对应的action * - * @return + * @return 返回对应的配对,如果是请求,则返回 Resp;如果是 Resp,则返回请求。找不到返回自身 */ public Action getPair() { if (isResp()) { diff --git a/framework-core/src/main/java/me/hekr/iotos/softgateway/core/exception/HttpResponseException.java b/framework-core/src/main/java/me/hekr/iotos/softgateway/core/exception/HttpResponseException.java deleted file mode 100644 index 8bbb17e..0000000 --- a/framework-core/src/main/java/me/hekr/iotos/softgateway/core/exception/HttpResponseException.java +++ /dev/null @@ -1,14 +0,0 @@ -package me.hekr.iotos.softgateway.core.exception; - -/** - * @author iotos - * @date 2020/7/20 - */ -public class HttpResponseException extends RuntimeException { - private final int code; - - public HttpResponseException(int code, String msg) { - super(msg); - this.code = code; - } -} diff --git a/framework-core/src/main/java/me/hekr/iotos/softgateway/core/klink/DevSendResp.java b/framework-core/src/main/java/me/hekr/iotos/softgateway/core/klink/DevSendResp.java index eca3698..fb2e6f8 100644 --- a/framework-core/src/main/java/me/hekr/iotos/softgateway/core/klink/DevSendResp.java +++ b/framework-core/src/main/java/me/hekr/iotos/softgateway/core/klink/DevSendResp.java @@ -6,7 +6,6 @@ import me.hekr.iotos.softgateway.core.enums.Action; * 设备发送回复
* * @author iotos
- * @date 2020/7/21 16:08
*/ public class DevSendResp extends KlinkResp { diff --git a/framework-core/src/main/java/me/hekr/iotos/softgateway/core/klink/KlinkService.java b/framework-core/src/main/java/me/hekr/iotos/softgateway/core/klink/KlinkService.java index ca4dd44..e9b7a89 100644 --- a/framework-core/src/main/java/me/hekr/iotos/softgateway/core/klink/KlinkService.java +++ b/framework-core/src/main/java/me/hekr/iotos/softgateway/core/klink/KlinkService.java @@ -15,28 +15,43 @@ import me.hekr.iotos.softgateway.core.dto.DeviceMapper; import me.hekr.iotos.softgateway.core.enums.Action; import me.hekr.iotos.softgateway.core.enums.ErrorCode; import me.hekr.iotos.softgateway.core.network.mqtt.MqttService; +import org.apache.commons.codec.binary.Hex; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** - * Title:Server 这是发送消息的服务端 配置数据平台相关参数,可执行设备上报数据至平台以及平台下发数据至设备 Description: - * 服务器向多个客户端推送主题,即不同客户端可向服务器订阅相同主题 此为模拟烟雾传感器连接至智慧消防平台,并且其与IoTOS平台进行交互的代码 - * 添加设备和配置流程详情请见《设备连接软网关数据上报说明书》 + * 这是发送消息的服务端 配置数据平台相关参数,可执行设备上报数据至平台以及平台下发数据至设备 Description: 服务器向多个客户端推送主题,即不同客户端可向服务器订阅相同主题 + * 此为模拟烟雾传感器连接至智慧消防平台,并且其与IoTOS平台进行交互的代码 添加设备和配置流程详情请见《设备连接软网关数据上报说明书》 * * @author iotos */ +@SuppressWarnings("ALL") @Slf4j @Service public class KlinkService { @Autowired private IotOsConfig iotOsConfig; @Autowired private MqttService mqttService; - /** 动态注册设备 */ + + /** + * 动态注册设备 + * + * @param pk pk + * @param devId devId + * @param devName 设备名字 可以为空 + */ @SneakyThrows public void register(String pk, String devId, String devName) { register(pk, devId, null, devName); } - /** 动态注册设备 */ + /** + * 动态注册设备 + * + * @param pk pk + * @param devId pk + * @param productSecret 产品密钥 + * @param devName 设备名字 可以为空 + */ @SneakyThrows public void register(String pk, String devId, String productSecret, String devName) { doRegister(pk, devId, productSecret, devName); @@ -52,36 +67,62 @@ public class KlinkService { register.setRandom(Constants.RANDOM); register.setHashMethod(ParseUtil.HASH_METHOD); register.setSign( - ParseUtil.parseByte2HexStr( - ParseUtil.HmacSHA1Encrypt(pk + productSecret + Constants.RANDOM, productSecret))); + Hex.encodeHexString( + ParseUtil.hmacSHA1Encrypt(pk + productSecret + Constants.RANDOM, productSecret))); } mqttService.publish(register); } - /** 注册设备并添加拓扑 */ + /** + * 注册设备并添加拓扑 + * + *

设备名字默认为空 + * + * @param pk pk + * @param devId devId + */ @SneakyThrows public void addDev(String pk, String devId) { addDev(pk, devId, null); } - /** 注册设备并添加拓扑关系 */ + /** + * 注册设备并添加拓扑关系 + * + * @param pk pk + * @param devId devId + * @param devName 设备名字,可以为空 + */ @SneakyThrows - public void addDev(String pk, String devId, String name) { - addDev(pk, null, devId, null, name); + public void addDev(String pk, String devId, String devName) { + addDev(pk, null, devId, null, devName); } - /** 添加拓扑 */ + /** + * 添加拓扑 + * + * @param pk pk + * @param devId devId + */ @SneakyThrows public void addTopo(String pk, String devId) { doAddTopo(pk, devId, null); } - /** 注册设备并添加拓扑关系 */ + /** + * 注册设备并添加拓扑关系 + * + * @param pk pk + * @param productSecret 产品密钥 + * @param devId devId + * @param devSecret 设备密钥 + * @param devName 设备名字 + */ @SneakyThrows public void addDev( - String pk, String productSecret, String devId, String subDevSecret, String name) { - register(pk, devId, productSecret, name); - doAddTopo(pk, devId, subDevSecret); + String pk, String productSecret, String devId, String devSecret, String devName) { + register(pk, devId, productSecret, devName); + doAddTopo(pk, devId, devSecret); } private void doAddTopo(String pk, String devId, String subDevSecret) throws Exception { @@ -93,8 +134,8 @@ public class KlinkService { topoSub.setHashMethod(ParseUtil.HASH_METHOD); topoSub.setRandom(Constants.RANDOM); topoSub.setSign( - ParseUtil.parseByte2HexStr( - ParseUtil.HmacSHA1Encrypt( + Hex.encodeHexString( + ParseUtil.hmacSHA1Encrypt( pk + devId + subDevSecret + Constants.RANDOM, subDevSecret))); } addTopo.setSub(topoSub); @@ -104,7 +145,12 @@ public class KlinkService { mqttService.publish(addTopo); } - /** 设备上线 */ + /** + * 设备上线 + * + * @param pk pk + * @param devId devId + */ @SneakyThrows public void devLogin(String pk, String devId) { doDevLogin(pk, devId); @@ -117,7 +163,12 @@ public class KlinkService { mqttService.publish(devLogin); } - /** 设备离线 */ + /** + * 设备离线 + * + * @param pk pk + * @param devId devId + */ @SneakyThrows public void devLogout(String pk, String devId) { doDevLogout(pk, devId); @@ -143,7 +194,12 @@ public class KlinkService { mqttService.publish(getTopo); } - /** 删除子设备拓扑关系 */ + /** + * 删除子设备拓扑关系 + * + * @param pk pk + * @param devId devId + */ @SneakyThrows public void delDev(String pk, String devId) { DelTopo delTopo = new DelTopo(); @@ -157,7 +213,14 @@ public class KlinkService { mqttService.publish(delTopo); } - /** 设备发送数据 */ + /** + * 设备发送数据 + * + * @param pk pk + * @param devId devId + * @param cmd 命令 + * @param params 参数 + */ @SneakyThrows public void devSend(String pk, String devId, String cmd, Map params) { ModelData modelData = new ModelData(); @@ -170,6 +233,9 @@ public class KlinkService { * 设备发送数据 * *

如果找不到 mapper,则打印日志,不会真实发送数据 + * + * @param mapper 设备 + * @param klink klink */ @SneakyThrows public void sendKlink(DeviceMapper mapper, KlinkDev klink) { @@ -183,18 +249,35 @@ public class KlinkService { mqttService.publish(klink); } - /** 发送数据,比较底层的发送方法,需要自己构造 klink */ + /** + * 发送数据,比较底层的发送方法,需要自己构造 klink + * + * @param klink klink + */ @SneakyThrows public void sendKlink(KlinkDev klink) { mqttService.publish(klink); } - /** 设备发送数据, 没有参数,只有命令 */ + /** + * 设备发送数据, 没有参数,只有命令 + * + * @param pk pk + * @param devId devId + * @param cmd 命令 + */ @SneakyThrows public void devSend(String pk, String devId, String cmd) { devSend(pk, devId, cmd, null); } + /** + * 设备发送数据 + * + * @param pk pk + * @param devId devId + * @param data 物模型数据 + */ public void devSend(String pk, String devId, ModelData data) { DevSend kLink = new DevSend(); kLink.setPk(pk); @@ -230,6 +313,11 @@ public class KlinkService { devSend(dev.getPk(), dev.getDevId(), data); } + /** + * 设备登录 + * + * @param mapper 设备 + */ public void devLogin(DeviceMapper mapper) { Optional devMapper = getDeviceMapper(mapper); if (!devMapper.isPresent()) { @@ -245,7 +333,7 @@ public class KlinkService { * *

如果找不到 mapper,则打印日志,不会真实发送数据 * - * @param mapper + * @param mapper 设备 */ public void devLogout(DeviceMapper mapper) { Optional devMapper = getDeviceMapper(mapper); @@ -260,7 +348,7 @@ public class KlinkService { * 获取设备映射 * * @param mapper 设备关系 - * @return + * @return 设备配置 */ private Optional getDeviceMapper(DeviceMapper mapper) { Props props = mapper.getProps(); @@ -273,6 +361,13 @@ public class KlinkService { return subsystemDev; } + /** + * 发送控制设备回复 + * + * @param mapper 设备 + * @param code 错误码 0 成功; 错误定义其他,1000以上 + * @param desc 错误描述 + */ public void sendCloudSendResp(DeviceMapper mapper, int code, String desc) { KlinkResp resp = new KlinkResp(); resp.setCode(code); @@ -281,6 +376,12 @@ public class KlinkService { sendKlink(mapper, resp); } + /** + * 发送控制设备回复 + * + * @param mapper 设备 + * @param errorCode 错误码 + */ public void sendCloudSendResp(DeviceMapper mapper, ErrorCode errorCode) { sendCloudSendResp(mapper, errorCode.getCode(), errorCode.getDesc()); } diff --git a/framework-core/src/main/java/me/hekr/iotos/softgateway/core/klink/processor/Processor.java b/framework-core/src/main/java/me/hekr/iotos/softgateway/core/klink/processor/Processor.java index 4e0f7e3..6699099 100644 --- a/framework-core/src/main/java/me/hekr/iotos/softgateway/core/klink/processor/Processor.java +++ b/framework-core/src/main/java/me/hekr/iotos/softgateway/core/klink/processor/Processor.java @@ -14,8 +14,6 @@ public interface Processor { *

如果处理成功,并且klinkResp,主动设置了pk和devId,则不会被重置为req信息,并且 deviceRequest 的 pk和devId也会设置为klinkResp中的信息。 * * @param klink klink json object 格式数据 如:{"action":"devSend","msgId":1,xx:xx} - * @return 如果没有特殊返回消息,可以返回null; 如果要自定义返回消息,则需要返回不为null的实体;其中返回值 outMessage - * 中的的pk,devId,action,msgId不受自定义返回影响,都是processManager统一处理。 */ void handle(T klink); diff --git a/framework-network-common/pom.xml b/framework-network-common/pom.xml index 4b60014..cdf6749 100644 --- a/framework-network-common/pom.xml +++ b/framework-network-common/pom.xml @@ -5,7 +5,7 @@ iotos-soft-gateway me.hekr.iotos.softgateway - 3.1.0-SNAPSHOT + 3.1.0 4.0.0 @@ -24,7 +24,6 @@ me.hekr.iotos.softgateway framework-common-utils - 3.1.0-SNAPSHOT \ No newline at end of file diff --git a/framework-network-common/src/main/java/me/hekr/iotos/softgateway/network/common/client/AbstractClient.java b/framework-network-common/src/main/java/me/hekr/iotos/softgateway/network/common/client/AbstractClient.java index 20023c4..7d93230 100644 --- a/framework-network-common/src/main/java/me/hekr/iotos/softgateway/network/common/client/AbstractClient.java +++ b/framework-network-common/src/main/java/me/hekr/iotos/softgateway/network/common/client/AbstractClient.java @@ -39,7 +39,7 @@ public abstract class AbstractClient { /** * 是不是同步;true 同步模式,即发送消息后等待数据返回 * - * @see #setTimeout(int) 超时时间 + *

参考 {@code AbstractClient#setTimeout(int) } 超时时间 */ @Setter protected boolean sync; @@ -147,7 +147,8 @@ public abstract class AbstractClient { * *

如果设置sync 为 true,会等待返回数据 * - * @throws TimeoutException sync 为 true,等待超时 + * @param t 消息 + *

sync 为 true,等待超时,超时会抛出 {@code TimeoutException} * @return sync 为 true 返回 response 数据,否则 null */ @SneakyThrows diff --git a/framework-network-common/src/main/java/me/hekr/iotos/softgateway/network/common/client/EventListener.java b/framework-network-common/src/main/java/me/hekr/iotos/softgateway/network/common/client/EventListener.java index 945b254..4c789d3 100644 --- a/framework-network-common/src/main/java/me/hekr/iotos/softgateway/network/common/client/EventListener.java +++ b/framework-network-common/src/main/java/me/hekr/iotos/softgateway/network/common/client/EventListener.java @@ -14,14 +14,14 @@ public interface EventListener { /** * 客户端与服务端建立连接 * - * @param ctx + * @param ctx 上下文 */ void onConnect(PacketContext ctx); /** * 客户端与服务端断开连接 * - * @param ctx + * @param ctx 上下文 * @param reason 关闭连接原因 */ void onDisconnect(PacketContext ctx, CloseReason reason); @@ -29,7 +29,7 @@ public interface EventListener { /** * * 客户端不活跃(超过了设定的心跳超时时间) * - * @param ctx + * @param ctx 上下文 * @param lastOccurTime 上次发生时间,如果是第一次,则为 null * @param count 连续发生次数,如果有数据进来就会被重置为0开始 */ @@ -38,8 +38,8 @@ public interface EventListener { /** * 异常处理 * - * @param ctx - * @param t + * @param ctx 上下文 + * @param t Throwable */ void exceptionCaught(PacketContext ctx, Throwable t); } diff --git a/framework-network-common/src/main/java/me/hekr/iotos/softgateway/network/common/listener/MessageListener.java b/framework-network-common/src/main/java/me/hekr/iotos/softgateway/network/common/listener/MessageListener.java index b3e024e..eae3814 100644 --- a/framework-network-common/src/main/java/me/hekr/iotos/softgateway/network/common/listener/MessageListener.java +++ b/framework-network-common/src/main/java/me/hekr/iotos/softgateway/network/common/listener/MessageListener.java @@ -8,7 +8,7 @@ public interface MessageListener> { /** * 收到消息 * - * @param ctx + * @param ctx 上下文 */ void onMessage(T ctx); } diff --git a/framework-network-mqtt/pom.xml b/framework-network-mqtt/pom.xml index 430fb52..00b9a69 100644 --- a/framework-network-mqtt/pom.xml +++ b/framework-network-mqtt/pom.xml @@ -5,7 +5,7 @@ iotos-soft-gateway me.hekr.iotos.softgateway - 3.1.0-SNAPSHOT + 3.1.0 4.0.0 @@ -25,7 +25,7 @@ me.hekr.iotos.softgateway framework-network-common - 3.1.0-SNAPSHOT + 3.1.0 \ No newline at end of file diff --git a/framework-network-tcp/pom.xml b/framework-network-tcp/pom.xml index 81989f9..53b25ca 100644 --- a/framework-network-tcp/pom.xml +++ b/framework-network-tcp/pom.xml @@ -5,12 +5,12 @@ iotos-soft-gateway me.hekr.iotos.softgateway - 3.1.0-SNAPSHOT + 3.1.0 4.0.0 framework-network-tcp - 3.1.0-SNAPSHOT + 3.1.0 8 @@ -21,7 +21,6 @@ me.hekr.iotos.softgateway framework-network-common - 3.1.0-SNAPSHOT diff --git a/framework-network-tcp/src/main/java/me/hekr/iotos/softgateway/network/tcp/TcpServer.java b/framework-network-tcp/src/main/java/me/hekr/iotos/softgateway/network/tcp/TcpServer.java index 9efaad8..6855f76 100644 --- a/framework-network-tcp/src/main/java/me/hekr/iotos/softgateway/network/tcp/TcpServer.java +++ b/framework-network-tcp/src/main/java/me/hekr/iotos/softgateway/network/tcp/TcpServer.java @@ -63,7 +63,7 @@ public class TcpServer { /** * 设置心跳超时时间,毫秒 * - * @param timeout + * @param timeout 时间,毫秒 */ public void setHeartbeatTimeout(int timeout) { this.timeout = timeout; diff --git a/framework-network-tcp/src/main/java/me/hekr/iotos/softgateway/network/tcp/listener/EventListener.java b/framework-network-tcp/src/main/java/me/hekr/iotos/softgateway/network/tcp/listener/EventListener.java index 3ff6418..799117c 100644 --- a/framework-network-tcp/src/main/java/me/hekr/iotos/softgateway/network/tcp/listener/EventListener.java +++ b/framework-network-tcp/src/main/java/me/hekr/iotos/softgateway/network/tcp/listener/EventListener.java @@ -21,16 +21,15 @@ public interface EventListener { /** * 客户端与服务端断开连接 * - * @param ctx + * @param ctx 上下文 * @param reason 关闭连接原因 - * @param t 异常关闭时候的异常 */ void onDisconnect(TcpServerPacketContext ctx, CloseReason reason); /** * * 客户端不活跃(超过了设定的心跳超时时间) * - * @param ctx + * @param ctx 上下文 * @param lastOccurTime 上次发生时间,如果是第一次,则为 null * @param count 连续发生次数,如果有数据进来就会被重置为0开始 */ @@ -39,8 +38,8 @@ public interface EventListener { /** * 异常处理 * - * @param ctx - * @param t + * @param ctx 上下文 + * @param t Throwable */ void exceptionCaught(TcpServerPacketContext ctx, Throwable t); } diff --git a/framework-network-udp/pom.xml b/framework-network-udp/pom.xml index 682faf0..269d009 100644 --- a/framework-network-udp/pom.xml +++ b/framework-network-udp/pom.xml @@ -5,12 +5,12 @@ iotos-soft-gateway me.hekr.iotos.softgateway - 3.1.0-SNAPSHOT + 3.1.0 4.0.0 framework-network-udp - 3.1.0-SNAPSHOT + 3.1.0 8 @@ -21,7 +21,6 @@ me.hekr.iotos.softgateway framework-network-common - 3.1.0-SNAPSHOT diff --git a/pom.xml b/pom.xml index 32701bc..614e970 100644 --- a/pom.xml +++ b/pom.xml @@ -17,16 +17,43 @@ me.hekr.iotos.softgateway iotos-soft-gateway - 3.1.0-SNAPSHOT - iotos-soft-gateway + 3.1.0 + ${project.groupId}:${project.artifactId} IoTOS 软网关 + https://gitee.com/geekhekr/iotos-soft-gateway 1.8 1.8 1.8 + UTF-8 + UTF-8 + UTF-8 + 3.1.0 + + + 木兰宽松许可证, 第2版 + https://license.coscl.org.cn/MulanPSL2/ + + + + + + sdvdxl + sdvdxl@163.com + hekr + https://hekr.me + + + + + scm:git:git://https://gitee.com/geekhekr/iotos-soft-gateway.git + scm:git:ssh://gitee.com:geekhekr/iotos-soft-gateway.git + https://gitee.com/geekhekr/iotos-soft-gateway + + @@ -34,6 +61,36 @@ netty-all 4.1.60.Final + + me.hekr.iotos.softgateway + framework-core + ${iotos.softgateway.version} + + + me.hekr.iotos.softgateway + framework-common-utils + ${iotos.softgateway.version} + + + me.hekr.iotos.softgateway + framework-network-udp + ${iotos.softgateway.version} + + + me.hekr.iotos.softgateway + framework-network-tcp + ${iotos.softgateway.version} + + + me.hekr.iotos.softgateway + framework-network-mqtt + ${iotos.softgateway.version} + + + me.hekr.iotos.softgateway + framework-network-common + ${iotos.softgateway.version} + @@ -91,19 +148,22 @@ - - - - - - - - - - - - - + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + + attach-javadocs + + jar + + + + + false + + org.apache.maven.plugins maven-gpg-plugin -- Gitee From 2402d2f62212ac4a7239a9a5d199e8e9f4598ce0 Mon Sep 17 00:00:00 2001 From: sdvdxl Date: Fri, 14 May 2021 16:23:43 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: sdvdxl --- deploy.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/deploy.sh b/deploy.sh index dde7578..bc9e49c 100755 --- a/deploy.sh +++ b/deploy.sh @@ -14,12 +14,10 @@ act=$1 deploy() { updateVersion - rm -rf maven - mvn clean deploy -DskipTests=true -DaltDeploymentRepository=hekr-maven::default::file:maven/repository/ - - echo "发布位置:maven/repository" + mvn deploy } + install() { updateVersion mvn clean install -DskipTests=true -- Gitee From 71d610c77ed0571a49710d89d95cb7ab3080b7aa Mon Sep 17 00:00:00 2001 From: sdvdxl Date: Fri, 14 May 2021 16:27:43 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9pom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 614e970..f3c2209 100644 --- a/pom.xml +++ b/pom.xml @@ -23,9 +23,9 @@ https://gitee.com/geekhekr/iotos-soft-gateway - 1.8 - 1.8 - 1.8 + 8 + 8 + 8 UTF-8 UTF-8 UTF-8 -- Gitee