You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.9 KiB
53 lines
1.9 KiB
/* Qt-кодек utun://: channelId/joinKey, пароль, Reality и адреса connection-узла. |
|
* decodeInviteLink возвращает ошибку в InviteData.error; подключения выполняет UtunNode/chat_sync. */ |
|
#pragma once |
|
|
|
#include <QString> |
|
#include <QByteArray> |
|
#include <QList> |
|
#include <cstdint> |
|
#include "../db/db_manager.h" |
|
|
|
#define INVITE_LINK_VERSION 0x03 |
|
|
|
#define INVITE_PROTO_UDP 0x01 |
|
#define INVITE_PROTO_TCP 0x02 |
|
#define INVITE_PROTO_REALITY 0x04 // флаг reality-камуфляжа поверх TCP (reality-TCP = 0x06) |
|
|
|
#define INVITE_SNAME_MAX 64 |
|
|
|
struct InviteAddr { |
|
int family; // 4=IPv4, 6=IPv6 |
|
QByteArray address; |
|
quint16 port; |
|
uint8_t socketId; // socket_id из ETCP |
|
uint8_t proto; // INVITE_PROTO_* |
|
}; |
|
|
|
/* Reality-параметры узла (node-global: одинаковы для всех reality-сокетов). */ |
|
struct InviteReality { |
|
bool has = false; |
|
QByteArray shortId; // 8 байт |
|
QByteArray serverPubkey; // 32 байта |
|
QByteArray version; // 3 байта |
|
QString serverName; |
|
}; |
|
|
|
struct InviteData { |
|
uint64_t channelId = 0; |
|
uint64_t joinKey = 0; // 64-битный ключ входа (генерируется инвайтером) |
|
QByteArray pubkey; |
|
QList<InviteAddr> addrs; |
|
QString password; |
|
QString error; |
|
InviteReality reality; |
|
}; |
|
|
|
QString encodeInviteLink(uint64_t channelId, const QByteArray& pubkey, |
|
const QList<NodeAddr>& addrs, |
|
const QString& password = QString()); |
|
|
|
InviteData decodeInviteLink(const QString& link); |
|
|
|
/* reality-префикс + адреса: has(1) [short_id(8) pubkey(32) ver(3) snlen(1) sn(N)] addrs*(family sockId proto addr port) */ |
|
QByteArray serializeInviteAddrs(const InviteData& d);
|
|
|