Exemple #1
0
bool SessionInitializer::setUpNightmare(qi::SessionPtr session, const std::string &serviceDirectoryUrl)
{
  std::string serviceName;

  // #1 Connect session to service directory.
  if(session->connect(serviceDirectoryUrl).wait(1000) != qi::FutureState_FinishedWithValue)
    return false;

  // #1.1 If session is a client session, that's it.
  if (_listen == false)
    return true;

  // #1.2 Make session listen.
  session->listen("tcp://0.0.0.0:0");

  // #2 Allocate population and traffic tools.
  _populationGenerator = new PopulationGenerator();
  _trafficGenerator = new TrafficGenerator();

  // #3 Generate an unique name for hidder service
  if (DefaultService::generateUniqueServiceName(serviceName) == false)
    throw TestSessionError("[Internal] Cannot generate unique service name.");

  // #4 Register hidden service.
  session->registerService(serviceName, DefaultService::getDefaultService());

  // #5 Populate with client session and generate traffic.
  if (_populationGenerator->populateClients(serviceDirectoryUrl, 10000) == false)
    return false;

  if (_trafficGenerator->generateCommonTraffic(_populationGenerator->clientPopulation(), serviceName) == false)
    return false;

  return true;
}
Exemple #2
0
bool SessionInitializer::setUpSD(qi::SessionPtr session, const std::string &serviceDirectoryUrl)
{
  session->connect(serviceDirectoryUrl);

  if (_listen == true)
    session->listen("tcp://0.0.0.0:0");

  return true;
}
Exemple #3
0
bool SessionInitializer::setUpSSL(qi::SessionPtr session, const std::string &serviceDirectoryUrl)
{
  if(session->connect(serviceDirectoryUrl).wait(1000) != qi::FutureState_FinishedWithValue)
    return false;

  if (_listen == true)
  {
    session->setIdentity("../tests/server.key", "../tests/server.crt");
    session->listen("tcps://0.0.0.0:0");
  }

  return true;
}