aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/util/NetworkUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/java/sip/communicator/util/NetworkUtils.java')
-rw-r--r--src/net/java/sip/communicator/util/NetworkUtils.java45
1 files changed, 36 insertions, 9 deletions
diff --git a/src/net/java/sip/communicator/util/NetworkUtils.java b/src/net/java/sip/communicator/util/NetworkUtils.java
index 5b641b9..2bb4c2b 100644
--- a/src/net/java/sip/communicator/util/NetworkUtils.java
+++ b/src/net/java/sip/communicator/util/NetworkUtils.java
@@ -107,6 +107,14 @@ public class NetworkUtils
*/
private static final Random random = new Random();
+ static
+ {
+ String prefer6 = System.getProperty("java.net.preferIPv6Addresses");
+ String prefer4 = System.getProperty("java.net.preferIPv4Stack");
+ logger.info("java.net.preferIPv6Addresses=" + prefer6);
+ logger.info("java.net.preferIPv4Stack=" + prefer4);
+ }
+
/**
* Determines whether the address is the result of windows auto configuration.
* (i.e. One that is in the 169.254.0.0 network)
@@ -420,6 +428,15 @@ public class NetworkUtils
colonIndex = -1;
int i = 0, j = 0;
+
+ // Can be wrapped in []
+ if (addrBuff[i] == '[')
+ {
+ ++i;
+ if (scopeID == -1)
+ --srcb_length;
+ }
+
// Starting : mean we need to have at least one more.
if (addrBuff[i] == ':')
if (addrBuff[++i] != ':')
@@ -752,30 +769,38 @@ public class NetworkUtils
return null;
}
- String[][] recVals = new String[records.length][4];
+ List<String[]> recVals = new ArrayList<>(records.length);
for (int i = 0; i < records.length; i++)
{
+ String[] recVal = new String[4];
NAPTRRecord r = (NAPTRRecord)records[i];
// todo - check here for broken records as missing transport
- recVals[i][0] = "" + r.getOrder();
- recVals[i][1] = getProtocolFromNAPTRRecords(r.getService());
+ recVal[0] = "" + r.getOrder();
+ recVal[1] = getProtocolFromNAPTRRecords(r.getService());
+ if (recVal[1] == null)
+ {
+ // we don't understand this NAPTR, maybe it's not for SIP?
+ continue;
+ }
+
String replacement = r.getReplacement().toString();
if (replacement.endsWith("."))
{
- recVals[i][2] =
+ recVal[2] =
replacement.substring(0, replacement.length() - 1);
}
else
{
- recVals[i][2] = replacement;
+ recVal[2] = replacement;
}
- recVals[i][3] = "" + r.getPreference();
+ recVal[3] = "" + r.getPreference();
+ recVals.add(recVal);
}
// sort the SRV RRs by RR value (lower is preferred)
- Arrays.sort(recVals, new Comparator<String[]>()
+ Collections.sort(recVals, new Comparator<String[]>()
{
// Sorts NAPTR records by ORDER (low number first), PREFERENCE (low
// number first) and PROTOCOL (0-TLS, 1-TCP, 2-UDP).
@@ -806,10 +831,12 @@ public class NetworkUtils
}
});
+ String[][] arrayResult = new String[recVals.size()][4];
+ arrayResult = recVals.toArray(arrayResult);
if(logger.isTraceEnabled())
logger.trace("NAPTRs for " + domain + "="
- + Arrays.toString(recVals));
- return recVals;
+ + Arrays.toString(arrayResult));
+ return arrayResult;
}
/**