Changeset 8451610


Ignore:
Timestamp:
Dec 20, 2010 7:37:38 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
8e40b35
Parents:
ad00c16
Message:

Several connect-to-self checks

Location:
apps/i2psnark/java/src/org/klomp/snark
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • apps/i2psnark/java/src/org/klomp/snark/ConnectionAcceptor.java

    rad00c16 r8451610  
    138138                }
    139139            } else {
     140                if (socket.getPeerDestination().equals(_util.getMyDestination())) {
     141                    _util.debug("Incoming connection from myself", Snark.ERROR);
     142                    try { socket.close(); } catch (IOException ioe) {}
     143                    continue;
     144                }
    140145                Thread t = new I2PAppThread(new Handler(socket), "I2PSnark incoming connection");
    141146                t.start();
  • apps/i2psnark/java/src/org/klomp/snark/I2PSnarkUtil.java

    rad00c16 r8451610  
    228228        if (addr == null)
    229229            throw new IOException("Null address");
     230        if (addr.equals(getMyDestination()))
     231            throw new IOException("Attempt to connect to myself");
    230232        Hash dest = addr.calculateHash();
    231233        if (_shitlist.contains(dest))
     
    301303   
    302304    String getOurIPString() {
     305        Destination dest = getMyDestination();
     306        if (dest != null)
     307            return dest.toBase64();
     308        return "unknown";
     309    }
     310
     311    /**
     312     *  @return dest or null
     313     *  @since 0.8.4
     314     */
     315    Destination getMyDestination() {
    303316        if (_manager == null)
    304             return "unknown";
     317            return null;
    305318        I2PSession sess = _manager.getSession();
    306         if (sess != null) {
    307             Destination dest = sess.getMyDestination();
    308             if (dest != null)
    309                 return dest.toBase64();
    310         }
    311         return "unknown";
     319        if (sess != null)
     320            return sess.getMyDestination();
     321        return null;
    312322    }
    313323
  • apps/i2psnark/java/src/org/klomp/snark/Peer.java

    rad00c16 r8451610  
    3131
    3232import net.i2p.client.streaming.I2PSocket;
     33import net.i2p.data.DataHelper;
    3334import net.i2p.util.Log;
    3435
     
    354355        _log.debug("Read the remote side's hash and peerID fully from " + toString());
    355356
     357    if (DataHelper.eq(my_id, bs))
     358        throw new IOException("Connected to myself");
     359
    356360    if (options != 0) {
    357361        // send them something in runConnection() above
Note: See TracChangeset for help on using the changeset viewer.