Remove some unnecessary resolves.

Fix NAPTR queries, getting SRV query string from NAPTR results.
Fix NPE when there is no SERVER_ADDRESS saved.
Process SIP 423 Interval Too Brief to update our expiration time value.
Disable Jabber user id field when editing jabber accounts.
cusax-fix
Damian Minkov 15 years ago
parent 4e132f0db4
commit bbcce19767

@ -2027,8 +2027,6 @@ void initOutboundProxy(SipAccountID accountID, int ix)
proxyAddress = proxySocketAddress.getAddress();
proxyPort = proxySocketAddress.getPort();
proxyAddressStr = proxyAddress.getHostName();
if (logger.isTraceEnabled())
logger.trace("Setting proxy address = " + proxyAddressStr);
@ -2069,9 +2067,7 @@ void initOutboundProxy(SipAccountID accountID, int ix)
}
// Return if no proxy is specified or if the proxyAddress is null.
if(proxyAddressStr == null
|| proxyAddressStr.length() == 0
|| proxyAddress == null)
if(proxyAddress == null)
{
return;
}
@ -2692,17 +2688,22 @@ public void resolveSipAddress(
for(String[] rec : naptrRecords)
{
resolveSRV(
address,
rec[2],
rec[1],
resultAddresses,
resultTransports,
preferIPv6Addresses);
preferIPv6Addresses,
true);
}
// NAPTR found use only it
if(logger.isInfoEnabled())
logger.info("Found NAPRT record and using it:"
+ resultAddresses);
// return only if found something
if(resultAddresses.size() > 0
&& resultTransports.size() > 0)
return;
}
}
@ -2720,7 +2721,8 @@ public void resolveSipAddress(
transport,
resultAddresses,
resultTransports,
preferIPv6Addresses);
preferIPv6Addresses,
false);
}
catch (ParseException e)
{
@ -2871,17 +2873,25 @@ public InetSocketAddress resolveSipAddress(String address)
* @param resultAddresses the result address after resolve.
* @param resultTransports and the addresses transports.
* @param preferIPv6Addresses is ipv6 addresses are preferred over ipv4.
* @param srvQueryString is the supplied address is of type
* _sip(s)._protocol.address, a string ready for srv queries, used
* when we have a NAPTR returned records with value <tt>true</tt>.
* @throws ParseException exception when parsing dns address
*/
private void resolveSRV(String address,
String transport,
List<InetSocketAddress> resultAddresses,
List<String> resultTransports,
boolean preferIPv6Addresses)
boolean preferIPv6Addresses,
boolean srvQueryString)
throws ParseException
{
InetSocketAddress[] socketAddresses =
NetworkUtils.getSRVRecords(
InetSocketAddress[] socketAddresses;
if(srvQueryString)
socketAddresses = NetworkUtils.getSRVRecords(address);
else
socketAddresses = NetworkUtils.getSRVRecords(
transport.equalsIgnoreCase(ListeningPoint.TLS)
? "sips" : "sip",
transport.equalsIgnoreCase(ListeningPoint.UDP)

@ -1039,6 +1039,11 @@ public Request createRegisterRequest(Address addressOfRecord,
String domain = protocolProvider.getAccountID().
getAccountPropertyString(ProtocolProviderFactory.SERVER_ADDRESS);
// we used to take domain from toHeader, if there is no such
// account property back to previous behaviour
if(domain == null)
domain = ((SipURI) toHeader.getAddress().getURI()).getHost();
//Request URI
SipURI requestURI = protocolProvider.getAddressFactory()
.createSipURI(null, domain);

@ -163,7 +163,8 @@ public SipRegistrarConnection(
this.sipProvider = sipProviderCallback;
this.currentRegistrarAddress = registrarAddresses[0];
registrarURI = sipProvider.getAddressFactory().createSipURI(
null, this.currentRegistrarAddress.getHostName());
null,
this.currentRegistrarAddress.getAddress().getHostAddress());
if(this.currentRegistrarAddress.getPort() != ListeningPoint.PORT_5060)
registrarURI.setPort(this.currentRegistrarAddress.getPort());
@ -313,9 +314,11 @@ private boolean registerUsingNextAddress()
try
{
registrarURI = sipProvider.getAddressFactory().createSipURI(
null, this.currentRegistrarAddress.getHostName());
null,
this.currentRegistrarAddress.getAddress().getHostAddress());
if(this.currentRegistrarAddress.getPort() != ListeningPoint.PORT_5060)
if(this.currentRegistrarAddress.getPort()
!= ListeningPoint.PORT_5060)
registrarURI.setPort(this.currentRegistrarAddress.getPort());
// as the transport may change NAPTR records provides
@ -867,6 +870,11 @@ else if (response.getStatusCode() == Response.UNAUTHORIZED
clientTransaction, response, sourceProvider);
processed = true;
}
else if (response.getStatusCode() == Response.INTERVAL_TOO_BRIEF)
{
processIntervalTooBrief(response);
processed = true;
}
else if ( response.getStatusCode() >= 400 )
{
logger.error("Received an error response.");
@ -1033,6 +1041,56 @@ public boolean processIOException(IOExceptionEvent exceptionEvent)
return true;
}
/**
* Process error 423 Interval Too Brief. If there is minimum interval
* specified use it. Check the specified interval is greater than the one
* we used in our register.
* @param response the response containing the min expires header.
*/
private void processIntervalTooBrief(Response response)
{
// interval is too brief, if we have specified correct interval
// in the response use it and re-register
MinExpiresHeader header =
(MinExpiresHeader)response.getHeader(MinExpiresHeader.NAME);
if(header != null)
{
int expires = header.getExpires();
if(expires > registrationsExpiration)
{
registrationsExpiration = expires;
try
{
register();
return;
}
catch (Throwable e)
{
logger.error("Cannot send register!", e);
setRegistrationState(
RegistrationState.CONNECTION_FAILED,
RegistrationStateChangeEvent.REASON_NOT_SPECIFIED,
"A timeout occurred while trying to " +
"connect to the server.");
return;
}
}
}
//tell the others we couldn't register
this.setRegistrationState(
RegistrationState.CONNECTION_FAILED
, RegistrationStateChangeEvent.REASON_NOT_SPECIFIED
, "Received an error while trying to register. "
+ "Server returned error:" + response.getReasonPhrase()
);
}
/**
* Returns a string representation of this connection instance
* instance including information that would permit to distinguish it among

@ -208,6 +208,7 @@ String getUsername()
void setUsername(String username)
{
userIDField.setText(username);
userIDField.setEnabled(false);
}
/**

@ -1019,7 +1019,7 @@ private static boolean isMappedIPv4Addr(byte[] address)
private static Lookup createLookup(String domain, int type)
throws TextParseException
{
Lookup lookup = new Lookup(domain, Type.SRV);
Lookup lookup = new Lookup(domain, type);
//initiate our global parallel resolver if this is our first ever
//DNS query.

Loading…
Cancel
Save