Package com.subgraph.orchid

Examples of com.subgraph.orchid.Router


    this.useCompression = useCompression;
  }
 
  private static String getHostnameFromStream(Stream stream) {
    final StringBuilder sb = new StringBuilder();
    final Router r = stream.getCircuit().getFinalCircuitNode().getRouter();
    if(r == null) {
      return null;
    }
    sb.append(r.getAddress().toString());
    if(r.getOnionPort() != 80) {
      sb.append(":");
      sb.append(r.getOnionPort());
    }
    return sb.toString();
  }
View Full Code Here


    final HexDigest id = HexDigest.createFromString(identity);
    return directory.getRouterByIdentity(id);
  }

  public boolean testCurrentlyUsable() {
    final Router router = getRouterForEntry();
    boolean isUsable = router != null && router.isValid() && router.isPossibleGuard() && router.isRunning();
    if(isUsable) {
      markUsable();
      return true;
    } else {
      markUnusable();
View Full Code Here

    launchBuildTaskForTargets(exitTargets);
  }

  private void launchBuildTaskForTargets(List<ExitTarget> exitTargets) {
    final Router exitRouter = pathChooser.chooseExitNodeForTargets(exitTargets);
    if(exitRouter == null) {
      logger.warning("Failed to select suitable exit node for targets");
      return;
    }
   
View Full Code Here

    }
    return null;
  }
 
  private Circuit attemptOpenIntroductionCircuit(IntroductionPoint ip) {
    final Router r = directory.getRouterByIdentity(ip.getIdentity());
    if(r == null) {
      return null;
    }
   
    try {
View Full Code Here

    for(String s: invalidStrings) { assertFalse(s, ConfigNodeFilter.isCountryCodeString(s)); }
  }
 
  private Router createRouterMockWithAddress(String ip) {
    final IPv4Address address = IPv4Address.createFromString(ip);
    final Router router = createMock("mockRouter", Router.class);
    expect(router.getAddress()).andReturn(address);
    replay(router);
    return router;
  }
View Full Code Here

    return router;
  }
 
  @Test
  public void testMaskFilter() {
    final Router r1 = createRouterMockWithAddress("1.2.3.4");
    final Router r2 = createRouterMockWithAddress("1.7.3.4");
    final RouterFilter f = ConfigNodeFilter.createFilterFor("1.2.3.0/16");
    assertTrue(f.filter(r1));
    assertFalse(f.filter(r2));
    verify(r1, r2);
  }
View Full Code Here

      if(router.isDescriptorDownloadable())
        routers.add(router);
    }

    for(int i = 0; i < routers.size(); i++) {
      final Router a = routers.get(i);
      final int swapIdx = random.nextInt(routers.size());
      final Router b = routers.get(swapIdx);
      routers.set(i, b);
      routers.set(swapIdx, a);
    }

    return routers;
View Full Code Here

  public List<Router> getRouterListByNames(List<String> names) {
    waitUntilLoaded();
    final List<Router> routers = new ArrayList<Router>();
    for(String n: names) {
      final Router r = getRouterByName(n);
      if(r == null)
        throw new TorException("Could not find router named: "+ n);
      routers.add(r);
    }
    return routers;
View Full Code Here

  protected void verifyIdentityKey(PublicKey publicKey) throws ConnectionHandshakeException {
    if(!(publicKey instanceof RSAPublicKey)) {
      throw new ConnectionHandshakeException("Identity certificate public key is not an RSA key as expected");
    }
    final TorPublicKey identityKey = new TorPublicKey((RSAPublicKey)publicKey);
    final Router router = connection.getRouter();
    if((router instanceof BridgeRouter) && (router.getIdentityHash() == null)) {
      logger.info("Setting Bridge fingerprint from connection handshake for "+ router);
      ((BridgeRouter) router).setIdentity(identityKey.getFingerprint());
    } else if(!identityKey.getFingerprint().equals(router.getIdentityHash())) {
      throw new ConnectionHandshakeException("Router identity does not match certificate key");
    }
  }
View Full Code Here

  private String nodeToName(CircuitNode node) {
    if(node == null || node.getRouter() == null) {
      return "(null)";
    }
    final Router router = node.getRouter();
    return router.getNickname();
  }
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.