Exemplo n.º 1
0
void Server::init() {
  if (initialized) return;
  initialized = true;

  // IP filters
  ipFilter.allow(options["allow"]);
  ipFilter.deny(options["deny"]);

  // Configure ports
  Option::strings_t addresses = options["http-addresses"].toStrings();
  for (unsigned i = 0; i < addresses.size(); i++)
    addListenPort(addresses[i]);

#ifdef HAVE_OPENSSL
  // SSL
  if (!sslCtx.isNull()) {
    // Configure secure ports
    addresses = options["https-addresses"].toStrings();
    for (unsigned i = 0; i < addresses.size(); i++)
      addListenPort(addresses[i], sslCtx);

    // Load server certificate
    // TODO should load file relative to configuration file
    if (options["certificate-file"].hasValue()) {
      string certFile = options["certificate-file"].toString();
      if (SystemUtilities::exists(certFile))
        sslCtx->useCertificateChainFile(certFile);
      else LOG_WARNING("Certificate file not found " << certFile);
    }

    // Load server private key
    if (options["private-key-file"].hasValue()) {
      string priKeyFile = options["private-key-file"].toString();
      if (SystemUtilities::exists(priKeyFile))
        sslCtx->usePrivateKey(priKeyFile);
      else LOG_WARNING("Private key file not found " << priKeyFile);
    }

    // CRL
    if (options["crl-file"].hasValue()) {
      string crlFile = options["crl-file"];
      if (SystemUtilities::exists(crlFile)) sslCtx->addCRL(crlFile);
      else LOG_WARNING("Certificate Relocation List not found " << crlFile);
    }
  }
#endif // HAVE_OPENSSL

  // Packet capture
  if (options["capture-packets"].toBoolean())
    captureRequests = captureResponses = true;
  if (captureOnError) captureRequests = captureResponses = false;
  captureDir = SocketDebugger::instance().getCaptureDirectory();
}
Exemplo n.º 2
0
void Logger::setLogDomainLevels(const string &levels) {
  Option::strings_t entries;
  String::tokenize(levels, entries, Option::DEFAULT_DELIMS + ",");

  for (unsigned i = 0; i < entries.size(); i++) {
    vector<string> tokens;
    String::tokenize(entries[i], tokens, ":");
    bool invalid = false;

    if (tokens.size() == 3) {
      int level = String::parseS32(tokens[2]);

      for (unsigned j = 0; j < tokens[1].size(); j++)
        switch (tokens[1][j]) {
        case 'i': infoDomainLevels[tokens[0]] = level; break;
        case 'd': debugDomainLevels[tokens[0]] = level; break;
#ifdef HAVE_DEBUGGER
        case 't': domainTraces.insert(tokens[0]); break;
#endif
        default: invalid = true;
        }

    } else if (tokens.size() == 2) {
      int level = String::parseS32(tokens[1]);
      infoDomainLevels[tokens[0]] = level;
      debugDomainLevels[tokens[0]] = level;

    } else invalid = true;

    if (invalid) THROWS("Invalid log domain level entry " << (i + 1)
                        << " '" << entries[i] << "'");
  }
}
Exemplo n.º 3
0
void Project::load(const string &_filename) {
  setFilename(_filename);

  XMLReader reader;
  reader.addFactory("tool_table", tools.get());
  reader.read(filename, &options);

  // Default workpiece
  if (!options["automatic-workpiece"].hasValue())
    options["automatic-workpiece"].
      setDefault(workpieceMin.empty() && workpieceMax.empty());

  // Load NC files
  Option::strings_t ncFiles = options["nc-files"].toStrings();
  options["nc-files"].reset();
  for (unsigned i = 0; i < ncFiles.size(); i++)
    addFile(decodeFilename(ncFiles[i]));

  markClean();
}
Exemplo n.º 4
0
void Project::load(const string &_filename) {
  setFilename(_filename);

  if (SystemUtilities::exists(_filename)) {
    XMLReader reader;
    reader.addFactory("tool_table", &tools);
    reader.read(filename, &options);

    // Default workpiece
    if (!options["automatic-workpiece"].hasValue())
      options["automatic-workpiece"].
        setDefault(workpieceMin.empty() && workpieceMax.empty());

    // Load NC files
    files.clear();
    Option::strings_t ncFiles = options["nc-files"].toStrings();
    for (unsigned i = 0; i < ncFiles.size(); i++) {
      string relPath = decodeFilename(ncFiles[i]);
      addFile(SystemUtilities::absolute(getDirectory(), relPath));
    }
  }

  markClean();
}