From 2591997dfc8995a788b07dd41f42aac77c6fc4fb Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期五, 12 八月 2022 10:00:18 +0800
Subject: [PATCH] 修复文档错误
---
src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java | 32 ++++++++++++++++++++++++++------
1 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java
index bdd1503..c24e0ca 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java
@@ -1,12 +1,15 @@
package com.genersoft.iot.vmp.conf;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
+import com.genersoft.iot.vmp.utils.DateUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;
-import java.text.SimpleDateFormat;
-import java.util.Date;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.regex.Pattern;
+
@Configuration("mediaConfig")
public class MediaConfig{
@@ -162,7 +165,18 @@
if (StringUtils.isEmpty(sdpIp)){
return ip;
}else {
- return sdpIp;
+ if (isValidIPAddress(sdpIp)) {
+ return sdpIp;
+ }else {
+ // 鎸夌収鍩熷悕瑙f瀽
+ String hostAddress = null;
+ try {
+ hostAddress = InetAddress.getByName(sdpIp).getHostAddress();
+ } catch (UnknownHostException e) {
+ throw new RuntimeException(e);
+ }
+ return hostAddress;
+ }
}
}
@@ -206,11 +220,17 @@
mediaServerItem.setRecordAssistPort(recordAssistPort);
mediaServerItem.setHookAliveInterval(120);
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- mediaServerItem.setCreateTime(format.format(System.currentTimeMillis()));
- mediaServerItem.setUpdateTime(format.format(System.currentTimeMillis()));
+ mediaServerItem.setCreateTime(DateUtil.getNow());
+ mediaServerItem.setUpdateTime(DateUtil.getNow());
return mediaServerItem;
}
+ private boolean isValidIPAddress(String ipAddress) {
+ if ((ipAddress != null) && (!ipAddress.isEmpty())) {
+ return Pattern.matches("^([1-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}$", ipAddress);
+ }
+ return false;
+ }
+
}
--
Gitblit v1.8.0