X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Fconfig.cpp;h=ad3c1375963a16602d07611b62bc7ff502e31606;hb=51d4000dfb0ae0c571084c21a070fa1dd020d91c;hp=ce78f417582a8a8049389f18435279cde60b7fa8;hpb=f69f31caeda734d6d9c8ab00e693671ac7512bea;p=cassiopeia.git diff --git a/src/config.cpp b/src/config.cpp index ce78f41..ad3c137 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -91,26 +91,26 @@ int parseProfiles() { std::string cas = map->at( "ca" ); - for( size_t pos = 0; pos != std::string::npos; ) { - size_t end = cas.find( ",", pos ); - std::string sub; - - if( end == std::string::npos ) { - sub = cas.substr( pos ); - } else { - sub = cas.substr( pos, end - pos ); - end++; + DIR *dir; + struct dirent *ent; + if ((dir = opendir ("ca")) != NULL) { + while ((ent = readdir (dir)) != NULL) { + std::string caName = std::string(ent->d_name); + if( caName.find( cas ) != 0 ){ + continue; + } + + if( CAs.find( caName ) == CAs.end() ) { + std::shared_ptr ca( new CAConfig( caName ) ); + CAs.emplace( caName, ca ); + } + + prof.ca.push_back( CAs.at( caName ) ); + std::cout << "Adding CA: " << caName << std::endl; } - - pos = end; - - if( CAs.find( sub ) == CAs.end() ) { - std::shared_ptr ca( new CAConfig( sub ) ); - CAs.emplace( sub, ca ); - } - - prof.ca.push_back( CAs.at( sub ) ); - + closedir (dir); + } else { + throw "Directory with CAConfigs not found"; } profiles.emplace( profileName, prof );