invite: add proto field (UDP/TCP/BOTH) to invite link binary format
Format per v4 addr: family(1) + socketId(1) + proto(1) + addr(4) + port(2) = 9 bytes (was 8) Proto values: 0x01=UDP, 0x02=TCP, 0x03=BOTH Affects: invite_link_c.h/c (Android), invite_link.h/cpp (desktop), chat_sync.c, conn_mgr.c, joindialog.cpp, utun_node.cpp
This commit is contained in:
1 parent
5276c1288c
commit
d0cca27edd
23 files changed
+329
-61
No files matched your search
@@ -14,7 +14,7 @@ QString encodeInviteLink(uint64_t channelId, const QByteArray& pubkey,
|
||||
}
|
||||
|
||||
QByteArray blob;
|
||||
blob.reserve(1 + 8 + addrs.size() * (1 + 32 + 19));
|
||||
blob.reserve(1 + 8 + addrs.size() * (1 + 32 + 20));
|
||||
|
||||
blob.append(static_cast<char>(INVITE_LINK_VERSION));
|
||||
|
||||
@@ -38,6 +38,7 @@ QString encodeInviteLink(uint64_t channelId, const QByteArray& pubkey,
|
||||
|
||||
for (int j = 0; j < cnt; j++) {
|
||||
blob.append(static_cast<char>(addrs[i + j].socketId));
|
||||
blob.append(static_cast<char>(addrs[i + j].protocol));
|
||||
blob.append(addrs[i + j].address);
|
||||
quint16 p = addrs[i + j].port;
|
||||
blob.append(static_cast<char>((p >> 8) & 0xFF));
|
||||
@@ -112,13 +113,14 @@ InviteData decodeInviteLink(const QString& link) {
|
||||
for (int j = 0; j < cnt; j++) {
|
||||
bool isV6 = header & (1 << (2 + j));
|
||||
int ipLen = isV6 ? 16 : 4;
|
||||
if (off + 1 + ipLen + 2 > len) {
|
||||
if (off + 2 + ipLen + 2 > len) {
|
||||
d.error = QStringLiteral("truncated at addr %1 of block").arg(j);
|
||||
GUI_ERROR("decodeInviteLink: truncated at addr %d of block", j);
|
||||
return d;
|
||||
}
|
||||
InviteAddr a;
|
||||
a.socketId = data[off++];
|
||||
a.proto = data[off++];
|
||||
a.family = isV6 ? 6 : 4;
|
||||
a.address = QByteArray(reinterpret_cast<const char*>(data + off), ipLen);
|
||||
off += ipLen;
|
||||
|
||||
Reference in new issue
Block a user