Changeset c5432a2 for core


Ignore:
Timestamp:
May 22, 2016 1:18:16 AM (4 years ago)
Author:
str4d <str4d@…>
Branches:
master
Children:
63260aa, e518e67
Parents:
3afe04d
Message:

Dynamically load domain socket code

Location:
core/java/src/net/i2p/client
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/client/impl/I2PSessionImpl.java

    r3afe04d rc5432a2  
    1515import java.io.InputStream;
    1616import java.io.OutputStream;
     17import java.lang.reflect.Constructor;
     18import java.lang.reflect.InvocationTargetException;
     19import java.lang.reflect.Method;
    1720import java.net.Socket;
    1821import java.net.UnknownHostException;
     
    3033import net.i2p.CoreVersion;
    3134import net.i2p.I2PAppContext;
    32 import net.i2p.client.DomainSocketFactory;
    3335import net.i2p.client.I2PClient;
    3436import net.i2p.client.I2PSession;
     
    598600                } else {
    599601                    if (SystemVersion.isAndroid() &&
    600                             Boolean.parseBoolean(_options.getProperty(PROP_DOMAIN_SOCKET))) {
    601                         final DomainSocketFactory fact = new DomainSocketFactory(_context);
    602                         _socket = fact.createSocket(DomainSocketFactory.I2CP_SOCKET_ADDRESS);
     602                            _options.getProperty(PROP_DOMAIN_SOCKET) != null) {
     603                        try {
     604                            Class<?> clazz = Class.forName("net.i2p.client.DomainSocketFactory");
     605                            Constructor<?> ctor = clazz.getDeclaredConstructor(I2PAppContext.class);
     606                            Object fact = ctor.newInstance(_context);
     607                            Method createSocket = clazz.getDeclaredMethod("createSocket", String.class);
     608                            _socket = (Socket) createSocket.invoke(fact, _options.getProperty(PROP_DOMAIN_SOCKET));
     609                        } catch (ClassNotFoundException e) {
     610                            throw new I2PSessionException("Cannot load DomainSocketFactory", e);
     611                        } catch (NoSuchMethodException e) {
     612                            throw new I2PSessionException("Cannot load DomainSocketFactory", e);
     613                        } catch (InstantiationException e) {
     614                            throw new I2PSessionException("Cannot load DomainSocketFactory", e);
     615                        } catch (IllegalAccessException e) {
     616                            throw new I2PSessionException("Cannot load DomainSocketFactory", e);
     617                        } catch (InvocationTargetException e) {
     618                            throw new I2PSessionException("Cannot load DomainSocketFactory", e);
     619                        }
    603620                    } else if (Boolean.parseBoolean(_options.getProperty(PROP_ENABLE_SSL))) {
    604621                        try {
     
    685702                msg = "Failed to build tunnels";
    686703            else if (SystemVersion.isAndroid() &&
    687                     Boolean.parseBoolean(_options.getProperty(PROP_DOMAIN_SOCKET)))
    688                 msg = "Failed to bind to the router and build tunnels";
     704                    _options.getProperty(PROP_DOMAIN_SOCKET) != null)
     705                msg = "Failed to bind to the router on " + _options.getProperty(PROP_DOMAIN_SOCKET) + " and build tunnels";
    689706            else
    690707                msg = "Cannot connect to the router on " + _hostname + ':' + _portNum + " and build tunnels";
Note: See TracChangeset for help on using the changeset viewer.