为User-Agent添加必要的版本信息
This commit is contained in:
parent
5c211a66e9
commit
162395d227
6
pom.xml
6
pom.xml
@ -263,14 +263,16 @@
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- <plugin>
|
||||
<plugin>
|
||||
<groupId>pl.project13.maven</groupId>
|
||||
<artifactId>git-commit-id-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<configuration>
|
||||
<offline>true</offline>
|
||||
<failOnNoGitDirectory>false</failOnNoGitDirectory>
|
||||
<dateFormat>yyyyMMdd</dateFormat>
|
||||
</configuration>
|
||||
</plugin>-->
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
@ -3,6 +3,12 @@ package com.genersoft.iot.vmp;
|
||||
import java.util.logging.LogManager;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.druid.EnableDruidSupport;
|
||||
import com.genersoft.iot.vmp.storager.impl.RedisCatchStorageImpl;
|
||||
import com.genersoft.iot.vmp.utils.GitUtil;
|
||||
import com.genersoft.iot.vmp.utils.SpringBeanFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
@ -17,11 +23,18 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
@EnableScheduling
|
||||
@EnableDruidSupport
|
||||
public class VManageBootstrap extends LogManager {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(VManageBootstrap.class);
|
||||
|
||||
private static String[] args;
|
||||
private static ConfigurableApplicationContext context;
|
||||
public static void main(String[] args) {
|
||||
VManageBootstrap.args = args;
|
||||
VManageBootstrap.context = SpringApplication.run(VManageBootstrap.class, args);
|
||||
GitUtil gitUtil1 = SpringBeanFactory.getBean("gitUtil");
|
||||
logger.info("构建版本: {}", gitUtil1.getBuildVersion());
|
||||
logger.info("构建时间: {}", gitUtil1.getBuildDate());
|
||||
logger.info("GIT最后提交时间: {}", gitUtil1.getCommitTime());
|
||||
}
|
||||
// 项目重启
|
||||
public static void restart() {
|
||||
|
@ -4,6 +4,7 @@ import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.utils.GitUtil;
|
||||
import gov.nist.javax.sip.message.MessageFactoryImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -34,6 +35,9 @@ public class SIPRequestHeaderPlarformProvider {
|
||||
@Autowired
|
||||
private SipFactory sipFactory;
|
||||
|
||||
@Autowired
|
||||
private GitUtil gitUtil;
|
||||
|
||||
@Autowired
|
||||
private IRedisCatchStorage redisCatchStorage;
|
||||
|
||||
@ -72,8 +76,7 @@ public class SIPRequestHeaderPlarformProvider {
|
||||
ExpiresHeader expires = sipFactory.createHeaderFactory().createExpiresHeader(isRegister ? platform.getExpires() : 0);
|
||||
request.addHeader(expires);
|
||||
|
||||
UserAgentHeader userAgentHeader = SipUtils.createUserAgentHeader(sipFactory);
|
||||
request.addHeader(userAgentHeader);
|
||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
||||
|
||||
return request;
|
||||
}
|
||||
@ -183,6 +186,8 @@ public class SIPRequestHeaderPlarformProvider {
|
||||
request = messageFactory.createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
|
||||
toHeader, viaHeaders, maxForwards);
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
||||
|
||||
ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
|
||||
request.setContent(content, contentTypeHeader);
|
||||
return request;
|
||||
|
@ -13,6 +13,7 @@ import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
||||
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.utils.GitUtil;
|
||||
import gov.nist.javax.sip.SipProviderImpl;
|
||||
import gov.nist.javax.sip.SipStackImpl;
|
||||
import gov.nist.javax.sip.stack.SIPDialog;
|
||||
@ -37,6 +38,9 @@ public class SIPRequestHeaderProvider {
|
||||
@Autowired
|
||||
private SipFactory sipFactory;
|
||||
|
||||
@Autowired
|
||||
private GitUtil gitUtil;
|
||||
|
||||
@Autowired
|
||||
private IRedisCatchStorage redisCatchStorage;
|
||||
|
||||
@ -76,6 +80,9 @@ public class SIPRequestHeaderProvider {
|
||||
|
||||
request = sipFactory.createMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
|
||||
toHeader, viaHeaders, maxForwards);
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
||||
|
||||
ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
|
||||
request.setContent(content, contentTypeHeader);
|
||||
return request;
|
||||
@ -106,7 +113,9 @@ public class SIPRequestHeaderProvider {
|
||||
//ceq
|
||||
CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE);
|
||||
request = sipFactory.createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
||||
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
||||
|
||||
Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
||||
// Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort()));
|
||||
request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
||||
@ -146,6 +155,9 @@ public class SIPRequestHeaderProvider {
|
||||
Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
||||
// Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort()));
|
||||
request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
||||
|
||||
// Subject
|
||||
SubjectHeader subjectHeader = sipFactory.createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0));
|
||||
request.addHeader(subjectHeader);
|
||||
@ -180,6 +192,8 @@ public class SIPRequestHeaderProvider {
|
||||
CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(callId);
|
||||
request = sipFactory.createMessageFactory().createRequest(requestLine, Request.BYE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
||||
|
||||
Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
||||
|
||||
return request;
|
||||
@ -230,6 +244,9 @@ public class SIPRequestHeaderProvider {
|
||||
|
||||
ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
|
||||
request.setContent(content, contentTypeHeader);
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
@ -264,8 +281,7 @@ public class SIPRequestHeaderProvider {
|
||||
Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory()
|
||||
.createSipURI(sipConfig.getId(), sipConfig.getIp() + ":" + sipConfig.getPort()));
|
||||
infoRequest.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
||||
UserAgentHeader userAgentHeader = SipUtils.createUserAgentHeader(sipFactory);
|
||||
infoRequest.addHeader(userAgentHeader);
|
||||
infoRequest.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
||||
|
||||
ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application",
|
||||
"MANSRTSP");
|
||||
|
@ -21,6 +21,7 @@ import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import com.genersoft.iot.vmp.utils.GitUtil;
|
||||
import gov.nist.javax.sip.SipProviderImpl;
|
||||
import gov.nist.javax.sip.SipStackImpl;
|
||||
import gov.nist.javax.sip.message.MessageFactoryImpl;
|
||||
@ -60,6 +61,9 @@ public class SIPCommander implements ISIPCommander {
|
||||
@Autowired
|
||||
private SipFactory sipFactory;
|
||||
|
||||
@Autowired
|
||||
private GitUtil gitUtil;
|
||||
|
||||
@Autowired
|
||||
@Qualifier(value="tcpSipProvider")
|
||||
private SipProviderImpl tcpSipProvider;
|
||||
@ -727,7 +731,7 @@ public class SIPCommander implements ISIPCommander {
|
||||
// 增加Contact header
|
||||
Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
||||
byeRequest.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
||||
UserAgentHeader userAgentHeader = SipUtils.createUserAgentHeader(sipFactory);
|
||||
UserAgentHeader userAgentHeader = SipUtils.createUserAgentHeader(sipFactory, gitUtil);
|
||||
byeRequest.addHeader(userAgentHeader);
|
||||
ClientTransaction clientTransaction = null;
|
||||
if("TCP".equals(protocol)) {
|
||||
@ -1618,7 +1622,7 @@ public class SIPCommander implements ISIPCommander {
|
||||
if (request.getHeader(UserAgentHeader.NAME) == null) {
|
||||
UserAgentHeader userAgentHeader = null;
|
||||
try {
|
||||
userAgentHeader = SipUtils.createUserAgentHeader(sipFactory);
|
||||
userAgentHeader = SipUtils.createUserAgentHeader(sipFactory, gitUtil);
|
||||
} catch (ParseException e) {
|
||||
logger.error("添加UserAgentHeader失败", e);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.response.SIPResponseProcessorAbstract;
|
||||
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||
import com.genersoft.iot.vmp.utils.GitUtil;
|
||||
import gov.nist.javax.sip.ResponseEventExt;
|
||||
import gov.nist.javax.sip.stack.SIPDialog;
|
||||
import org.slf4j.Logger;
|
||||
@ -48,6 +49,9 @@ public class InviteResponseProcessor extends SIPResponseProcessorAbstract {
|
||||
@Autowired
|
||||
private SipFactory sipFactory;
|
||||
|
||||
@Autowired
|
||||
private GitUtil gitUtil;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
// 添加消息处理的订阅
|
||||
@ -98,7 +102,7 @@ public class InviteResponseProcessor extends SIPResponseProcessorAbstract {
|
||||
}
|
||||
requestURI.setPort(event.getRemotePort());
|
||||
reqAck.setRequestURI(requestURI);
|
||||
UserAgentHeader userAgentHeader = SipUtils.createUserAgentHeader(sipFactory);
|
||||
UserAgentHeader userAgentHeader = SipUtils.createUserAgentHeader(sipFactory, gitUtil);
|
||||
reqAck.addHeader(userAgentHeader);
|
||||
Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
||||
reqAck.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.genersoft.iot.vmp.gb28181.utils;
|
||||
|
||||
import com.genersoft.iot.vmp.utils.GitUtil;
|
||||
import gov.nist.javax.sip.address.AddressImpl;
|
||||
import gov.nist.javax.sip.address.SipUri;
|
||||
import gov.nist.javax.sip.header.Subject;
|
||||
@ -49,10 +50,13 @@ public class SipUtils {
|
||||
return "z9hG4bK" + System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public static UserAgentHeader createUserAgentHeader(SipFactory sipFactory) throws PeerUnavailableException, ParseException {
|
||||
public static UserAgentHeader createUserAgentHeader(SipFactory sipFactory, GitUtil gitUtil) throws PeerUnavailableException, ParseException {
|
||||
List<String> agentParam = new ArrayList<>();
|
||||
agentParam.add("WVP PRO");
|
||||
// TODO 添加版本信息以及日期
|
||||
agentParam.add("WVP-Pro v");
|
||||
if (gitUtil != null && gitUtil.getCommitTime() != null) {
|
||||
agentParam.add(gitUtil.getBuildVersion() + ".");
|
||||
agentParam.add(gitUtil.getCommitTime());
|
||||
}
|
||||
return sipFactory.createHeaderFactory().createUserAgentHeader(agentParam);
|
||||
}
|
||||
|
||||
|
@ -19,9 +19,16 @@ public class GitUtil {
|
||||
private String gitUrl;
|
||||
@Value("${git.build.time:null}")
|
||||
private String buildDate;
|
||||
|
||||
@Value("${git.build.version:null}")
|
||||
private String buildVersion;
|
||||
|
||||
@Value("${git.commit.id.abbrev:null}")
|
||||
private String commitIdShort;
|
||||
|
||||
@Value("${git.commit.time:null}")
|
||||
private String commitTime;
|
||||
|
||||
public String getGitCommitId() {
|
||||
return gitCommitId;
|
||||
}
|
||||
@ -41,4 +48,12 @@ public class GitUtil {
|
||||
public String getCommitIdShort() {
|
||||
return commitIdShort;
|
||||
}
|
||||
|
||||
public String getBuildVersion() {
|
||||
return buildVersion;
|
||||
}
|
||||
|
||||
public String getCommitTime() {
|
||||
return commitTime;
|
||||
}
|
||||
}
|
||||
|
@ -195,9 +195,3 @@ springdoc:
|
||||
enabled: false
|
||||
swagger-ui:
|
||||
enabled: false
|
||||
|
||||
# 版本信息, 不需修改
|
||||
version:
|
||||
version: "@project.version@"
|
||||
description: "@project.description@"
|
||||
artifact-id: "@project.artifactId@"
|
||||
|
@ -84,9 +84,3 @@ media:
|
||||
# [可选] 日志配置, 一般不需要改
|
||||
logging:
|
||||
config: classpath:logback-spring-local.xml
|
||||
|
||||
# 版本信息, 不需修改
|
||||
version:
|
||||
version: "@project.version@"
|
||||
description: "@project.description@"
|
||||
artifact-id: "@project.artifactId@"
|
||||
|
@ -78,10 +78,3 @@ user-settings:
|
||||
# 推流直播是否录制
|
||||
record-push-live: true
|
||||
auto-apply-play: true
|
||||
|
||||
|
||||
# 版本信息, 不需修改
|
||||
version:
|
||||
version: "@project.version@"
|
||||
description: "@project.description@"
|
||||
artifact-id: "@project.artifactId@"
|
||||
|
@ -5,5 +5,3 @@
|
||||
\ \ \|\__\_\ \ \ / / \ \ \___\|____________|\ \ \___|\ \ \\ \\ \ \\\ \
|
||||
\ \____________\ \__/ / \ \__\ \ \__\ \ \__\\ _\\ \_______\
|
||||
\|____________|\|__|/ \|__| \|__| \|__|\|__|\|_______|
|
||||
|
||||
版本:${version.version}
|
Loading…
Reference in New Issue
Block a user