forked from I2P_Developers/i2p.i2p
Hooks into streaming for filtering of incoming connections
This commit is contained in:
@@ -21,6 +21,7 @@ import net.i2p.util.ConvertToHash;
|
||||
import net.i2p.util.LHMCache;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.SimpleTimer2;
|
||||
import net.i2p.client.streaming.IncomingConnectionFilter;
|
||||
|
||||
/**
|
||||
* Coordinate all of the connections for a single local destination.
|
||||
@@ -38,6 +39,7 @@ class ConnectionManager {
|
||||
private final SchedulerChooser _schedulerChooser;
|
||||
private final ConnectionPacketHandler _conPacketHandler;
|
||||
private final TCBShare _tcbShare;
|
||||
private final IncomingConnectionFilter _connectionFilter;
|
||||
/** Inbound stream ID (Long) to Connection map */
|
||||
private final ConcurrentHashMap<Long, Connection> _connectionByInboundId;
|
||||
/** Ping ID (Long) to PingRequest */
|
||||
@@ -81,10 +83,14 @@ class ConnectionManager {
|
||||
/**
|
||||
* Manage all conns for this session
|
||||
*/
|
||||
public ConnectionManager(I2PAppContext context, I2PSession session, ConnectionOptions defaultOptions) {
|
||||
public ConnectionManager(I2PAppContext context,
|
||||
I2PSession session,
|
||||
ConnectionOptions defaultOptions,
|
||||
IncomingConnectionFilter connectionFilter) {
|
||||
_context = context;
|
||||
_session = session;
|
||||
_defaultOptions = defaultOptions;
|
||||
_connectionFilter = connectionFilter;
|
||||
_log = _context.logManager().getLog(ConnectionManager.class);
|
||||
_connectionByInboundId = new ConcurrentHashMap<Long,Connection>(32);
|
||||
_pendingPings = new ConcurrentHashMap<Long,PingRequest>(4);
|
||||
@@ -655,6 +661,10 @@ class ConnectionManager {
|
||||
" per minute";
|
||||
}
|
||||
|
||||
if (!_connectionFilter.allowDestination(from)) {
|
||||
return "not allowed by filter";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import net.i2p.client.streaming.I2PServerSocket;
|
||||
import net.i2p.client.streaming.I2PSocket;
|
||||
import net.i2p.client.streaming.I2PSocketManager;
|
||||
import net.i2p.client.streaming.I2PSocketOptions;
|
||||
import net.i2p.client.streaming.IncomingConnectionFilter;
|
||||
import net.i2p.crypto.SigAlgo;
|
||||
import net.i2p.crypto.SigType;
|
||||
import net.i2p.data.Certificate;
|
||||
@@ -191,7 +192,8 @@ public class I2PSocketManagerFull implements I2PSocketManager {
|
||||
* @param opts may be null
|
||||
* @param name non-null
|
||||
*/
|
||||
public I2PSocketManagerFull(I2PAppContext context, I2PSession session, Properties opts, String name) {
|
||||
public I2PSocketManagerFull(I2PAppContext context, I2PSession session, Properties opts, String name,
|
||||
IncomingConnectionFilter connectionFilter) {
|
||||
_context = context;
|
||||
_session = session;
|
||||
_subsessions = new ConcurrentHashSet<I2PSession>(4);
|
||||
@@ -200,7 +202,7 @@ public class I2PSocketManagerFull implements I2PSocketManager {
|
||||
_name = name + " " + (__managerId.incrementAndGet());
|
||||
_acceptTimeout = ACCEPT_TIMEOUT_DEFAULT;
|
||||
_defaultOptions = new ConnectionOptions(opts);
|
||||
_connectionManager = new ConnectionManager(_context, _session, _defaultOptions);
|
||||
_connectionManager = new ConnectionManager(_context, _session, _defaultOptions, connectionFilter);
|
||||
_serverSocket = new I2PServerSocketFull(this);
|
||||
|
||||
if (_log.shouldLog(Log.INFO)) {
|
||||
|
||||
Reference in New Issue
Block a user