Package com.subgraph.orchid

Examples of com.subgraph.orchid.Cell


    return myAddress;
  }
 
  protected Cell expectCell(Integer... expectedTypes) throws ConnectionHandshakeException {
    try {
      final Cell c = connection.readConnectionControlCell();
      for(int t: expectedTypes) {
        if(c.getCommand() == t) {
          return c;
        }
      }
      final List<Integer> expected = Arrays.asList(expectedTypes);
      throw new ConnectionHandshakeException("Expecting Cell command "+ expected + " and got [ "+ c.getCommand() +" ] instead");
    } catch (ConnectionIOException e) {
      throw new ConnectionHandshakeException("Connection exception while performing handshake "+ e);
    }
  }
View Full Code Here


      throw new ConnectionHandshakeException("Connection exception while performing handshake "+ e);
    }
  }

  protected  void sendVersions(int... versions) throws ConnectionIOException {
    final Cell cell = CellImpl.createVarCell(0, Cell.VERSIONS, versions.length * 2);
    for(int v: versions) {
      cell.putShort(v);
    }
    connection.sendCell(cell);
  }
View Full Code Here

    }
    connection.sendCell(cell);
  }

  protected void receiveVersions() throws ConnectionHandshakeException {
    final Cell c = expectCell(Cell.VERSIONS);
    while(c.cellBytesRemaining() >= 2) {
      remoteVersions.add(c.getShort());
    }
  }
View Full Code Here

      remoteVersions.add(c.getShort());
    }
  }

  protected void sendNetinfo() throws ConnectionIOException {
    final Cell cell = CellImpl.createCell(0, Cell.NETINFO);
    putTimestamp(cell);
    putIPv4Address(cell, connection.getRouter().getAddress());
    putMyAddresses(cell);
    connection.sendCell(cell);
  }
View Full Code Here

    circuit.setStateDestroyed();
    isClosed = true;
  }

  void sendDestroyCell(int reason) {
    Cell destroy = CellImpl.createCell(circuitId, Cell.DESTROY);
    destroy.putByte(reason);
    try {
      connection.sendCell(destroy);
    } catch (ConnectionIOException e) {
      logger.warning("Connection IO error sending DESTROY cell: "+ e.getMessage());
    }
View Full Code Here

    verifyCertificates();
    sendNetinfo();
  }
 
  void recvCerts() throws ConnectionHandshakeException  {
    final Cell cell = expectCell(Cell.CERTS);
    final int ncerts = cell.getByte();
    if(ncerts != 2) {
      throw new ConnectionHandshakeException("Expecting 2 certificates and got "+ ncerts);
    }

    linkCertificate = null;
    identityCertificate = null;
   
    for(int i = 0; i < ncerts; i++) {
      int type = cell.getByte();
      if(type == 1) {
        linkCertificate = testAndReadCertificate(cell, linkCertificate, "Link (type = 1)");
      } else if(type == 2) {
        identityCertificate = testAndReadCertificate(cell, identityCertificate, "Identity (type = 2)");
      } else {
View Full Code Here

      throw new ConnectionHandshakeException("Link certificate in CERTS cell does not match connection certificate");
    }
  }

  void recvAuthChallengeAndNetinfo() throws ConnectionHandshakeException {
    final Cell cell = expectCell(Cell.AUTH_CHALLENGE, Cell.NETINFO);
    if(cell.getCommand() == Cell.NETINFO) {
      processNetInfo(cell);
      return;
    }
    final Cell netinfo = expectCell(Cell.NETINFO);
    processNetInfo(netinfo);
  }
View Full Code Here

    sendCreateFastCell(kex);
    return receiveAndProcessCreateFastResponse(targetRouter, kex);
  }

  private void sendCreateFastCell(TorCreateFastKeyAgreement kex) {
    final Cell cell = CellImpl.createCell(circuit.getCircuitId(), Cell.CREATE_FAST);
    cell.putByteArray(kex.createOnionSkin());
    circuit.sendCell(cell);
  }
View Full Code Here

    cell.putByteArray(kex.createOnionSkin());
    circuit.sendCell(cell);
  }
 
  private CircuitNode receiveAndProcessCreateFastResponse(Router targetRouter, TorKeyAgreement kex) {
    final Cell cell = circuit.receiveControlCellResponse();
    if(cell == null) {
      throw new TorException("Timeout building circuit waiting for CREATE_FAST response from "+ targetRouter);
    }

    return processCreatedFastCell(targetRouter, cell, kex);
View Full Code Here

TOP

Related Classes of com.subgraph.orchid.Cell

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.