forked from I2P_Developers/i2p.i2p
Dynamically load domain socket code
This commit is contained in:
@ -10,6 +10,8 @@ package net.i2p.router.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@ -123,10 +125,30 @@ class ClientManager {
|
||||
protected void startListeners() {
|
||||
ClientListenerRunner listener;
|
||||
if (SystemVersion.isAndroid()) {
|
||||
listener = new DomainClientListenerRunner(_ctx, this);
|
||||
Thread t = new I2PThread(listener, "DomainClientListener", true);
|
||||
t.start();
|
||||
_listeners.add(listener);
|
||||
try {
|
||||
Class<? extends ClientListenerRunner> clazz = Class.forName(
|
||||
"net.i2p.router.client.DomainClientListenerRunner"
|
||||
).asSubclass(ClientListenerRunner.class);
|
||||
Constructor<? extends ClientListenerRunner> ctor =
|
||||
clazz.getDeclaredConstructor(RouterContext.class,
|
||||
ClientManager.class);
|
||||
listener = ctor.newInstance(_ctx, this);
|
||||
Thread t = new I2PThread(listener, "DomainClientListener", true);
|
||||
t.start();
|
||||
_listeners.add(listener);
|
||||
} catch (ClassNotFoundException e) {
|
||||
_log.warn("Could not find DomainClientListenerRunner class", e);
|
||||
} catch (ClassCastException e) {
|
||||
_log.error("Error creating DomainClientListenerRunner", e);
|
||||
} catch (NoSuchMethodException e) {
|
||||
_log.error("Error creating DomainClientListenerRunner", e);
|
||||
} catch (InstantiationException e) {
|
||||
_log.error("Error creating DomainClientListenerRunner", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
_log.error("Error creating DomainClientListenerRunner", e);
|
||||
} catch (InvocationTargetException e) {
|
||||
_log.error("Error creating DomainClientListenerRunner", e);
|
||||
}
|
||||
}
|
||||
if (!_ctx.getBooleanProperty(PROP_DISABLE_EXTERNAL)) {
|
||||
// there's no option to start both an SSL and non-SSL listener
|
||||
|
@ -1,31 +0,0 @@
|
||||
package net.i2p.router.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
|
||||
import net.i2p.client.DomainSocketFactory;
|
||||
import net.i2p.router.RouterContext;
|
||||
|
||||
/**
|
||||
* Unix domain socket version of ClientListenerRunner.
|
||||
* <p/>
|
||||
* This is a stub that does nothing.
|
||||
* This class is replaced in the Android build.
|
||||
*
|
||||
* @author str4d
|
||||
* @since 0.9.14
|
||||
*/
|
||||
public class DomainClientListenerRunner extends ClientListenerRunner {
|
||||
public DomainClientListenerRunner(RouterContext context, ClientManager manager) {
|
||||
super(context, manager, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
protected ServerSocket getServerSocket() throws IOException {
|
||||
final DomainSocketFactory fact = new DomainSocketFactory(_context);
|
||||
return fact.createServerSocket(DomainSocketFactory.I2CP_SOCKET_ADDRESS);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user