Package com.turn.ttorrent.common

Examples of com.turn.ttorrent.common.Peer


    throws InvalidBEncodingException {
    List<Peer> result = new LinkedList<Peer>();

    for (BEValue peer : peers) {
      Map<String, BEValue> peerInfo = peer.getMap();
      result.add(new Peer(
        peerInfo.get("ip").getString(Torrent.BYTE_ENCODING),
        peerInfo.get("port").getInt()));
    }

    return result;
View Full Code Here


      peers.get(ipBytes);
      InetAddress ip = InetAddress.getByAddress(ipBytes);
      int port =
        (0xFF & (int)peers.get()) << 8 |
        (0xFF & (int)peers.get());
      result.add(new Peer(new InetSocketAddress(ip, port)));
    }

    return result;
  }
View Full Code Here

        data.get(ipBytes);
        InetAddress ip = InetAddress.getByAddress(ipBytes);
        int port =
          (0xFF & (int)data.get()) << 8 |
          (0xFF & (int)data.get());
        peers.add(new Peer(new InetSocketAddress(ip, port)));
      } catch (UnknownHostException uhe) {
        throw new MessageValidationException(
          "Invalid IP address in announce request!");
      }
    }
View Full Code Here

        event = RequestEvent.getByName(params.get("event")
          .getString(Torrent.BYTE_ENCODING));
      }

      return new HTTPAnnounceRequestMessage(data, infoHash,
        new Peer(ip, port, ByteBuffer.wrap(peerId)),
        uploaded, downloaded, left, compact, noPeerId,
        event, numWant);
    } catch (InvalidBEncodingException ibee) {
      throw new MessageValidationException(
        "Invalid HTTP tracker request!", ibee);
View Full Code Here

      params.put("numwant", new BEValue(numWant));
    }

    return new HTTPAnnounceRequestMessage(
      BEncoder.bencode(params),
      infoHash, new Peer(ip, port, ByteBuffer.wrap(peerId)),
      uploaded, downloaded, left, compact, noPeerId, event, numWant);
  }
View Full Code Here

    // Initialize the incoming connection handler and register ourselves to
    // it.
    this.service = new ConnectionHandler(this.torrent, id, address);
    this.service.register(this);

    this.self = new Peer(
      this.service.getSocketAddress()
        .getAddress().getHostAddress(),
      (short)this.service.getSocketAddress().getPort(),
      ByteBuffer.wrap(id.getBytes(Torrent.BYTE_ENCODING)));
View Full Code Here

   * handshake, after validation.
   * @see com.turn.ttorrent.client.peer.SharingPeer
   */
  @Override
  public void handleNewPeerConnection(SocketChannel channel, byte[] peerId) {
    Peer search = new Peer(
      channel.socket().getInetAddress().getHostAddress(),
      channel.socket().getPort(),
      (peerId != null
        ? ByteBuffer.wrap(peerId)
        : (ByteBuffer)null));
View Full Code Here

TOP

Related Classes of com.turn.ttorrent.common.Peer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.