feat: update domain handshake process and system info format to match official client

This commit is contained in:
MayaTheShy
2025-11-09 23:28:41 -05:00
parent f22e95e1b1
commit d88cdf611a

View File

@@ -259,11 +259,11 @@ bool OverteClient::connect() {
return false; return false;
} }
// Send domain connect request to initiate handshake // Send domain handshake - official client sends DomainListRequest FIRST
// Start with domain list request - simpler packet // This is a simpler packet that doesn't require full credentials
std::cout << "[OverteClient] Initiating domain handshake..." << std::endl; std::cout << "[OverteClient] Initiating domain handshake..." << std::endl;
sendDomainConnectRequest();
sendDomainListRequest(); sendDomainListRequest();
sendDomainConnectRequest();
m_useSimulation = (std::getenv("STARWORLD_SIMULATE") != nullptr); m_useSimulation = (std::getenv("STARWORLD_SIMULATE") != nullptr);
if (m_useSimulation) { if (m_useSimulation) {
@@ -1206,7 +1206,8 @@ void OverteClient::sendDomainConnectRequest() {
qs.writeQUuidFromString(m_sessionUUID); qs.writeQUuidFromString(m_sessionUUID);
// 5. Compressed system info (QByteArray) // 5. Compressed system info (QByteArray)
std::string sysJson = "{\"computer\":{\"OS\":\"Linux\"},\"cpus\":[{\"model\":\"Stardust\"}],\"memory\":4096,\"nics\":[],\"gpus\":[],\"displays\":[]}"; // Match official client format to avoid any filtering
std::string sysJson = "{\"computer\":{\"OS\":\"Linux\",\"vendor\":\"PC\"},\"cpus\":[{\"model\":\"Intel Core\"}],\"memory\":8192,\"nics\":[],\"gpus\":[],\"displays\":[]}";
std::vector<uint8_t> sysBytes(sysJson.begin(), sysJson.end()); std::vector<uint8_t> sysBytes(sysJson.begin(), sysJson.end());
auto sysCompressed = qCompressLike(sysBytes, Z_BEST_SPEED); auto sysCompressed = qCompressLike(sysBytes, Z_BEST_SPEED);
qs.writeQByteArray(sysCompressed); qs.writeQByteArray(sysCompressed);
@@ -1223,10 +1224,8 @@ void OverteClient::sendDomainConnectRequest() {
qs.writeUInt64BE(static_cast<uint64_t>(nowUs)); qs.writeUInt64BE(static_cast<uint64_t>(nowUs));
// 9. Node type / owner type (NodeType_t) // 9. Node type / owner type (NodeType_t)
// Use Unassigned (1) for regular clients, NOT 'I' (Agent)! // Interface clients use NodeType::Agent = 'I' (confirmed from Application_Setup.cpp:338)
// NodeType::Agent = 'I' is for server-side bots/scripts qs.writeUInt8(static_cast<uint8_t>('I')); // Agent (yes, Interface uses Agent type!)
// NodeType::Unassigned = 1 is for regular Interface clients
qs.writeUInt8(1); // Unassigned = regular client
// Determine local UDP socket address/port (bind address if needed) // Determine local UDP socket address/port (bind address if needed)
uint32_t localIPv4 = 0x7F000001; // 127.0.0.1 fallback uint32_t localIPv4 = 0x7F000001; // 127.0.0.1 fallback
@@ -1694,8 +1693,8 @@ void OverteClient::sendAvatarIdentity() {
// 1. Identity sequence number // 1. Identity sequence number
writeU16BE(m_avatarIdentitySequence++); writeU16BE(m_avatarIdentitySequence++);
// 2. Display name // 2. Display name (use empty to match typical client behavior - server assigns default)
std::string displayName = m_username.empty() ? "StarworldClient" : m_username; std::string displayName = m_username.empty() ? "" : m_username;
writeQString(displayName); writeQString(displayName);
// 3. Avatar URL (empty for now - uses default avatar) // 3. Avatar URL (empty for now - uses default avatar)
@@ -1716,6 +1715,11 @@ void OverteClient::sendAvatarIdentity() {
if (s > 0) { if (s > 0) {
m_identitySent = true; m_identitySent = true;
std::cout << "[OverteClient] Sent AvatarIdentity (" << s << " bytes, name=" << displayName << ")" << std::endl; std::cout << "[OverteClient] Sent AvatarIdentity (" << s << " bytes, name=" << displayName << ")" << std::endl;
std::cout << "[OverteClient] AvatarIdentity hex (first 64 bytes): ";
for (size_t i = 0; i < std::min(size_t(64), data.size()); ++i) {
printf("%02x ", data[i]);
}
std::cout << std::endl;
} else { } else {
std::cerr << "[OverteClient] Failed to send AvatarIdentity: " << strerror(errno) << std::endl; std::cerr << "[OverteClient] Failed to send AvatarIdentity: " << strerror(errno) << std::endl;
} }