From c7de14bb83d56a5a385ffd1092bd49075e36d50e Mon Sep 17 00:00:00 2001 From: Emil Ivov Date: Sun, 30 Mar 2008 09:35:37 +0000 Subject: [PATCH] Do not use Route headers in registers --- .../protocol/sip/SipRegistrarConnection.java | 57 ++++++++++++++++--- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java b/src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java index cf52f0989..b14ad9e81 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java @@ -104,8 +104,13 @@ public class SipRegistrarConnection */ private static final String KEEP_ALIVE_INTERVAL_DEFAULT_VALUE = "25"; - - + /** + * Specifies whether or not we should be using a route header in register + * requests. This field is specified by the REGISTERS_USE_ROUTE account + * property. + */ + private boolean useRouteHeader = false; + /** * Creates a new instance of this class. * @@ -271,13 +276,17 @@ void register() , maxForwardsHeader); // JvB: use Route header in addition to the request URI - SipURI regURI = (SipURI) registrarURI.clone(); - regURI.setLrParam(); - RouteHeader route = sipProvider.getHeaderFactory() - .createRouteHeader( sipProvider.getAddressFactory() - .createAddress( null, regURI )); + // because some servers loop otherwise + if(isRouteHeaderEnabled()) + { + SipURI regURI = (SipURI) registrarURI.clone(); + regURI.setLrParam(); + RouteHeader route = sipProvider.getHeaderFactory() + .createRouteHeader( sipProvider.getAddressFactory() + .createAddress( null, regURI )); - request.addHeader( route ); + request.addHeader( route ); + } } catch (ParseException ex) { @@ -1152,4 +1161,36 @@ private void updateRegisterSequenceNumber(ClientTransaction lastClientTran) //sent so the next CSeq Value should be set to seqNum + 1. this.nextCSeqValue = sequenceNumber + 1; } + + /** + * Determines whether Register requests should be using a route header. The + * return value of this method is specified by the REGISTERS_USE_ROUTE + * account property. + * + * Jeroen van Bemmel: The reason this may needed, is that standards- + * compliant registrars check the domain in the request URI. If it contains + * an IP address, some registrars are unable to match/process it (they may + * forward instead, and get into a forwarding loop) + * + * @return true if we should be using a route header. + */ + public boolean isRouteHeaderEnabled() + { + return useRouteHeader; + } + + /** + * Specifies whether Register requests should be using a route header. + * + * Jeroen van Bemmel: The reason this may needed, is that standards- + * compliant registrars check the domain in the request URI. If it contains + * an IP address, some registrars are unable to match/process it (they may + * forward instead, and get into a forwarding loop) + * + * @return true if we should be using a route header. + */ + public boolean setRouteHeaderEnabled(boolean useRouteHeader) + { + return this.useRouteHeader = useRouteHeader; + } }