diff --git a/gb28181-sip/src/main/java/cn/skcks/docking/gb28181/sip/method/RequestBuilder.java b/gb28181-sip/src/main/java/cn/skcks/docking/gb28181/sip/method/RequestBuilder.java index a690afc..d8f495c 100644 --- a/gb28181-sip/src/main/java/cn/skcks/docking/gb28181/sip/method/RequestBuilder.java +++ b/gb28181-sip/src/main/java/cn/skcks/docking/gb28181/sip/method/RequestBuilder.java @@ -12,6 +12,7 @@ import javax.sip.address.Address; import javax.sip.address.SipURI; import javax.sip.message.Request; +@SuppressWarnings("Duplicates") @Data @SuperBuilder public class RequestBuilder { @@ -28,12 +29,13 @@ public class RequestBuilder { Address localAddress = SipBuilder.createAddress(SipBuilder.createSipURI(getLocalId(), local)); String target = SipBuilder.createHostAddress(getTargetIp(), getTargetPort()); SipURI targetUri = SipBuilder.createSipURI(getTargetId(), target); + Address targetAddress = SipBuilder.createAddress(targetUri); return SipRequestBuilder.createRequest(targetUri, method, SipBuilder.createCallIdHeader(callId), SipBuilder.createCSeqHeader(cSeq, method), SipBuilder.createFromHeader(localAddress, SipUtil.generateFromTag()), - SipBuilder.createToHeader(localAddress), + SipBuilder.createToHeader(targetAddress), SipBuilder.createViaHeaders(getTargetIp(), getTargetPort(), getTransport(), SipUtil.generateViaTag()), SipBuilder.createMaxForwardsHeader(70)); } @@ -43,12 +45,13 @@ public class RequestBuilder { Address localAddress = SipBuilder.createAddress(SipBuilder.createSipURI(getLocalId(), local)); String target = SipBuilder.createHostAddress(getTargetIp(), getTargetPort()); SipURI targetUri = SipBuilder.createSipURI(getTargetId(), target); + Address targetAddress = SipBuilder.createAddress(targetUri); return SipRequestBuilder.createRequest(targetUri, method, SipBuilder.createCallIdHeader(callId), SipBuilder.createCSeqHeader(cSeq, method), SipBuilder.createFromHeader(localAddress, SipUtil.generateFromTag()), - SipBuilder.createToHeader(localAddress), + SipBuilder.createToHeader(targetAddress), SipBuilder.createViaHeaders(getTargetIp(), getTargetPort(), getTransport(), SipUtil.generateViaTag()), SipBuilder.createMaxForwardsHeader(70), SipContentType.XML, content); } @@ -58,12 +61,13 @@ public class RequestBuilder { Address localAddress = SipBuilder.createAddress(SipBuilder.createSipURI(getLocalId(), local)); String target = SipBuilder.createHostAddress(getTargetIp(), getTargetPort()); SipURI targetUri = SipBuilder.createSipURI(getTargetId(), target); + Address targetAddress = SipBuilder.createAddress(targetUri); return SipRequestBuilder.createRequest(targetUri, method, SipBuilder.createCallIdHeader(callId), SipBuilder.createCSeqHeader(cSeq, method), SipBuilder.createFromHeader(localAddress, SipUtil.generateFromTag()), - SipBuilder.createToHeader(localAddress), + SipBuilder.createToHeader(targetAddress), SipBuilder.createViaHeaders(getTargetIp(), getTargetPort(), getTransport(), SipUtil.generateViaTag()), SipBuilder.createMaxForwardsHeader(70), SipContentType.SDP, description.toString()); } diff --git a/gb28181-sip/src/main/java/cn/skcks/docking/gb28181/sip/method/register/request/RegisterRequestBuilder.java b/gb28181-sip/src/main/java/cn/skcks/docking/gb28181/sip/method/register/request/RegisterRequestBuilder.java index 097128f..d7dc8f3 100644 --- a/gb28181-sip/src/main/java/cn/skcks/docking/gb28181/sip/method/register/request/RegisterRequestBuilder.java +++ b/gb28181-sip/src/main/java/cn/skcks/docking/gb28181/sip/method/register/request/RegisterRequestBuilder.java @@ -1,11 +1,9 @@ package cn.skcks.docking.gb28181.sip.method.register.request; import cn.skcks.docking.gb28181.sip.generic.SipBuilder; -import cn.skcks.docking.gb28181.sip.generic.SipRequestBuilder; import cn.skcks.docking.gb28181.sip.method.RequestBuilder; import cn.skcks.docking.gb28181.sip.method.register.RegisterBuilder; import cn.skcks.docking.gb28181.sip.utils.DigestAuthenticationHelper; -import cn.skcks.docking.gb28181.sip.utils.SipUtil; import gov.nist.javax.sip.message.SIPRequest; import lombok.Data; import lombok.EqualsAndHashCode; @@ -14,7 +12,6 @@ import lombok.ToString; import lombok.experimental.SuperBuilder; import javax.sip.address.Address; -import javax.sip.address.SipURI; import javax.sip.header.AuthorizationHeader; import javax.sip.header.WWWAuthenticateHeader; import javax.sip.message.Request; @@ -30,7 +27,9 @@ public class RegisterRequestBuilder extends RequestBuilder implements RegisterBu String local = SipBuilder.createHostAddress(getLocalIp(), getLocalPort()); Address localAddress = SipBuilder.createAddress(SipBuilder.createSipURI(getLocalId(), local)); - Request request = createRequest(METHOD, callId, 1); + SIPRequest request = (SIPRequest) createRequest(METHOD, callId, 1); + Address address = request.getFromHeader().getAddress(); + request.getToHeader().setAddress(address); return SipBuilder.addHeaders(request, SipBuilder.createExpiresHeader(expires), SipBuilder.createContactHeader(localAddress)); diff --git a/gb28181-sip/src/test/java/cn/skcks/docking/gb28181/sip/process/RequestTest.java b/gb28181-sip/src/test/java/cn/skcks/docking/gb28181/sip/process/RequestTest.java index 1e63fb0..4a4a86b 100644 --- a/gb28181-sip/src/test/java/cn/skcks/docking/gb28181/sip/process/RequestTest.java +++ b/gb28181-sip/src/test/java/cn/skcks/docking/gb28181/sip/process/RequestTest.java @@ -40,7 +40,7 @@ public class RequestTest { .targetIp(localIp) .targetPort(localPort) .targetId(localId) - .transport(ListeningPoint.UDP) + .transport(ListeningPoint.TCP) .build(); String callId = SipUtil.nanoId(10); CatalogQueryDTO catalogQueryDTO = CatalogQueryDTO.builder()