78 lines
4.5 KiB
C++
78 lines
4.5 KiB
C++
#pragma once
|
|
#include "gateway/protocol.hpp"
|
|
#include "gateway/realms.hpp"
|
|
#include "gateway/legacy_stream.hpp"
|
|
#include "gateway/world_authentication.hpp"
|
|
#include <memory>
|
|
#include <optional>
|
|
namespace gateway {
|
|
class LegacyLogin {
|
|
struct Impl;
|
|
std::unique_ptr<Impl> impl_;
|
|
friend class LegacySession;
|
|
std::vector<LegacyRealm> request_realm_list();
|
|
void authenticate(const NumericIPv4Endpoint&,const std::string&,std::span<const uint8_t>,const std::string&);
|
|
void authenticate(const NumericIPv4Endpoint&,const std::string&,std::span<const uint8_t>,const std::string&,std::span<const uint8_t> version_hash_bytes);
|
|
public:
|
|
LegacyLogin(uint16_t auth_port,const std::string& username,const std::string& password_path,
|
|
const std::string& hash_path);
|
|
// Borrowed synchronous UI input, never a temporary password file. The
|
|
// Caller owns/wipes its source; LegacyLogin's owned input copies are wiped
|
|
// on all exits. This is not a guarantee about every SRP math temporary.
|
|
LegacyLogin(uint16_t auth_port,const std::string& username,std::span<const uint8_t> password,
|
|
const std::string& hash_path);
|
|
// Explicit numeric endpoint profile; never selected by the loopback APIs.
|
|
// Only this profile permits numeric advertised non-loopback realm metadata
|
|
// in socket-free prepare_transport. LegacySession retains its local guard.
|
|
LegacyLogin(const NumericIPv4Endpoint& endpoint,const std::string& username,
|
|
std::span<const uint8_t> password,const std::string& hash_path);
|
|
// Private opt-in detail path; existing constructors retain old errors.
|
|
LegacyLogin(const NumericIPv4Endpoint& endpoint,const std::string& username,
|
|
std::span<const uint8_t> password,const std::string& hash_path,bool capture_rejection_detail);
|
|
LegacyLogin(const NumericIPv4Endpoint& endpoint,const std::string& username,
|
|
std::span<const uint8_t> password,std::span<const uint8_t> version_hash,
|
|
bool capture_rejection_detail);
|
|
~LegacyLogin();
|
|
LegacyLogin(const LegacyLogin&)=delete;LegacyLogin& operator=(const LegacyLogin&)=delete;
|
|
// One authenticated retrieval per object; repeated reads use its cache.
|
|
const std::vector<LegacyRealm>& realms();
|
|
// Confirm the displayed choices on the same authenticated socket.
|
|
bool confirm_realm_list();
|
|
// Prepare a separate engine-owned transport from this verified account.
|
|
// No world socket opened here; follows an actual advertised local realm.
|
|
std::unique_ptr<WorldAuthentication> prepare_transport(size_t realm_index,const std::string& addon_path,uint32_t build=5875);
|
|
// Additive in-memory entry for a native host on another filesystem.
|
|
// Borrowed bytes are copied into the engine-owned authentication object.
|
|
std::unique_ptr<WorldAuthentication> prepare_transport_bytes(size_t realm_index,std::span<const uint8_t> addon_bytes,uint32_t build=5875);
|
|
};
|
|
class LegacySession {
|
|
struct Impl;
|
|
std::unique_ptr<Impl> impl_;
|
|
void connect_world(const std::string& username,const Bytes& key,uint16_t port,
|
|
const std::string& addon_path,uint32_t build,const std::string& create_name);
|
|
public:
|
|
LegacySession(uint16_t auth_port,uint16_t world_port,const std::string& username,
|
|
const std::string& password_path,const std::string& hash_path,const std::string& addon_path,
|
|
uint32_t world_build=7272,const std::string& create_name={});
|
|
// Shares the verified auth session internally; follows only a selected,
|
|
// genuinely advertised loopback endpoint. No session key crosses the ABI.
|
|
LegacySession(LegacyLogin& login,size_t realm_index,const std::string& addon_path,uint32_t world_build=5875);
|
|
~LegacySession();
|
|
LegacySession(const LegacySession&)=delete;
|
|
LegacySession& operator=(const LegacySession&)=delete;
|
|
const std::vector<Character>& roster() const;
|
|
uint32_t internal_source_account() const;
|
|
void login(uint64_t guid);
|
|
LegacyPacket receive();
|
|
// One reader owns this stream. A timeout preserves a partial encrypted
|
|
// header/body; the next call continues it without decrypting twice.
|
|
std::optional<LegacyPacket> receive_for(uint32_t timeout_ms);
|
|
void send(uint32_t opcode,const Bytes& body);
|
|
int descriptor() const;
|
|
};
|
|
std::vector<Character> fetch_roster(uint16_t auth_port,uint16_t world_port,
|
|
const std::string& username,const std::string& password_path,
|
|
const std::string& hash_path,const std::string& addon_path,
|
|
uint32_t world_build=7272,const std::string& create_name={});
|
|
}
|