Package com.subgraph.orchid

Examples of com.subgraph.orchid.RelayCell


        return;

      if(inputStream.unflushedCellCount() >= STREAMWINDOW_MAX_UNFLUSHED)
        return;

      final RelayCell sendme = circuit.createRelayCell(RelayCell.RELAY_SENDME, streamId, targetNode);
      circuit.sendRelayCell(sendme);
      deliverWindow += STREAMWINDOW_INCREMENT;
    }
  }
View Full Code Here


    if(autoclose) {
      circuit.markForClose();
    }
   
    if(!relayEndReceived) {
      final RelayCell cell = new RelayCellImpl(circuit.getFinalCircuitNode(), circuit.getCircuitId(), streamId, RelayCell.RELAY_END);
      cell.putByte(RelayCell.REASON_DONE);
      circuit.sendRelayCellToFinalNode(cell);
    }
  }
View Full Code Here

    }
  }

  public void openDirectory(long timeout) throws InterruptedException, TimeoutException, StreamConnectFailedException {
    streamTarget = "[Directory]";
    final RelayCell cell = new RelayCellImpl(circuit.getFinalCircuitNode(), circuit.getCircuitId(), streamId, RelayCell.RELAY_BEGIN_DIR);
    circuit.sendRelayCellToFinalNode(cell);
    waitForRelayConnected(timeout);
  }
View Full Code Here

    waitForRelayConnected(timeout);
  }

  void openExit(String target, int port, long timeout) throws InterruptedException, TimeoutException, StreamConnectFailedException {
    streamTarget = target + ":"+ port;
    final RelayCell cell = new RelayCellImpl(circuit.getFinalCircuitNode(), circuit.getCircuitId(), streamId, RelayCell.RELAY_BEGIN);
    cell.putString(target + ":"+ port);
    circuit.sendRelayCellToFinalNode(cell);
    waitForRelayConnected(timeout);
  }
View Full Code Here

    inputStream.close();
    verify(mockStream);
  }
 
  private static RelayCell createDataCell(byte[] data) {
    final RelayCell cell = createMock("dataCell", RelayCell.class);
    expect(cell.cellBytesRemaining()).andReturn(data.length);
    expectLastCall().times(2);
    expect(cell.getRelayCommand()).andReturn(RelayCell.RELAY_DATA);
    expect(cell.getPayloadBuffer()).andReturn(ByteBuffer.wrap(data));
    replay(cell);
    return cell;
  }
View Full Code Here

    replay(cell);
    return cell;
  }
 
  private static RelayCell createEndCell() {
    final RelayCell cell = createMock("endCell", RelayCell.class);
    expect(cell.getRelayCommand()).andReturn(RelayCell.RELAY_END);
    replay(cell);
    return cell;
  }
View Full Code Here

  TorPublicKey getServiceKey() {
    return introductionPoint.getServiceKey();
  }
 
  boolean sendIntroduce(TorPublicKey permanentKey, byte[] publicKeyBytes, byte[] rendezvousCookie, Router rendezvousRouter) {
    final RelayCell introduceCell = introductionCircuit.createRelayCell(RelayCell.RELAY_COMMAND_INTRODUCE1, 0, introductionCircuit.getFinalCircuitNode());

    final byte[] payload = createIntroductionPayload(rendezvousRouter, publicKeyBytes, rendezvousCookie, permanentKey);
    final TorPublicKey serviceKey = introductionPoint.getServiceKey();
    introduceCell.putByteArray(serviceKey.getFingerprint().getRawBytes());
    introduceCell.putByteArray(payload);
    introductionCircuit.sendRelayCell(introduceCell);
   
    final RelayCell response = introductionCircuit.receiveRelayCell();
    if(response == null) {
      logger.fine("Timeout waiting for response to INTRODUCE1 cell");
      return false;
    } else if(response.getRelayCommand() != RelayCell.RELAY_COMMAND_INTRODUCE_ACK) {
      logger.info("Unexpected relay cell type received waiting for response to INTRODUCE1 cell: "+ response.getRelayCommand());
      return false;
    } else if(response.cellBytesRemaining() == 0) {
      return true;
    } else {
      logger.info("INTRODUCE_ACK indicates that introduction was not forwarded: "+ response.getByte());
      return false;
    }
  }
