forked from I2P_Developers/i2p.i2p
Transport: Add methods to force-disconnect a peer
This commit is contained in:
@ -102,6 +102,13 @@ public abstract class CommSystemFacade implements Service {
|
|||||||
* @since 0.9.24
|
* @since 0.9.24
|
||||||
*/
|
*/
|
||||||
public void mayDisconnect(Hash peer) {}
|
public void mayDisconnect(Hash peer) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell the comm system to disconnect from this peer.
|
||||||
|
*
|
||||||
|
* @since 0.9.38
|
||||||
|
*/
|
||||||
|
public void forceDisconnect(Hash peer) {}
|
||||||
|
|
||||||
/** @since 0.8.11 */
|
/** @since 0.8.11 */
|
||||||
public String getOurCountry() { return null; }
|
public String getOurCountry() { return null; }
|
||||||
|
@ -195,6 +195,16 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
|
|||||||
_manager.mayDisconnect(peer);
|
_manager.mayDisconnect(peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell the comm system to disconnect from this peer.
|
||||||
|
*
|
||||||
|
* @since 0.9.38
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void forceDisconnect(Hash peer) {
|
||||||
|
_manager.forceDisconnect(peer);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getMostRecentErrorMessages() {
|
public List<String> getMostRecentErrorMessages() {
|
||||||
return _manager.getMostRecentErrorMessages();
|
return _manager.getMostRecentErrorMessages();
|
||||||
|
@ -196,4 +196,11 @@ public interface Transport {
|
|||||||
* @since 0.9.24
|
* @since 0.9.24
|
||||||
*/
|
*/
|
||||||
public void mayDisconnect(Hash peer);
|
public void mayDisconnect(Hash peer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell the transport to disconnect from this peer.
|
||||||
|
*
|
||||||
|
* @since 0.9.38
|
||||||
|
*/
|
||||||
|
public void forceDisconnect(Hash peer);
|
||||||
}
|
}
|
||||||
|
@ -555,6 +555,17 @@ public class TransportManager implements TransportEventListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell the transports to disconnect from this peer.
|
||||||
|
*
|
||||||
|
* @since 0.9.38
|
||||||
|
*/
|
||||||
|
void forceDisconnect(Hash peer) {
|
||||||
|
for (Transport t : _transports.values()) {
|
||||||
|
t.forceDisconnect(peer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Was the peer UNreachable (outbound only) on any transport,
|
* Was the peer UNreachable (outbound only) on any transport,
|
||||||
* based on the last time we tried it for each transport?
|
* based on the last time we tried it for each transport?
|
||||||
|
@ -640,6 +640,18 @@ public class NTCPTransport extends TransportImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell the transport to disconnect from this peer.
|
||||||
|
*
|
||||||
|
* @since 0.9.38
|
||||||
|
*/
|
||||||
|
public void forceDisconnect(Hash peer) {
|
||||||
|
NTCPConnection con = _conByIdent.remove(peer);
|
||||||
|
if (con != null) {
|
||||||
|
con.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return usually the con passed in, but possibly a second connection with the same peer...
|
* @return usually the con passed in, but possibly a second connection with the same peer...
|
||||||
* only con or null as of 0.9.37
|
* only con or null as of 0.9.37
|
||||||
|
@ -2679,6 +2679,18 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell the transport to disconnect from this peer.
|
||||||
|
*
|
||||||
|
* @since 0.9.38
|
||||||
|
*/
|
||||||
|
public void forceDisconnect(Hash peer) {
|
||||||
|
PeerState ps = _peersByIdent.get(peer);
|
||||||
|
if (ps != null) {
|
||||||
|
dropPeer(ps, true, "router");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean allowConnection() {
|
public boolean allowConnection() {
|
||||||
return _peersByIdent.size() < getMaxConnections();
|
return _peersByIdent.size() < getMaxConnections();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user