|
@@ -23,11 +23,8 @@
|
23
|
23
|
package com.dmdirc.addons.identd;
|
24
|
24
|
|
25
|
25
|
import com.dmdirc.ClientModule.GlobalConfig;
|
26
|
|
-import com.dmdirc.DMDircMBassador;
|
27
|
|
-import com.dmdirc.events.UserErrorEvent;
|
28
|
26
|
import com.dmdirc.interfaces.ConnectionManager;
|
29
|
27
|
import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
30
|
|
-import com.dmdirc.logger.ErrorLevel;
|
31
|
28
|
import com.dmdirc.plugins.PluginDomain;
|
32
|
29
|
import com.dmdirc.util.SystemInfo;
|
33
|
30
|
|
|
@@ -39,13 +36,17 @@ import java.util.List;
|
39
|
36
|
|
40
|
37
|
import javax.inject.Inject;
|
41
|
38
|
|
|
39
|
+import org.slf4j.Logger;
|
|
40
|
+import org.slf4j.LoggerFactory;
|
|
41
|
+
|
|
42
|
+import static com.dmdirc.util.LogUtils.USER_ERROR;
|
|
43
|
+
|
42
|
44
|
/**
|
43
|
45
|
* The IdentdServer watches over the ident port when required
|
44
|
46
|
*/
|
45
|
47
|
public final class IdentdServer implements Runnable {
|
46
|
48
|
|
47
|
|
- /** The event bus to post errors on. */
|
48
|
|
- private final DMDircMBassador eventBus;
|
|
49
|
+ private static final Logger LOG = LoggerFactory.getLogger(IdentdServer.class);
|
49
|
50
|
/** The Thread in use for this server */
|
50
|
51
|
private volatile Thread myThread;
|
51
|
52
|
/** The current socket in use for this server */
|
|
@@ -66,18 +67,15 @@ public final class IdentdServer implements Runnable {
|
66
|
67
|
/**
|
67
|
68
|
* Create the IdentdServer.
|
68
|
69
|
*
|
69
|
|
- * @param eventBus The event bus to post errors on
|
70
|
70
|
* @param connectionManager Server manager to iterate over servers
|
71
|
71
|
* @param config Global config
|
72
|
72
|
* @param domain This plugin's setting domain
|
73
|
73
|
*/
|
74
|
74
|
@Inject
|
75
|
|
- public IdentdServer(final DMDircMBassador eventBus,
|
76
|
|
- final ConnectionManager connectionManager,
|
|
75
|
+ public IdentdServer(final ConnectionManager connectionManager,
|
77
|
76
|
@GlobalConfig final AggregateConfigProvider config,
|
78
|
77
|
@PluginDomain(IdentdPlugin.class) final String domain,
|
79
|
78
|
final SystemInfo systemInfo) {
|
80
|
|
- this.eventBus = eventBus;
|
81
|
79
|
this.connectionManager = connectionManager;
|
82
|
80
|
this.config = config;
|
83
|
81
|
this.domain = domain;
|
|
@@ -93,14 +91,13 @@ public final class IdentdServer implements Runnable {
|
93
|
91
|
while (myThread == thisThread) {
|
94
|
92
|
try {
|
95
|
93
|
final Socket clientSocket = serverSocket.accept();
|
96
|
|
- final IdentClient client = new IdentClient(eventBus, this, clientSocket,
|
97
|
|
- connectionManager, config, domain, systemInfo);
|
|
94
|
+ final IdentClient client = new IdentClient(this, clientSocket, connectionManager,
|
|
95
|
+ config, domain, systemInfo);
|
98
|
96
|
client.start();
|
99
|
97
|
addClient(client);
|
100
|
98
|
} catch (IOException e) {
|
101
|
99
|
if (myThread == thisThread) {
|
102
|
|
- eventBus.publishAsync(new UserErrorEvent(ErrorLevel.HIGH, e,
|
103
|
|
- "Accepting client failed: " + e.getMessage(), ""));
|
|
100
|
+ LOG.error(USER_ERROR, "Accepting client failed: {}", e.getMessage(), e);
|
104
|
101
|
}
|
105
|
102
|
}
|
106
|
103
|
}
|
|
@@ -153,8 +150,7 @@ public final class IdentdServer implements Runnable {
|
153
|
150
|
myThread = new Thread(this);
|
154
|
151
|
myThread.start();
|
155
|
152
|
} catch (IOException e) {
|
156
|
|
- eventBus.publishAsync(new UserErrorEvent(ErrorLevel.HIGH, e,
|
157
|
|
- "Unable to start identd server: " + e.getMessage(), ""));
|
|
153
|
+ LOG.error(USER_ERROR, "Unable to start identd server: {}", e.getMessage(), e);
|
158
|
154
|
if ("Permission denied".equals(e.getMessage())) {
|
159
|
155
|
failed = true;
|
160
|
156
|
}
|
|
@@ -175,6 +171,7 @@ public final class IdentdServer implements Runnable {
|
175
|
171
|
try {
|
176
|
172
|
serverSocket.close();
|
177
|
173
|
} catch (IOException e) {
|
|
174
|
+ LOG.info("Unable to close socket: {}", e.getMessage(), e);
|
178
|
175
|
}
|
179
|
176
|
|
180
|
177
|
synchronized (clientList) {
|