View Full Code Here

    this.circuit = circuit;
    this.cookie = random.getBytes(RENDEZVOUS_COOKIE_LEN);
  }
 
  boolean establishRendezvous() {
    final RelayCell cell = circuit.createRelayCell(RelayCell.RELAY_COMMAND_ESTABLISH_RENDEZVOUS, 0, circuit.getFinalCircuitNode());
    cell.putByteArray(cookie);
    circuit.sendRelayCell(cell);
    final RelayCell response = circuit.receiveRelayCell();
    if(response == null) {
      logger.info("Timeout waiting for Rendezvous establish response");
      return false;
    } else if(response.getRelayCommand() != RelayCell.RELAY_COMMAND_RENDEZVOUS_ESTABLISHED) {
      logger.info("Response received from Rendezvous establish was not expected acknowledgement, Relay Command: "+ response.getRelayCommand());
      return false;
    } else {
      return true;
    }
  }
View Full Code Here

      return true;
    }
  }
 
  HiddenServiceCircuit processRendezvous2(TorTapKeyAgreement kex) {
    final RelayCell cell = circuit.receiveRelayCell();
    if(cell == null) {
      logger.info("Timeout waiting for RENDEZVOUS2");
      return null;
    } else if (cell.getRelayCommand() != RelayCell.RELAY_COMMAND_RENDEZVOUS2) {
      logger.info("Unexpected Relay cell type received while waiting for RENDEZVOUS2: "+ cell.getRelayCommand());
      return null;
    }
    final BigInteger peerPublic = readPeerPublic(cell);
    final HexDigest handshakeDigest = readHandshakeDigest(cell);
    if(peerPublic == null || handshakeDigest == null) {
View Full Code Here

  }

  /* This is called by the cell reading thread in ConnectionImpl to deliver RELAY cells. */
  void deliverRelayCell(Cell cell) {
    circuit.getStatus().updateDirtyTimestamp();
    final RelayCell relayCell = decryptRelayCell(cell);
    logRelayCell("Dispatching: ", relayCell);
    switch(relayCell.getRelayCommand()) {
    case RelayCell.RELAY_EXTENDED:
    case RelayCell.RELAY_EXTENDED2:
    case RelayCell.RELAY_RESOLVED:
    case RelayCell.RELAY_TRUNCATED:
    case RelayCell.RELAY_COMMAND_RENDEZVOUS_ESTABLISHED:
    case RelayCell.RELAY_COMMAND_INTRODUCE_ACK:
    case RelayCell.RELAY_COMMAND_RENDEZVOUS2:
      relayCellResponseQueue.add(relayCell);
      break
    case RelayCell.RELAY_DATA:
    case RelayCell.RELAY_END:
    case RelayCell.RELAY_CONNECTED:
      processRelayDataCell(relayCell);
      break;

    case RelayCell.RELAY_SENDME:
      if(relayCell.getStreamId() != 0)
        processRelayDataCell(relayCell);
      else
        processCircuitSendme(relayCell);
      break;
    case RelayCell.RELAY_BEGIN:
    case RelayCell.RELAY_BEGIN_DIR:
    case RelayCell.RELAY_EXTEND:
    case RelayCell.RELAY_RESOLVE:
    case RelayCell.RELAY_TRUNCATE:
      destroyCircuit();
      throw new TorException("Unexpected 'forward' direction relay cell type: "+ relayCell.getRelayCommand());
    }
  }
View Full Code Here

TOP

Related Classes of com.subgraph.orchid.RelayCell

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.