Package com.subgraph.orchid

Examples of com.subgraph.orchid.Router


    return chooseFirstElementAboveRandom(random.nextLong(total));
  }
 
  void adjustWeights(double exitWeight, double guardWeight) {
    for(WeightedRouter wr: weightedRouters) {
      Router r = wr.router;
      if(r.isExit() && r.isPossibleGuard()) {
        wr.weightedBandwidth *= (exitWeight * guardWeight);
      } else if(r.isPossibleGuard()) {
        wr.weightedBandwidth *= guardWeight;
      } else if(r.isExit()) {
        wr.weightedBandwidth *= exitWeight;
      }
    }
    scaleRouterWeights();
  }
View Full Code Here


    scaleRouterWeights();
  }

  private Router chooseFirstElementAboveRandom(long randomValue) {
    long sum = 0;
    Router chosen = null;
    for(WeightedRouter wr: weightedRouters) {
      sum += wr.scaledBandwidth;
      if(sum > randomValue) {
        chosen = wr.router;
        /* Don't return early to avoid leaking timing information about choice */
 
View Full Code Here

  }

  public List<Router> chooseDirectoryPath() throws InterruptedException {
    if(useEntryGuards && entryGuards.isUsingBridges()) {
      final Set<Router> empty = Collections.emptySet();
      final Router bridge = entryGuards.chooseRandomGuard(empty);
      if(bridge == null) {
        throw new IllegalStateException("Failed to choose bridge for directory request");
      }
      return Arrays.asList(bridge);
    }
    final Router dir = nodeChooser.chooseDirectory();
    return Arrays.asList(dir);
  }
View Full Code Here

    return Arrays.asList(dir);
  }
 
  public List<Router> chooseInternalPath() throws InterruptedException, PathSelectionFailedException {
    final Set<Router> excluded = Collections.emptySet();
    final Router finalRouter = chooseMiddleNode(excluded);
    return choosePathWithFinal(finalRouter);
  }
View Full Code Here

  public List<Router> choosePathWithFinal(Router finalRouter) throws InterruptedException, PathSelectionFailedException {
    final Set<Router> excluded = new HashSet<Router>();
    excludeChosenRouterAndRelated(finalRouter, excluded);

    final Router middleRouter = chooseMiddleNode(excluded);
    if(middleRouter == null) {
      throw new PathSelectionFailedException("Failed to select suitable middle node");
    }
    excludeChosenRouterAndRelated(middleRouter, excluded);

    final Router entryRouter = chooseEntryNode(excluded);
    if(entryRouter == null) {
      throw new PathSelectionFailedException("Failed to select suitable entry node");
    }
    return Arrays.asList(entryRouter, middleRouter, finalRouter);
  }
View Full Code Here

        excludedRouters.add(r);
      }
    }
   
    for(String s: router.getFamilyMembers()) {
      Router r = directory.getRouterByName(s);
      if(r != null) {
        // Is mutual?
        if(isFamilyMember(r.getFamilyMembers(), router)) {
          excludedRouters.add(r);
        }
      }
    }
  }
View Full Code Here

    }
  }
 
  private boolean isFamilyMember(Collection<String> familyMemberNames, Router r) {
    for(String s: familyMemberNames) {
      Router member = directory.getRouterByName(s);
      if(member != null && member.equals(r)) {
        return true;
      }
    }
    return false;
  }
View Full Code Here

    }
   
    final int[] nSupport = new int[routers.size()];
   
    for(int i = 0; i < routers.size(); i++) {
      final Router r = routers.get(i);
      nSupport[i] = countTargetSupport(r, exitTargets);
      if(nSupport[i] > bestSupport) {
        bestSupport = nSupport[i];
      }
    }
View Full Code Here

    this.circuit = request.getCircuit();
    this.extender = new CircuitExtender(request.getCircuit(), ntorEnabled);
  }

  public void run() {
    Router firstRouter = null;
    try {
      circuit.notifyCircuitBuildStart();
      creationRequest.choosePath();
      if(logger.isLoggable(Level.FINE)) {
        logger.fine("Opening a new circuit to "+ pathToString(creationRequest));
View Full Code Here

      public boolean filter(Router router) {
        return router.getDirectoryPort() != 0;
      }
    };
    final List<Router> candidates = getFilteredRouters(filter, false);
    final Router choice = chooseByBandwidth(candidates, WeightRule.WEIGHT_FOR_DIR);
    if(choice == null) {
      return directory.getRandomDirectoryAuthority();
    } else {
      return choice;
    }
View Full Code Here

TOP

Related Classes of com.subgraph.orchid.Router

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.