|
@@ -163,6 +163,9 @@ public class IRCParser implements SecureParser, Runnable {
|
163
|
163
|
/** Has the thread started execution yet, (Prevents run() being called multiple times). */
|
164
|
164
|
boolean hasBegan;
|
165
|
165
|
|
|
166
|
+ /** Connect timeout. */
|
|
167
|
+ private int connectTimeout = 5000;
|
|
168
|
+
|
166
|
169
|
/** Hashtable storing known prefix modes (ohv). */
|
167
|
170
|
final Map<Character, Long> prefixModes = new Hashtable<Character, Long>();
|
168
|
171
|
/**
|
|
@@ -418,12 +421,25 @@ public class IRCParser implements SecureParser, Runnable {
|
418
|
421
|
|
419
|
422
|
/**
|
420
|
423
|
* Get the current Value of addLastLine.
|
421
|
|
- * This returns "this" and thus can be used in the construction line.
|
422
|
424
|
*
|
423
|
425
|
* @param newValue New value to set addLastLine
|
424
|
426
|
*/
|
425
|
427
|
public void setAddLastLine(final boolean newValue) { addLastLine = newValue; }
|
426
|
428
|
|
|
429
|
+ /**
|
|
430
|
+ * Get the current Value of connectTimeout.
|
|
431
|
+ *
|
|
432
|
+ * @return The value of getConnectTimeout.
|
|
433
|
+ */
|
|
434
|
+ public int getConnectTimeout() { return connectTimeout; }
|
|
435
|
+
|
|
436
|
+ /**
|
|
437
|
+ * Set the Value of connectTimeout.
|
|
438
|
+ *
|
|
439
|
+ * @param newValue new value for value of getConnectTimeout.
|
|
440
|
+ */
|
|
441
|
+ public void setConnectTimeout(final int newValue) { connectTimeout = newValue; }
|
|
442
|
+
|
427
|
443
|
/**
|
428
|
444
|
* Get the current socket State.
|
429
|
445
|
*
|
|
@@ -718,28 +734,26 @@ public class IRCParser implements SecureParser, Runnable {
|
718
|
734
|
try {
|
719
|
735
|
try { ia.getSemaphore().acquire(); } catch (InterruptedException ex) { }
|
720
|
736
|
ia.addAuthentication(server);
|
721
|
|
- socket.connect(new InetSocketAddress(server.getHost(), server.getPort()));
|
|
737
|
+ socket.connect(new InetSocketAddress(server.getHost(), server.getPort()), connectTimeout);
|
722
|
738
|
} finally {
|
723
|
739
|
ia.removeAuthentication(server);
|
724
|
740
|
ia.getSemaphore().release();
|
725
|
741
|
}
|
726
|
742
|
} else {
|
727
|
743
|
callDebugInfo(DEBUG_SOCKET, "Not using Proxy");
|
728
|
|
- if (!server.getSSL()) {
|
729
|
|
- socket = new Socket();
|
|
744
|
+ socket = new Socket();
|
730
|
745
|
|
731
|
|
- if (bindIP != null && !bindIP.isEmpty()) {
|
732
|
|
- callDebugInfo(DEBUG_SOCKET, "Binding to IP: "+bindIP);
|
733
|
|
- try {
|
734
|
|
- socket.bind(new InetSocketAddress(InetAddress.getByName(bindIP), 0));
|
735
|
|
- } catch (IOException e) {
|
736
|
|
- callDebugInfo(DEBUG_SOCKET, "Binding failed: "+e.getMessage());
|
737
|
|
- }
|
|
746
|
+ if (bindIP != null && !bindIP.isEmpty()) {
|
|
747
|
+ callDebugInfo(DEBUG_SOCKET, "Binding to IP: "+bindIP);
|
|
748
|
+ try {
|
|
749
|
+ socket.bind(new InetSocketAddress(InetAddress.getByName(bindIP), 0));
|
|
750
|
+ } catch (IOException e) {
|
|
751
|
+ callDebugInfo(DEBUG_SOCKET, "Binding failed: "+e.getMessage());
|
738
|
752
|
}
|
739
|
|
-
|
740
|
|
- currentSocketState = SocketState.OPENING;
|
741
|
|
- socket.connect(new InetSocketAddress(server.getHost(), server.getPort()));
|
742
|
753
|
}
|
|
754
|
+
|
|
755
|
+ currentSocketState = SocketState.OPENING;
|
|
756
|
+ socket.connect(new InetSocketAddress(server.getHost(), server.getPort()), connectTimeout);
|
743
|
757
|
}
|
744
|
758
|
|
745
|
759
|
if (server.getSSL()) {
|
|
@@ -751,22 +765,8 @@ public class IRCParser implements SecureParser, Runnable {
|
751
|
765
|
sc.init(myKeyManagers, myTrustManager, new java.security.SecureRandom());
|
752
|
766
|
|
753
|
767
|
final SSLSocketFactory socketFactory = sc.getSocketFactory();
|
754
|
|
- if (server.getUseSocks()) {
|
755
|
|
- socket = socketFactory.createSocket(socket, server.getHost(), server.getPort(), false);
|
756
|
|
- } else {
|
757
|
|
- if (bindIP == null || bindIP.isEmpty()) {
|
758
|
|
- socket = socketFactory.createSocket(server.getHost(), server.getPort());
|
759
|
|
- } else {
|
760
|
|
- callDebugInfo(DEBUG_SOCKET, "Binding to IP: "+bindIP);
|
761
|
|
- try {
|
762
|
|
- socket = socketFactory.createSocket(server.getHost(), server.getPort(), InetAddress.getByName(bindIP), 0);
|
763
|
|
- } catch (UnknownHostException e) {
|
764
|
|
- callDebugInfo(DEBUG_SOCKET, "Bind failed: "+e.getMessage());
|
765
|
|
- socket = socketFactory.createSocket(server.getHost(), server.getPort());
|
766
|
|
- }
|
767
|
|
- }
|
768
|
|
- }
|
769
|
|
-
|
|
768
|
+ socket = socketFactory.createSocket(socket, server.getHost(), server.getPort(), false);
|
|
769
|
+
|
770
|
770
|
currentSocketState = SocketState.OPENING;
|
771
|
771
|
}
|
772
|
772
|
|