Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
device-new-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
device-new-platform
Commits
dd8c1191
Commit
dd8c1191
authored
Jun 22, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改udp 加密解密
parent
5113c16d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
6 deletions
+21
-6
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
...n/java/com/mortals/xhx/busiz/web/DeviceApiController.java
+13
-1
device-manager/src/main/java/com/mortals/xhx/common/key/Constant.java
...er/src/main/java/com/mortals/xhx/common/key/Constant.java
+1
-0
device-manager/src/main/java/com/mortals/xhx/daemon/netty/server/controlserver/handler/NettyUDPServerHandler.java
...y/server/controlserver/handler/NettyUDPServerHandler.java
+3
-3
doc/api.md
doc/api.md
+4
-2
No files found.
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
View file @
dd8c1191
...
@@ -22,6 +22,7 @@ import com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders;
...
@@ -22,6 +22,7 @@ import com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders;
import
com.mortals.xhx.common.model.MessageHeader
;
import
com.mortals.xhx.common.model.MessageHeader
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.common.utils.DownMsgTask
;
import
com.mortals.xhx.common.utils.DownMsgTask
;
import
com.mortals.xhx.common.utils.EncryptUtil
;
import
com.mortals.xhx.common.utils.SendTaskThreadPool
;
import
com.mortals.xhx.common.utils.SendTaskThreadPool
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
com.mortals.xhx.module.device.service.DeviceService
;
...
@@ -46,6 +47,9 @@ import java.util.Date;
...
@@ -46,6 +47,9 @@ import java.util.Date;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
Constant
.
DES_STR
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
Constant
.
ENCRYPT_STR
;
/**
/**
* 设备
* 设备
*
*
...
@@ -124,7 +128,12 @@ public class DeviceApiController {
...
@@ -124,7 +128,12 @@ public class DeviceApiController {
authInfo
.
setUploadTopicFilter
(
Constant
.
UPLOAD_TOPIC
+
deviceEntity
.
getDeviceCode
());
authInfo
.
setUploadTopicFilter
(
Constant
.
UPLOAD_TOPIC
+
deviceEntity
.
getDeviceCode
());
authInfo
.
setDownTopicFilter
(
Constant
.
DOWN_TOPIC
+
deviceEntity
.
getDeviceCode
());
authInfo
.
setDownTopicFilter
(
Constant
.
DOWN_TOPIC
+
deviceEntity
.
getDeviceCode
());
authInfo
.
setHomeUrl
(
platformEntity
.
getHomeUrl
());
authInfo
.
setHomeUrl
(
platformEntity
.
getHomeUrl
());
String
content
=
AESUtil
.
encryptForApp
(
JSON
.
toJSONString
(
authInfo
),
secret
);
// String content = AESUtil.encryptForApp(JSON.toJSONString(authInfo), secret);
String
content
=
EncryptUtil
.
myEnscrt
(
JSON
.
toJSONString
(
authInfo
),
9
,
DES_STR
,
ENCRYPT_STR
);
deviceResp
.
setContent
(
content
);
deviceResp
.
setContent
(
content
);
deviceEntity
.
setOnlineTime
(
new
Date
());
deviceEntity
.
setOnlineTime
(
new
Date
());
deviceEntity
.
setDeviceOnlineStatus
(
DeviceOnlineStatusEnum
.
在线
.
getValue
());
deviceEntity
.
setDeviceOnlineStatus
(
DeviceOnlineStatusEnum
.
在线
.
getValue
());
...
@@ -461,6 +470,9 @@ public class DeviceApiController {
...
@@ -461,6 +470,9 @@ public class DeviceApiController {
}
}
private
DeviceEntity
checkDeviceExist
(
DeviceReq
req
)
{
private
DeviceEntity
checkDeviceExist
(
DeviceReq
req
)
{
if
(
ObjectUtils
.
isEmpty
(
req
.
getDeviceCode
()))
{
throw
new
AppException
(
"当前设备编码不存在!"
);
}
DeviceEntity
deviceEntity
=
deviceService
.
getExtCache
(
req
.
getDeviceCode
());
DeviceEntity
deviceEntity
=
deviceService
.
getExtCache
(
req
.
getDeviceCode
());
if
(
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
if
(
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
throw
new
AppException
(
"当前设备不存在!"
);
throw
new
AppException
(
"当前设备不存在!"
);
...
...
device-manager/src/main/java/com/mortals/xhx/common/key/Constant.java
View file @
dd8c1191
...
@@ -42,6 +42,7 @@ public final class Constant {
...
@@ -42,6 +42,7 @@ public final class Constant {
*/
*/
public
static
final
String
TOKEN
=
"token"
;
public
static
final
String
TOKEN
=
"token"
;
public
static
final
String
ENCRYPT_STR
=
"w4*KbUamPdZDnDpG"
;
public
static
final
String
ENCRYPT_STR
=
"w4*KbUamPdZDnDpG"
;
public
static
final
String
DES_STR
=
"FZV1D&tr"
;
public
static
final
Integer
SERVER_PORT
=
8074
;
public
static
final
Integer
SERVER_PORT
=
8074
;
public
static
final
Integer
CLIENT_PORT
=
8073
;
public
static
final
Integer
CLIENT_PORT
=
8073
;
...
...
device-manager/src/main/java/com/mortals/xhx/daemon/netty/server/controlserver/handler/NettyUDPServerHandler.java
View file @
dd8c1191
...
@@ -47,7 +47,7 @@ public class NettyUDPServerHandler extends SimpleChannelInboundHandler<DatagramP
...
@@ -47,7 +47,7 @@ public class NettyUDPServerHandler extends SimpleChannelInboundHandler<DatagramP
resp
.
setCode
(
YesNoEnum
.
YES
.
getValue
());
resp
.
setCode
(
YesNoEnum
.
YES
.
getValue
());
log
.
info
(
"receive->UDP entbefore:{}"
,
packet
.
sender
().
toString
()
+
","
+
content
);
log
.
info
(
"receive->UDP entbefore:{}"
,
packet
.
sender
().
toString
()
+
","
+
content
);
try
{
try
{
content
=
EncryptUtil
.
myReEnscrt
(
content
,
9
,
"FZV1D&tr"
,
ENCRYPT_STR
);
content
=
EncryptUtil
.
myReEnscrt
(
content
,
9
,
DES_STR
,
ENCRYPT_STR
);
//EncryptUtil.decrypt(content, ENCRYPT_STR);
//EncryptUtil.decrypt(content, ENCRYPT_STR);
log
.
info
(
"receive->UDPafter:{}"
,
packet
.
sender
().
toString
()
+
","
+
content
);
log
.
info
(
"receive->UDPafter:{}"
,
packet
.
sender
().
toString
()
+
","
+
content
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
content
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
content
);
...
@@ -56,7 +56,7 @@ public class NettyUDPServerHandler extends SimpleChannelInboundHandler<DatagramP
...
@@ -56,7 +56,7 @@ public class NettyUDPServerHandler extends SimpleChannelInboundHandler<DatagramP
resp
.
setMsg
(
"获取服务端地址成功!"
);
resp
.
setMsg
(
"获取服务端地址成功!"
);
if
(!
ObjectUtils
.
isEmpty
(
action
)
&&
"findserver"
.
equals
(
action
))
{
if
(!
ObjectUtils
.
isEmpty
(
action
)
&&
"findserver"
.
equals
(
action
))
{
String
URL
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_HTTP_URL
,
"http://192.168.0.98:110
21
"
);
String
URL
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_HTTP_URL
,
"http://192.168.0.98:110
71/m/api/register
"
);
resp
.
setData
(
URL
);
resp
.
setData
(
URL
);
}
else
{
}
else
{
resp
.
setCode
(
YesNoEnum
.
NO
.
getValue
());
resp
.
setCode
(
YesNoEnum
.
NO
.
getValue
());
...
@@ -64,7 +64,7 @@ public class NettyUDPServerHandler extends SimpleChannelInboundHandler<DatagramP
...
@@ -64,7 +64,7 @@ public class NettyUDPServerHandler extends SimpleChannelInboundHandler<DatagramP
}
}
InetSocketAddress
remoteAddress
=
new
InetSocketAddress
(
packet
.
sender
().
getHostName
(),
CLIENT_PORT
);
InetSocketAddress
remoteAddress
=
new
InetSocketAddress
(
packet
.
sender
().
getHostName
(),
CLIENT_PORT
);
String
sa
=
EncryptUtil
.
myEnscrt
(
JSON
.
toJSONString
(
resp
),
9
,
"FZV1D&tr"
,
ENCRYPT_STR
);
String
sa
=
EncryptUtil
.
myEnscrt
(
JSON
.
toJSONString
(
resp
),
9
,
DES_STR
,
ENCRYPT_STR
);
DatagramPacket
sendpacket
=
new
DatagramPacket
(
Unpooled
.
copiedBuffer
(
sa
,
CharsetUtil
.
UTF_8
),
remoteAddress
);
DatagramPacket
sendpacket
=
new
DatagramPacket
(
Unpooled
.
copiedBuffer
(
sa
,
CharsetUtil
.
UTF_8
),
remoteAddress
);
//ctx.writeAndFlush(new DatagramPacket(Unpooled.copiedBuffer(JSON.toJSONString(resp), CharsetUtil.UTF_8), packet.sender()));
//ctx.writeAndFlush(new DatagramPacket(Unpooled.copiedBuffer(JSON.toJSONString(resp), CharsetUtil.UTF_8), packet.sender()));
...
...
doc/api.md
View file @
dd8c1191
...
@@ -18,7 +18,9 @@ arrays|数组类型|[{"name":"zhang3"},{"name":"zhang2"}]
...
@@ -18,7 +18,9 @@ arrays|数组类型|[{"name":"zhang3"},{"name":"zhang2"}]
### 服务端地址获取
### 服务端地址获取
**广播端口:**
54321
**广播服务端口:**
8074
**广播客户端口:**
8073
**请求方式:**
UDP
**请求方式:**
UDP
...
@@ -55,7 +57,7 @@ data|String|数据对象|-
...
@@ -55,7 +57,7 @@ data|String|数据对象|-
{
{
"msg":"获取服务端地址成功",
"msg":"获取服务端地址成功",
"code":1,
"code":1,
"data":"http://192.168.0.98:110
21
"
"data":"http://192.168.0.98:110
71/m/api/register
"
}
}
```
```
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment