X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;ds=sidebyside;f=src%2Fconfig.cpp;h=ad3c1375963a16602d07611b62bc7ff502e31606;hb=be10d9f19349b8d4915f125aa29db98d0048df3f;hp=b746bad11a88049338853537be38250c1297bb6a;hpb=ab317a7803ad0ff688ab8fb452d13d8bdd09fd60;p=cassiopeia.git diff --git a/src/config.cpp b/src/config.cpp index b746bad..ad3c137 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -87,14 +87,32 @@ int parseProfiles() { prof.id = std::stoi( id ); prof.eku = map->at( "eku" ); prof.ku = map->at( "ku" ); - - if( CAs.find( map->at( "ca" ) ) == CAs.end() ) { - std::shared_ptr ca( new CAConfig( map->at( "ca" ) ) ); - CAs.emplace( map->at( "ca" ), ca ); + prof.maxValidity = std::stoi( map->at( "days" ) ) * /* DAYS */24 * 60 * 60; + + std::string cas = map->at( "ca" ); + + 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; + } + closedir (dir); + } else { + throw "Directory with CAConfigs not found"; } - prof.ca = CAs.at( map->at( "ca" ) ); - profiles.emplace( profileName, prof ); std::cout << "Profile: " << profileName << " up and running." << std::endl; }