feat: add environment variable support for domain authentication credentials

This commit is contained in:
MayaTheShy
2025-11-08 17:20:53 -05:00
parent af4b04ccbc
commit 870420ae79
2 changed files with 19 additions and 3 deletions

View File

@@ -37,6 +37,18 @@ bool OverteClient::connect() {
m_sessionUUID = generateUUID();
std::cout << "[OverteClient] Session UUID: " << m_sessionUUID << std::endl;
// Check for authentication credentials from environment
const char* usernameEnv = std::getenv("OVERTE_USERNAME");
const char* passwordEnv = std::getenv("OVERTE_PASSWORD");
if (usernameEnv) m_username = usernameEnv;
if (passwordEnv) m_password = passwordEnv;
if (!m_username.empty()) {
std::cout << "[OverteClient] Using authentication: username=" << m_username << std::endl;
} else {
std::cout << "[OverteClient] No authentication credentials provided (set OVERTE_USERNAME/OVERTE_PASSWORD)" << std::endl;
}
// Parse ws://host:port
std::string url = m_domainUrl;
if (url.empty()) url = "ws://127.0.0.1:40102";
@@ -106,7 +118,9 @@ bool OverteClient::connect() {
}
// Send domain connect request to initiate handshake
sendDomainConnectRequest();
// Start with domain list request - simpler packet
std::cout << "[OverteClient] Requesting domain list..." << std::endl;
sendDomainListRequest();
m_useSimulation = (std::getenv("STARWORLD_SIMULATE") != nullptr);
if (m_useSimulation) {
@@ -199,8 +213,8 @@ void OverteClient::poll() {
// Request domain list periodically if not connected
if (!m_domainConnected && std::chrono::duration_cast<std::chrono::seconds>(now - lastDomainList).count() >= 2) {
std::cout << "[OverteClient] Retrying domain connection..." << std::endl;
sendDomainConnectRequest();
std::cout << "[OverteClient] Retrying domain list request..." << std::endl;
sendDomainListRequest();
lastDomainList = now;
}
}

View File

@@ -67,6 +67,8 @@ private:
bool m_useSimulation{false};
bool m_domainConnected{false};
std::string m_sessionUUID; // Our client session UUID
std::string m_username; // Domain authentication username
std::string m_password; // Domain authentication password (or token)
// Very small in-process world state for testing
std::unordered_map<std::uint64_t, OverteEntity> m_entities;