From 5599fe010a7e30ee6f41ed783bfbf7d516955ce5 Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Tue, 22 Aug 2023 02:12:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20logback=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=20=E6=8E=A7=E5=88=B6=20sip=20=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../skcks/docking/gb28181/config/sip/SipConfig.java | 1 - .../gb28181/core/sip/logger/StackLoggerImpl.java | 2 ++ .../core/sip/properties/DefaultProperties.java | 13 ++++--------- .../gb28181/core/sip/service/SipServiceImpl.java | 2 +- starter/src/main/resources/application.yml | 3 +++ starter/src/main/resources/logback.xml | 1 + .../docking/gb28181/test/MediaServiceTest.java | 5 ----- 7 files changed, 11 insertions(+), 16 deletions(-) diff --git a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/config/sip/SipConfig.java b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/config/sip/SipConfig.java index 782439a..1d60ef9 100644 --- a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/config/sip/SipConfig.java +++ b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/config/sip/SipConfig.java @@ -14,7 +14,6 @@ import java.util.List; @Order(0) @Data public class SipConfig { - private List ip; private List showIp; diff --git a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/logger/StackLoggerImpl.java b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/logger/StackLoggerImpl.java index 7117925..fd55803 100644 --- a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/logger/StackLoggerImpl.java +++ b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/logger/StackLoggerImpl.java @@ -1,6 +1,8 @@ package cn.skcks.docking.gb28181.core.sip.logger; +import cn.skcks.docking.gb28181.config.sip.SipConfig; import gov.nist.core.StackLogger; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/properties/DefaultProperties.java b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/properties/DefaultProperties.java index 80acbee..d9e1a77 100644 --- a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/properties/DefaultProperties.java +++ b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/properties/DefaultProperties.java @@ -11,7 +11,7 @@ import java.util.Properties; */ public class DefaultProperties { - public static Properties getProperties(String name, boolean sipLog) { + public static Properties getProperties(String name) { Properties properties = new Properties(); properties.setProperty("javax.sip.STACK_NAME", name); // properties.setProperty("javax.sip.IP_ADDRESS", ip); @@ -49,14 +49,9 @@ public class DefaultProperties { * sip_server_log.log 和 sip_debug_log.log ERROR, INFO, WARNING, OFF, DEBUG, TRACE */ Logger logger = LoggerFactory.getLogger(SipConfig.class); - if (sipLog) { - properties.setProperty("gov.nist.javax.sip.STACK_LOGGER", "cn.skcks.docking.gb28181.core.sip.logger.StackLoggerImpl"); - properties.setProperty("gov.nist.javax.sip.SERVER_LOGGER", "cn.skcks.docking.gb28181.core.sip.logger.ServerLoggerImpl"); - properties.setProperty("gov.nist.javax.sip.LOG_MESSAGE_CONTENT", "true"); - logger.info("[SIP日志]已开启"); - }else { - logger.info("[SIP日志]已关闭"); - } + properties.setProperty("gov.nist.javax.sip.STACK_LOGGER", "cn.skcks.docking.gb28181.core.sip.logger.StackLoggerImpl"); + properties.setProperty("gov.nist.javax.sip.SERVER_LOGGER", "cn.skcks.docking.gb28181.core.sip.logger.ServerLoggerImpl"); + properties.setProperty("gov.nist.javax.sip.LOG_MESSAGE_CONTENT", "true"); return properties; } } diff --git a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/service/SipServiceImpl.java b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/service/SipServiceImpl.java index 10540e5..e1236c0 100644 --- a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/service/SipServiceImpl.java +++ b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/service/SipServiceImpl.java @@ -69,7 +69,7 @@ public class SipServiceImpl implements SipService { public void listen(String ip, int port){ try{ - sipStack = (SipStackImpl)sipFactory.createSipStack(DefaultProperties.getProperties("GB28181_SIP_LOG",true)); + sipStack = (SipStackImpl)sipFactory.createSipStack(DefaultProperties.getProperties("GB28181_SIP")); sipStack.setMessageParserFactory(new GbStringMsgParserFactory()); // sipStack.setMessageProcessorFactory(); try { diff --git a/starter/src/main/resources/application.yml b/starter/src/main/resources/application.yml index 7714ded..59ab111 100644 --- a/starter/src/main/resources/application.yml +++ b/starter/src/main/resources/application.yml @@ -1,2 +1,5 @@ server: port: 28181 + +project: + version: @project.version@ diff --git a/starter/src/main/resources/logback.xml b/starter/src/main/resources/logback.xml index 5f64ee4..dca0ed8 100644 --- a/starter/src/main/resources/logback.xml +++ b/starter/src/main/resources/logback.xml @@ -49,5 +49,6 @@ + diff --git a/zlmediakit-service/src/test/java/cn/skcks/docking/gb28181/test/MediaServiceTest.java b/zlmediakit-service/src/test/java/cn/skcks/docking/gb28181/test/MediaServiceTest.java index 175eed7..e26c340 100644 --- a/zlmediakit-service/src/test/java/cn/skcks/docking/gb28181/test/MediaServiceTest.java +++ b/zlmediakit-service/src/test/java/cn/skcks/docking/gb28181/test/MediaServiceTest.java @@ -2,12 +2,9 @@ package cn.skcks.docking.gb28181.test; import cn.hutool.core.codec.Base64; import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.net.url.UrlBuilder; -import cn.hutool.core.net.url.UrlPath; import cn.skcks.docking.gb28181.common.json.JsonResponse; import cn.skcks.docking.gb28181.common.json.JsonUtils; import cn.skcks.docking.gb28181.media.config.ZlmMediaConfig; -import cn.skcks.docking.gb28181.media.dto.config.FFMpegConfig; import cn.skcks.docking.gb28181.media.dto.config.HookConfig; import cn.skcks.docking.gb28181.media.dto.config.ServerConfig; import cn.skcks.docking.gb28181.media.dto.media.GetMediaList; @@ -24,7 +21,6 @@ import cn.skcks.docking.gb28181.media.dto.version.VersionResp; import cn.skcks.docking.gb28181.media.proxy.ZlmMediaService; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; @@ -34,7 +30,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.ResponseEntity; import org.springframework.test.context.junit.jupiter.SpringExtension; -import java.net.URL; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneOffset;