1 parent
38e86d4a07
commit
6dddf513b3
6 files changed
+600
-3
No files matched your search
@@ -28,6 +28,9 @@ namespace Echoion::Protocol
|
||||
// Load / save the identity to a small text file:
|
||||
// privateKeyPem, publicKeyString, keyOffset (one per line).
|
||||
static Identity load(const std::string& path);
|
||||
// Import an identity exported by the TeamSpeak client. The export is
|
||||
// an INI file containing its obfuscated "<offset>V<base64>" key.
|
||||
static Identity importTeamSpeakIni(const std::string& path);
|
||||
void save(const std::string& path) const;
|
||||
|
||||
// libtomcrypt ASN.1 public key, base64 ("omega" in clientinitiv).
|
||||
|
||||
@@ -12,7 +12,10 @@
|
||||
#include "echoion/protocol/Identity.hpp"
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
#include <cstdint>
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@@ -66,6 +69,14 @@ namespace Echoion::Protocol
|
||||
std::function<void(const std::string&)> onDebug;
|
||||
};
|
||||
|
||||
struct CommandResult {
|
||||
std::vector<CommandParams> records;
|
||||
int errorId = 0;
|
||||
std::string errorMessage;
|
||||
|
||||
[[nodiscard]] bool ok() const noexcept { return errorId == 0; }
|
||||
};
|
||||
|
||||
class TsClient
|
||||
{
|
||||
public:
|
||||
@@ -100,6 +111,16 @@ namespace Echoion::Protocol
|
||||
|
||||
// Send a raw pre-built TS3 command line (fragmented if large).
|
||||
void sendCommand(const std::string& cmd);
|
||||
// Send a command and wait for its data records plus terminating
|
||||
// `error` response. Safe to call from threads other than the receive
|
||||
// callback thread.
|
||||
CommandResult requestCommand(
|
||||
const std::string& cmd,
|
||||
std::chrono::milliseconds timeout = std::chrono::seconds{3});
|
||||
CommandResult downloadFile(
|
||||
const std::string& remotePath, const std::string& destination,
|
||||
uint64_t channelId = 0, const std::string& channelPassword = {},
|
||||
std::chrono::milliseconds timeout = std::chrono::seconds{10});
|
||||
|
||||
private:
|
||||
|
||||
@@ -139,6 +160,7 @@ namespace Echoion::Protocol
|
||||
void resendTick();
|
||||
void debug(const std::string& msg);
|
||||
void cleanup();
|
||||
void cancelPendingRequests(const std::string& reason);
|
||||
|
||||
// counters / crypto
|
||||
struct Counter {
|
||||
@@ -190,6 +212,18 @@ namespace Echoion::Protocol
|
||||
|
||||
// channel map for auto-move
|
||||
std::map<std::string, uint64_t> channelMap_;
|
||||
|
||||
struct PendingRequest {
|
||||
CommandResult result;
|
||||
std::string returnCode;
|
||||
bool completed = false;
|
||||
std::condition_variable cv;
|
||||
};
|
||||
std::mutex requestSerialMutex_;
|
||||
std::mutex pendingMutex_;
|
||||
std::deque<std::shared_ptr<PendingRequest>> pendingRequests_;
|
||||
std::atomic<uint64_t> requestId_{0};
|
||||
std::atomic<uint16_t> transferId_{0};
|
||||
};
|
||||
|
||||
} // namespace Echoion::Protocol
|
||||
Reference in new issue
Block a user