/** * Incoming connection. Creates a unconnected peer from the input and output stream got from the * socket. Note that the complete handshake (which can take some time or block indefinitely) is * done in the calling Thread to get the remote peer id. To completely start the connection call * the connect() method. * * @param metainfo null if in magnet mode * @exception IOException when an error occurred during the handshake. */ public Peer( final I2PSocket sock, InputStream in, OutputStream out, byte[] my_id, byte[] infohash, MetaInfo metainfo) throws IOException { this.my_id = my_id; this.infohash = infohash; this.metainfo = metainfo; this.sock = sock; byte[] id = handshake(in, out); this.peerID = new PeerID(id, sock.getPeerDestination()); _id = ++__id; if (_log.shouldLog(Log.DEBUG)) _log.debug("Creating a new peer " + peerID.toString(), new Exception("creating " + _id)); }
/** @since 0.8.4 */ public Destination getDestination() { if (sock == null) return null; return sock.getPeerDestination(); }