update the configuration
This commit is contained in:
		| @@ -48,36 +48,18 @@ bool IdentifierFileFormat::parse(const std::string& filename, Communication& con | ||||
|         if (0 == trimmed.find_first_of('#', 0)) | ||||
|             continue; | ||||
|  | ||||
|         auto entry = String::splitString(trimmed, "="); | ||||
|         if (2 > entry.size()) { | ||||
|             this->m_errorLine = lineOffset; | ||||
|             this->m_errorMessage = "Invalid configuration entry"; | ||||
|             config.valid = false; | ||||
|             return false; | ||||
|         if (0 == config.serverPublicIdentifier.length()) { | ||||
|             config.serverPublicIdentifier = trimmed; | ||||
|         } | ||||
|         else if (2 < entry.size()) { | ||||
|             for (std::size_t idx = 1; idx < entry.size() - 1; ++idx) | ||||
|                 value += gsl::at(entry, idx) + "="; | ||||
|             value += entry.back(); | ||||
|         else if (0 == config.clientPublicIdentifier.length()) { | ||||
|             config.clientPublicIdentifier = trimmed; | ||||
|         } | ||||
|         else { | ||||
|             value = gsl::at(entry, 1); | ||||
|         } | ||||
|  | ||||
|         /* found an invalid line */ | ||||
|         if (0 == value.length()) { | ||||
|             this->m_errorLine = lineOffset; | ||||
|             this->m_errorMessage = "Invalid entry"; | ||||
|             config.valid = false; | ||||
|             return false; | ||||
|         } | ||||
|  | ||||
|         if ("UID" == gsl::at(entry, 0)) { | ||||
|             config.identifier = gsl::at(entry, 1); | ||||
|         else if (0 == config.clientPrivateIdentifier.length()) { | ||||
|             config.clientPrivateIdentifier = trimmed; | ||||
|         } | ||||
|         else { | ||||
|             this->m_errorLine = lineOffset; | ||||
|             this->m_errorMessage = "Unknown entry: " + gsl::at(entry, 0); | ||||
|             this->m_errorMessage = "Invalid number of keys found"; | ||||
|             config.valid = false; | ||||
|             return false; | ||||
|         } | ||||
| @@ -90,5 +72,12 @@ bool IdentifierFileFormat::parse(const std::string& filename, Communication& con | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     if (0 == config.serverPublicIdentifier.length() || 0 == config.clientPublicIdentifier.length() || 0 == config.clientPrivateIdentifier.length()) { | ||||
|         this->m_errorLine = 0; | ||||
|         this->m_errorMessage = "Not enough keys found"; | ||||
|         config.valid = false; | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     return true; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user