|
@@ -67,8 +67,12 @@ import com.dmdirc.ui.input.TabCompletionType;
|
67
|
67
|
import com.dmdirc.ui.messages.Formatter;
|
68
|
68
|
import com.dmdirc.util.URLBuilder;
|
69
|
69
|
|
|
70
|
+import java.net.NoRouteToHostException;
|
|
71
|
+import java.net.SocketException;
|
|
72
|
+import java.net.SocketTimeoutException;
|
70
|
73
|
import java.net.URI;
|
71
|
74
|
import java.net.URISyntaxException;
|
|
75
|
+import java.net.UnknownHostException;
|
72
|
76
|
import java.security.cert.CertificateException;
|
73
|
77
|
import java.security.cert.X509Certificate;
|
74
|
78
|
import java.util.ArrayList;
|
|
@@ -80,7 +84,6 @@ import java.util.HashSet;
|
80
|
84
|
import java.util.List;
|
81
|
85
|
import java.util.Map;
|
82
|
86
|
import java.util.Random;
|
83
|
|
-import java.util.Set;
|
84
|
87
|
import java.util.concurrent.ConcurrentSkipListMap;
|
85
|
88
|
import java.util.concurrent.ScheduledExecutorService;
|
86
|
89
|
import java.util.concurrent.ScheduledFuture;
|
|
@@ -89,6 +92,7 @@ import java.util.concurrent.locks.ReadWriteLock;
|
89
|
92
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
90
|
93
|
|
91
|
94
|
import javax.annotation.Nonnull;
|
|
95
|
+import javax.net.ssl.SSLException;
|
92
|
96
|
import javax.net.ssl.TrustManager;
|
93
|
97
|
|
94
|
98
|
import org.slf4j.LoggerFactory;
|
|
@@ -146,7 +150,7 @@ public class Server extends FrameContainer implements ConfigChangeListener,
|
146
|
150
|
/** A list of outstanding invites. */
|
147
|
151
|
private final List<Invite> invites = new ArrayList<>();
|
148
|
152
|
/** A set of channels we want to join without focusing. */
|
149
|
|
- private final Set<String> backgroundChannels = new HashSet<>();
|
|
153
|
+ private final Collection<String> backgroundChannels = new HashSet<>();
|
150
|
154
|
/** Our ignore list. */
|
151
|
155
|
private final IgnoreList ignoreList = new IgnoreList();
|
152
|
156
|
/** Our string convertor. */
|
|
@@ -936,14 +940,14 @@ public class Server extends FrameContainer implements ConfigChangeListener,
|
936
|
940
|
boolean isTLD = false;
|
937
|
941
|
|
938
|
942
|
for (String tld : tlds) {
|
939
|
|
- if (serverName.endsWith("." + tld)) {
|
|
943
|
+ if (serverName.endsWith('.' + tld)) {
|
940
|
944
|
isTLD = true;
|
941
|
945
|
break;
|
942
|
946
|
}
|
943
|
947
|
}
|
944
|
948
|
|
945
|
949
|
if (isTLD && parts.length > 2) {
|
946
|
|
- return parts[parts.length - 2] + "." + parts[parts.length - 1];
|
|
950
|
+ return parts[parts.length - 2] + '.' + parts[parts.length - 1];
|
947
|
951
|
} else if (parts.length > 2) {
|
948
|
952
|
final StringBuilder network = new StringBuilder();
|
949
|
953
|
|
|
@@ -1038,13 +1042,13 @@ public class Server extends FrameContainer implements ConfigChangeListener,
|
1038
|
1042
|
|
1039
|
1043
|
@Override
|
1040
|
1044
|
public void sendCTCPReply(final String source, final String type, final String args) {
|
1041
|
|
- if (type.equalsIgnoreCase("VERSION")) {
|
|
1045
|
+ if ("VERSION".equalsIgnoreCase(type)) {
|
1042
|
1046
|
parser.sendCTCPReply(source, "VERSION", "DMDirc "
|
1043
|
1047
|
+ getConfigManager().getOption("version", "version")
|
1044
|
1048
|
+ " - http://www.dmdirc.com/");
|
1045
|
|
- } else if (type.equalsIgnoreCase("PING")) {
|
|
1049
|
+ } else if ("PING".equalsIgnoreCase(type)) {
|
1046
|
1050
|
parser.sendCTCPReply(source, "PING", args);
|
1047
|
|
- } else if (type.equalsIgnoreCase("CLIENTINFO")) {
|
|
1051
|
+ } else if ("CLIENTINFO".equalsIgnoreCase(type)) {
|
1048
|
1052
|
parser.sendCTCPReply(source, "CLIENTINFO", "VERSION PING CLIENTINFO");
|
1049
|
1053
|
}
|
1050
|
1054
|
}
|
|
@@ -1054,7 +1058,7 @@ public class Server extends FrameContainer implements ConfigChangeListener,
|
1054
|
1058
|
try {
|
1055
|
1059
|
parserLock.readLock().lock();
|
1056
|
1060
|
return hasChannel(channelName)
|
1057
|
|
- || (parser != null && parser.isValidChannelName(channelName));
|
|
1061
|
+ || parser != null && parser.isValidChannelName(channelName);
|
1058
|
1062
|
} finally {
|
1059
|
1063
|
parserLock.readLock().unlock();
|
1060
|
1064
|
}
|
|
@@ -1088,7 +1092,7 @@ public class Server extends FrameContainer implements ConfigChangeListener,
|
1088
|
1092
|
|
1089
|
1093
|
try {
|
1090
|
1094
|
parserLock.readLock().lock();
|
1091
|
|
- final Object[] arguments = new Object[]{
|
|
1095
|
+ final Object[] arguments = {
|
1092
|
1096
|
address.getHost(), parser == null ? "Unknown" : parser.getServerName(),
|
1093
|
1097
|
address.getPort(), parser == null ? "Unknown" : getNetwork(),
|
1094
|
1098
|
parser == null ? "Unknown" : parser.getLocalClient().getNickname(),};
|
|
@@ -1155,7 +1159,7 @@ public class Server extends FrameContainer implements ConfigChangeListener,
|
1155
|
1159
|
if (numeric < 10) {
|
1156
|
1160
|
snumeric = "00" + snumeric;
|
1157
|
1161
|
} else if (numeric < 100) {
|
1158
|
|
- snumeric = "0" + snumeric;
|
|
1162
|
+ snumeric = '0' + snumeric;
|
1159
|
1163
|
}
|
1160
|
1164
|
|
1161
|
1165
|
final String sansIrcd = "numeric_" + snumeric;
|
|
@@ -1277,21 +1281,21 @@ public class Server extends FrameContainer implements ConfigChangeListener,
|
1277
|
1281
|
|
1278
|
1282
|
updateIcon();
|
1279
|
1283
|
|
1280
|
|
- String description;
|
|
1284
|
+ final String description;
|
1281
|
1285
|
|
1282
|
1286
|
if (errorInfo.getException() == null) {
|
1283
|
1287
|
description = errorInfo.getData();
|
1284
|
1288
|
} else {
|
1285
|
1289
|
final Exception exception = errorInfo.getException();
|
1286
|
1290
|
|
1287
|
|
- if (exception instanceof java.net.UnknownHostException) {
|
|
1291
|
+ if (exception instanceof UnknownHostException) {
|
1288
|
1292
|
description = "Unknown host (unable to resolve)";
|
1289
|
|
- } else if (exception instanceof java.net.NoRouteToHostException) {
|
|
1293
|
+ } else if (exception instanceof NoRouteToHostException) {
|
1290
|
1294
|
description = "No route to host";
|
1291
|
|
- } else if (exception instanceof java.net.SocketTimeoutException) {
|
|
1295
|
+ } else if (exception instanceof SocketTimeoutException) {
|
1292
|
1296
|
description = "Connection attempt timed out";
|
1293
|
|
- } else if (exception instanceof java.net.SocketException
|
1294
|
|
- || exception instanceof javax.net.ssl.SSLException) {
|
|
1297
|
+ } else if (exception instanceof SocketException
|
|
1298
|
+ || exception instanceof SSLException) {
|
1295
|
1299
|
description = exception.getMessage();
|
1296
|
1300
|
} else {
|
1297
|
1301
|
Logger.appError(ErrorLevel.LOW, "Unknown socket error: "
|
|
@@ -1318,7 +1322,7 @@ public class Server extends FrameContainer implements ConfigChangeListener,
|
1318
|
1322
|
public void onPingFailed() {
|
1319
|
1323
|
statusBarManager.setMessage(new StatusMessage(
|
1320
|
1324
|
"No ping reply from " + getName() + " for over "
|
1321
|
|
- + ((int) (Math.floor(parser.getPingTime() / 1000.0)))
|
|
1325
|
+ + (int) Math.floor(parser.getPingTime() / 1000.0)
|
1322
|
1326
|
+ " seconds.", getConfigManager()));
|
1323
|
1327
|
|
1324
|
1328
|
getEventBus().publishAsync(new ServerNopingEvent(this, parser.getPingTime()));
|
|
@@ -1412,8 +1416,8 @@ public class Server extends FrameContainer implements ConfigChangeListener,
|
1412
|
1416
|
missing.append(missingUmodes);
|
1413
|
1417
|
}
|
1414
|
1418
|
|
1415
|
|
- Logger.appError(ErrorLevel.LOW, missing.toString() + " ["
|
1416
|
|
- + parser.getServerSoftwareType() + "]",
|
|
1419
|
+ Logger.appError(ErrorLevel.LOW, missing + " ["
|
|
1420
|
+ + parser.getServerSoftwareType() + ']',
|
1417
|
1421
|
new MissingModeAliasException(getNetwork(), parser,
|
1418
|
1422
|
getConfigManager().getOption("identity",
|
1419
|
1423
|
"modealiasversion"), missing.toString()));
|
|
@@ -1547,8 +1551,8 @@ public class Server extends FrameContainer implements ConfigChangeListener,
|
1547
|
1551
|
|
1548
|
1552
|
@Override
|
1549
|
1553
|
public void updateAwayState(final String message) {
|
1550
|
|
- if ((awayMessage != null && awayMessage.equals(message))
|
1551
|
|
- || (awayMessage == null && message == null)) {
|
|
1554
|
+ if (awayMessage != null && awayMessage.equals(message)
|
|
1555
|
+ || awayMessage == null && message == null) {
|
1552
|
1556
|
return;
|
1553
|
1557
|
}
|
1554
|
1558
|
|