Changeset 6e05368


Ignore:
Timestamp:
Dec 2, 2018 7:14:36 PM (2 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
633a75e
Parents:
ee722b7
Message:

Transport: Add methods to force-disconnect a peer

Location:
router/java/src/net/i2p/router
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/CommSystemFacade.java

    ree722b7 r6e05368  
    103103     */
    104104    public void mayDisconnect(Hash peer) {}
     105   
     106    /**
     107     * Tell the comm system to disconnect from this peer.
     108     *
     109     * @since 0.9.38
     110     */
     111    public void forceDisconnect(Hash peer) {}
    105112
    106113    /** @since 0.8.11 */
  • router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java

    ree722b7 r6e05368  
    194194    public void mayDisconnect(Hash peer) {
    195195        _manager.mayDisconnect(peer);
     196    }
     197   
     198    /**
     199     * Tell the comm system to disconnect from this peer.
     200     *
     201     * @since 0.9.38
     202     */
     203    @Override
     204    public void forceDisconnect(Hash peer) {
     205        _manager.forceDisconnect(peer);
    196206    }
    197207   
  • router/java/src/net/i2p/router/transport/Transport.java

    ree722b7 r6e05368  
    197197     */
    198198    public void mayDisconnect(Hash peer);
     199
     200    /**
     201     * Tell the transport to disconnect from this peer.
     202     *
     203     * @since 0.9.38
     204     */
     205    public void forceDisconnect(Hash peer);
    199206}
  • router/java/src/net/i2p/router/transport/TransportManager.java

    ree722b7 r6e05368  
    557557   
    558558    /**
     559     * Tell the transports to disconnect from this peer.
     560     *
     561     * @since 0.9.38
     562     */
     563    void forceDisconnect(Hash peer) {
     564        for (Transport t : _transports.values()) {
     565             t.forceDisconnect(peer);
     566        }
     567    }
     568   
     569    /**
    559570     * Was the peer UNreachable (outbound only) on any transport,
    560571     * based on the last time we tried it for each transport?
  • router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java

    ree722b7 r6e05368  
    642642
    643643    /**
     644     * Tell the transport to disconnect from this peer.
     645     *
     646     * @since 0.9.38
     647     */
     648    public void forceDisconnect(Hash peer) {
     649        NTCPConnection con = _conByIdent.remove(peer);
     650        if (con != null) {
     651            con.close();
     652        }
     653    }
     654
     655    /**
    644656     * @return usually the con passed in, but possibly a second connection with the same peer...
    645657     *         only con or null as of 0.9.37
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    ree722b7 r6e05368  
    26802680    }
    26812681
     2682    /**
     2683     * Tell the transport to disconnect from this peer.
     2684     *
     2685     * @since 0.9.38
     2686     */
     2687    public void forceDisconnect(Hash peer) {
     2688        PeerState ps =  _peersByIdent.get(peer);
     2689        if (ps != null) {
     2690            dropPeer(ps, true, "router");
     2691        }
     2692    }
     2693
    26822694    public boolean allowConnection() {
    26832695            return _peersByIdent.size() < getMaxConnections();
Note: See TracChangeset for help on using the changeset viewer.