Changeset c777109 for apps


Ignore:
Timestamp:
Mar 27, 2019 3:04:04 PM (21 months ago)
Author:
zab2 <zab2@…>
Branches:
master
Children:
473ced4
Parents:
b35762b
Message:

hook up loading of filter definitions for server tunnels

Location:
apps/i2ptunnel/java/src/net/i2p/i2ptunnel
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java

    rb35762b rc777109  
    105105
    106106    public long readTimeout = -1;
     107
     108    public String filterDefinition;
    107109
    108110    private static final String nocli_args[] = { "-nocli", "-die"};
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java

    rb35762b rc777109  
    3131
    3232import net.i2p.I2PException;
     33import net.i2p.I2PAppContext;
    3334import net.i2p.client.I2PClient;
    3435import net.i2p.client.I2PSession;
     
    3940import net.i2p.client.streaming.I2PSocketManagerFactory;
    4041import net.i2p.client.streaming.RouterRestartException;
     42import net.i2p.client.streaming.IncomingConnectionFilter;
    4143import net.i2p.crypto.SigType;
    4244import net.i2p.data.Base64;
     
    4648import net.i2p.util.I2PSSLSocketFactory;
    4749import net.i2p.util.Log;
     50import net.i2p.i2ptunnel.access.FilterFactory;
     51import net.i2p.i2ptunnel.access.InvalidDefinitionException;
    4852
    4953public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
     
    219223            }
    220224        }
     225
     226        IncomingConnectionFilter filter = IncomingConnectionFilter.ALLOW;
     227        if (getTunnel().filterDefinition != null) {
     228            File filterDefinition = new File(getTunnel().filterDefinition);
     229            I2PAppContext context = getTunnel().getContext();
     230            try {
     231                filter = FilterFactory.createFilter(context, filterDefinition);
     232            } catch (IOException | InvalidDefinitionException bad) {
     233                throw new IllegalArgumentException("Can't create socket manager", bad);
     234            }
     235        }
    221236        try {
    222237            I2PSocketManager rv = I2PSocketManagerFactory.createDisconnectedManager(privData, getTunnel().host,
    223                                                                                     portNum, props);
     238                                                                                    portNum, props, filter);
    224239            rv.setName("I2PTunnel Server");
    225240            getTunnel().addSession(rv.getSession());
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java

    rb35762b rc777109  
    8686    public static final String PROP_TARGET_PORT = "targetPort";
    8787    public static final String PROP_TYPE = "type";
     88    public static final String PROP_FILTER = "filterDefinition";
    8889   
    8990    /**
     
    835836            }
    836837            if (!isClient(type)) {
     838                _tunnel.filterDefinition = _config.getProperty(PROP_FILTER);
     839             
    837840                String p1 = _config.getProperty(OPT_MAX_CONNS_MIN, "0");
    838841                String p2 = _config.getProperty(OPT_MAX_CONNS_HOUR, "0");
Note: See TracChangeset for help on using the changeset viewer.