Package freenet.io.comm

Examples of freenet.io.comm.Peer


    setDetectedPeer(newPeer);
  }

  private void setDetectedPeer(Peer newPeer) {
    // Also, we need to call .equals() to propagate any DNS lookups that have been done if the two have the same domain.
    Peer p = newPeer;
    newPeer = newPeer.dropHostName();
    if(newPeer == null) {
      Logger.error(this, "Impossible: No address for detected peer! "+p+" on "+this);
      return;
    }
    synchronized(this) {
      Peer oldPeer = detectedPeer;
      if((newPeer != null) && ((oldPeer == null) || !oldPeer.equals(newPeer))) {
        this.detectedPeer = newPeer;
        updateShortToString();
        // IP has changed, it is worth looking up the DNS address again.
        this.lastAttemptedHandshakeIPUpdateTime = 0;
        if(!isConnected())
View Full Code Here


        nominalPeer = new ArrayList<Peer>(physical.length);

        Peer[] oldPeers = oldNominalPeer.toArray(new Peer[oldNominalPeer.size()]);

        for(String phys: physical) {
          Peer p;
          try {
            p = new Peer(phys, true, true);
          } catch(HostnameSyntaxException e) {
            Logger.error(this, "Invalid hostname or IP Address syntax error while parsing new peer reference: " + phys);
            continue;
          } catch (PeerParseException e) {
            Logger.error(this, "Invalid hostname or IP Address syntax error while parsing new peer reference: " + phys);
View Full Code Here

    assert reason.indexOf(' ') == -1;
    pRejected.report(1.0);
    if(logMINOR)
      Logger.minor(this, "Local rejected overload (" + reason + ") on " + this + " : pRejected=" + pRejected.currentValue());
    long now = System.currentTimeMillis();
    Peer peer = getPeer();
    reportBackoffStatus(now);
    // We need it because of nested locking on getStatus()
    synchronized(this) {
      // Don't back off any further if we are already backed off
      long routingBackedOffUntil = realTime ? routingBackedOffUntilRT : routingBackedOffUntilBulk;
View Full Code Here

   */
  public void successNotOverload(boolean realTime) {
    pRejected.report(0.0);
    if(logMINOR)
      Logger.minor(this, "Success not overload on " + this + " : pRejected=" + pRejected.currentValue());
    Peer peer = getPeer();
    long now = System.currentTimeMillis();
    reportBackoffStatus(now);
    synchronized(this) {
      // Don't un-backoff if still backed off
      long until;
View Full Code Here

    assert reason.indexOf(' ') == -1;
    pRejected.report(1.0);
    if(logMINOR)
      Logger.minor(this, "Transfer failed (" + reason + ") on " + this + " : pRejected=" + pRejected.currentValue());
    long now = System.currentTimeMillis();
    Peer peer = getPeer();
    reportBackoffStatus(now);
    // We need it because of nested locking on getStatus()
    synchronized(this) {
      // Don't back off any further if we are already backed off
      long transferBackedOffUntil = realTime ? transferBackedOffUntilRT : transferBackedOffUntilBulk;
View Full Code Here

   */
  public void transferSuccess(boolean realTime) {
    pRejected.report(0.0);
    if(logMINOR)
      Logger.minor(this, "Transfer success on " + this + " : pRejected=" + pRejected.currentValue());
    Peer peer = getPeer();
    long now = System.currentTimeMillis();
    reportBackoffStatus(now);
    synchronized(this) {
      // Don't un-backoff if still backed off
      long until;
View Full Code Here

          continue;
        }
      }
      validIPs.add(peer);
    }
    Peer ret;
    if(validIPs.isEmpty()) {
      ret = null;
    } else if(validIPs.size() == 1) {
      ret = validIPs.get(0);
    } else {
View Full Code Here

   
    if(logMINOR) Logger.minor(this, "Checking whether should detect with "+peers.length+" peers and "+conns.length+" conns, counting peers...");
    for(PeerNode p: peers) {
      if(p.isDisabled()) continue;
      // Don't count localhost, LAN addresses.
      Peer peer = p.getPeer();
      if(peer == null) continue;
      FreenetInetAddress a = peer.getFreenetAddress();
      if(a == null) continue; // Not much chance of connecting.
      InetAddress addr = a.getAddress(false);
      if(addr != null) {
        if(!IPUtil.isValidAddress(addr, false)) continue;
      }
View Full Code Here

    boolean hasOldPeers = false;
    for(PeerNode p : peers) {
      if(p.isConnected() || (now - p.lastReceivedPacketTime() < HOURS.toMillis(24))) {
        // Has been connected in the last 24 hours.
        // Unique IP address?
        Peer peer = p.getPeer();
        if(peer != null){
          InetAddress addr = peer.getAddress(false);
          if(p.isConnected() && (addr != null) && IPUtil.isValidAddress(peer.getAddress(), false)) {
            // Connected node, on a real internet IP address.
            // Is it internal?
            boolean internal = false;
            for(FreenetInetAddress nodeAddr: nodeAddrs) {
              if(addr.equals(nodeAddr.getAddress(false))) {
View Full Code Here

TOP

Related Classes of freenet.io.comm.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.