|
@@ -61,9 +61,7 @@ public class ProcessJoin extends IRCProcessor {
|
61
|
61
|
/** Mode manager to use for channel modes. */
|
62
|
62
|
private final ModeManager chanModeManager;
|
63
|
63
|
/** Pending Joins. */
|
64
|
|
- private final Queue<String> pendingJoins = new LinkedList<>();
|
65
|
|
- /** Pending Join Keys. */
|
66
|
|
- private final Queue<String> pendingJoinKeys = new LinkedList<>();
|
|
64
|
+ private final Queue<PendingJoin> pendingJoins = new LinkedList<>();
|
67
|
65
|
|
68
|
66
|
/**
|
69
|
67
|
* Create a new instance of the IRCProcessor Object.
|
|
@@ -183,24 +181,21 @@ public class ProcessJoin extends IRCProcessor {
|
183
|
181
|
parser.addChannel(iChannel);
|
184
|
182
|
sendString("MODE " + iChannel.getName(), QueuePriority.LOW);
|
185
|
183
|
|
186
|
|
- final String pendingJoin = pendingJoins.poll();
|
187
|
|
- final String pendingJoinKey = pendingJoinKeys.poll();
|
188
|
|
- if (pendingJoin != null && pendingJoin.equalsIgnoreCase(channelName)) {
|
189
|
|
- callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Guessing channel Key: " + pendingJoin + " -> " + pendingJoinKey);
|
190
|
|
- iChannel.setInternalPassword(pendingJoinKey == null ? "" : pendingJoinKey);
|
|
184
|
+ final PendingJoin pendingJoin = pendingJoins.poll();
|
|
185
|
+ if (pendingJoin != null && parser.getStringConverter().equalsIgnoreCase(pendingJoin.getChannel(), channelName)) {
|
|
186
|
+ callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Guessing channel Key: " + pendingJoin.getChannel() + " -> " + pendingJoin.getKey());
|
|
187
|
+ iChannel.setInternalPassword(pendingJoin.getKey());
|
191
|
188
|
} else {
|
192
|
189
|
// Out of sync, clear
|
193
|
|
- callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: pending join keys out of sync (Got: " + pendingJoin + ", Wanted: " + channelName + ") - Clearing.");
|
|
190
|
+ callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: pending join keys out of sync (Got: " + pendingJoin.getChannel() + ", Wanted: " + channelName + ") - Clearing.");
|
194
|
191
|
pendingJoins.clear();
|
195
|
|
- pendingJoinKeys.clear();
|
196
|
192
|
}
|
197
|
193
|
|
198
|
194
|
callChannelSelfJoin(iChannel);
|
199
|
195
|
} else {
|
200
|
196
|
// Some kind of failed to join, pop the pending join queues.
|
201
|
|
- final String pendingJoin = pendingJoins.poll();
|
202
|
|
- final String pendingJoinKey = pendingJoinKeys.poll();
|
203
|
|
- callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Failed to join channel (" + sParam + ") - Skipping " + pendingJoin + " (" + pendingJoinKey + ")");
|
|
197
|
+ final PendingJoin pendingJoin = pendingJoins.poll();
|
|
198
|
+ callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Failed to join channel (" + sParam + ") - Skipping " + pendingJoin.getChannel() + " (" + pendingJoin.getKey() + ")");
|
204
|
199
|
}
|
205
|
200
|
}
|
206
|
201
|
|
|
@@ -218,8 +213,6 @@ public class ProcessJoin extends IRCProcessor {
|
218
|
213
|
keys.addAll(Arrays.asList(newLine[2].split(",")));
|
219
|
214
|
}
|
220
|
215
|
|
221
|
|
- // PendingJoins and PendingJoinKeys should always be the same length (even if no key was given).
|
222
|
|
- //
|
223
|
216
|
// We don't get any errors for channels we try to join that we are already in
|
224
|
217
|
// But the IRCD will still swallow the key attempt.
|
225
|
218
|
//
|
|
@@ -229,8 +222,7 @@ public class ProcessJoin extends IRCProcessor {
|
229
|
222
|
final String key = keys.poll();
|
230
|
223
|
if (getChannel(chan) == null) {
|
231
|
224
|
callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Intercepted possible channel Key: " + chan + " -> " + key);
|
232
|
|
- pendingJoins.add(chan);
|
233
|
|
- pendingJoinKeys.add(key);
|
|
225
|
+ pendingJoins.add(new PendingJoin(chan, key));
|
234
|
226
|
} else {
|
235
|
227
|
callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Ignoring possible channel Key for existing channel: " + chan + " -> " + key);
|
236
|
228
|
}
|
|
@@ -260,4 +252,41 @@ public class ProcessJoin extends IRCProcessor {
|
260
|
252
|
parser, LocalDateTime.now(), cChannel));
|
261
|
253
|
}
|
262
|
254
|
|
|
255
|
+
|
|
256
|
+ /** Class to link channels to pending keys. */
|
|
257
|
+ private static class PendingJoin {
|
|
258
|
+ /** Channel name. */
|
|
259
|
+ private final String channel;
|
|
260
|
+ /** Guessed Key. */
|
|
261
|
+ private final String key;
|
|
262
|
+
|
|
263
|
+ /**
|
|
264
|
+ * Create a new PendingJoin
|
|
265
|
+ *
|
|
266
|
+ * @param channel Channel
|
|
267
|
+ * @param key Guessed Key (if there is one)
|
|
268
|
+ */
|
|
269
|
+ public PendingJoin(final String channel, final String key) {
|
|
270
|
+ this.channel = channel;
|
|
271
|
+ this.key = (key == null ? "" : key);
|
|
272
|
+ }
|
|
273
|
+
|
|
274
|
+ /**
|
|
275
|
+ * Get the channel name.
|
|
276
|
+ *
|
|
277
|
+ * @return Channel name,
|
|
278
|
+ */
|
|
279
|
+ public String getChannel() {
|
|
280
|
+ return channel;
|
|
281
|
+ }
|
|
282
|
+
|
|
283
|
+ /**
|
|
284
|
+ * Get the key
|
|
285
|
+ *
|
|
286
|
+ * @return Key
|
|
287
|
+ */
|
|
288
|
+ public String getKey() {
|
|
289
|
+ return key;
|
|
290
|
+ }
|
|
291
|
+ }
|
263
|
292
|
}
|