Add opt-in KSwitcher LAN discovery and mutual code pairing preview
This commit is contained in:
1 parent
346af2256f
commit
9b565dd55e
17 files changed
+743
-21
No files matched your search
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#include "platform.h"
|
||||
#include "../vendor/json.hpp"
|
||||
|
||||
namespace ks::lan
|
||||
{
|
||||
using Json = nlohmann::json;
|
||||
inline constexpr unsigned Port = 45883;
|
||||
inline constexpr uint64_t PairLifetime = 120000, PeerLifetime = 12000;
|
||||
std::string randomHex(size_t bytes);
|
||||
std::string normalizeCode(const std::string &);
|
||||
std::string mac(const std::string &key, const std::string &text);
|
||||
bool equal(const std::string &, const std::string &);
|
||||
bool identifier(const std::string &);
|
||||
Json envelope(const std::string &type, const std::string &id);
|
||||
struct Pairing
|
||||
{
|
||||
std::string local, peer, code, nonce, remoteNonce, derived;
|
||||
uint64_t started{};
|
||||
bool acknowledged{}, confirmed{};
|
||||
Pairing(std::string local, std::string peer, const std::string &code, uint64_t now);
|
||||
bool expired(uint64_t now) const;
|
||||
Json offer() const;
|
||||
std::vector<Json> receive(const Json &, uint64_t now);
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user