diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java index fa3465dd..d4321d96 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java @@ -173,7 +173,7 @@ public class SIPRequestHeaderProvider { } - public Request createRegisterRequest(@NotNull ParentPlatform platform, String fromTag, String viaTag) throws ParseException, InvalidArgumentException, PeerUnavailableException { + public Request createRegisterRequest(@NotNull ParentPlatform platform, long CSeq, String fromTag, String viaTag) throws ParseException, InvalidArgumentException, PeerUnavailableException { Request request = null; String sipAddress = sipConfig.getSipIp() + ":" + sipConfig.getSipPort(); //请求行 @@ -206,7 +206,7 @@ public class SIPRequestHeaderProvider { MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); //ceq - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(1L, Request.REGISTER); + CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(CSeq, Request.REGISTER); request = sipFactory.createMessageFactory().createRequest(requestLine, Request.REGISTER, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); @@ -214,12 +214,15 @@ public class SIPRequestHeaderProvider { .createSipURI(platform.getDeviceGBId(), sipAddress)); request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); + ExpiresHeader expires = sipFactory.createHeaderFactory().createExpiresHeader(3600); + request.addHeader(expires); + return request; } public Request createRegisterRequest(@NotNull ParentPlatform parentPlatform, String fromTag, String viaTag, String callId, String realm, String nonce, String scheme) throws ParseException, PeerUnavailableException, InvalidArgumentException { - Request registerRequest = createRegisterRequest(parentPlatform, fromTag, viaTag); + Request registerRequest = createRegisterRequest(parentPlatform, 2L, fromTag, viaTag); CallIdHeader callIdHeader = (CallIdHeader)registerRequest.getHeader(CallIdHeader.NAME); callIdHeader.setCallId(callId); @@ -233,8 +236,7 @@ public class SIPRequestHeaderProvider { String RESPONSE = DigestUtils.md5DigestAsHex((HA1 + ":" + nonce + ":" + HA2).getBytes()); String authorizationHeaderContent = scheme + " username=\"" + parentPlatform.getDeviceGBId() + "\", " + "realm=\"" - + realm + "\", uri=\"" + uri + "\", response=\"" + RESPONSE + "\", nonce=\"" - + nonce + "\""; + + realm + "\", nonce=\"" + nonce + "\", uri=\"" + uri + "\", response=\"" + RESPONSE + "\"" + ", algorithm=MD5"; AuthorizationHeader authorizationHeader = sipFactory.createHeaderFactory().createAuthorizationHeader(authorizationHeaderContent); registerRequest.addHeader(authorizationHeader); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java index baf6e5ac..020b7500 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java @@ -52,7 +52,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { try { Request request = null; if (realm == null || nonce == null) { - request = headerProvider.createRegisterRequest(parentPlatform, null, null); + request = headerProvider.createRegisterRequest(parentPlatform, 1L, null, null); }else { request = headerProvider.createRegisterRequest(parentPlatform, null, null, callId, realm, nonce, scheme); } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java index 8af7cbfe..a94685e9 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.vmanager.platform; +import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.common.PageResult; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; @@ -15,6 +16,8 @@ import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; +import com.genersoft.iot.vmp.conf.SipConfig; + @CrossOrigin @RestController @@ -29,6 +32,19 @@ public class PlatformController { @Autowired private ISIPCommanderForPlatform commanderForPlatform; + @Autowired + private SipConfig sipConfig; + + @GetMapping("/platforms/serverconfig") + public ResponseEntity serverConfig() { + JSONObject result = new JSONObject(); + result.put("deviceIp", sipConfig.getSipIp()); + result.put("devicePort", sipConfig.getSipPort()); + result.put("username", sipConfig.getSipId()); + result.put("password", sipConfig.getSipPassword()); + return new ResponseEntity<>(result, HttpStatus.OK); + } + @GetMapping("/platforms/{count}/{page}") public PageResult platforms(@PathVariable int page, @PathVariable int count){ diff --git a/web_src/src/components/platformEdit.vue b/web_src/src/components/platformEdit.vue index 7dee4ca4..7b5a258c 100644 --- a/web_src/src/components/platformEdit.vue +++ b/web_src/src/components/platformEdit.vue @@ -1,410 +1,418 @@