コード例 #1
0
    public void succeeded(InetSocketAddress rendezvous, InetSocketAddress target, Map reply) {
      removeRequest(this, OUTCOME_SUCCESS);

      if (Logger.isEnabled()) {
        Logger.log(
            new LogEvent(
                LOGID,
                "NAT traversal for " + initiator.getDisplayName() + "/" + target + " succeeded"));
      }

      adapter.success(target);
    }
コード例 #2
0
  public void create(
      PeerNATInitiator initiator, InetSocketAddress target, PeerNATTraversalAdapter adapter) {
    boolean bad = false;

    synchronized (initiators) {
      if (negative_result_bloom.contains(target.toString().getBytes())) {

        bad = true;

        failed_negative_bloom++;

      } else {

        LinkedList requests = (LinkedList) initiators.get(initiator);

        if (requests == null) {

          // we get here when download stopped at same time
          // Debug.out( "initiator not found" );

          bad = true;

        } else {

          PeerNATTraversal traversal = new PeerNATTraversal(initiator, target, adapter);

          requests.addLast(traversal);

          pending_requests.addLast(traversal);

          if (Logger.isEnabled()) {
            Logger.log(
                new LogEvent(
                    LOGID,
                    "created NAT traversal for " + initiator.getDisplayName() + "/" + target));
          }
        }
      }
    }

    if (bad) {

      adapter.failed();
    }
  }