- u_async.c: process immediate_queue BEFORE epoll_wait in uasync_poll - stcp_link.c: defensive NULL etcp_conn/etcp_link in stcp_link_close - utun_instance.c: move stcp_server_list_destroy_all to Phase J (before ETCP), add deferred drain in both Phase J and L - stcp.h/c: STCP_HS_ENC_CLIENT 6→38, STCP_HS_ENC_SERVER 7→39, exchange ed25519_pubkey in both handshake directions - etcp_connections.c: copy peer_ed25519 from STCP to ETCP_CONN in etcp_link_enter_ready_tcp; guard link->etcp in tcp_link_close_cb - chat_sync.c: fix lk->conn NULL dereference for TCP links - test_stcp.c: update stcp_server_create/stcp_client_connect callsites - tools/chat_tcp_test: change transport udp→tcp
58 lines
1.7 KiB
C
58 lines
1.7 KiB
C
#ifndef INVITE_LINK_C_H
|
|
#define INVITE_LINK_C_H
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
|
|
#define INVITE_LINK_VERSION 0x01
|
|
#define INVITE_PUBKEY_SIZE 32
|
|
#define INVITE_ADDR_MAX 32
|
|
#define INVITE_PASS_MAX 128
|
|
|
|
#define INVITE_PROTO_UDP 0x01
|
|
#define INVITE_PROTO_TCP 0x02
|
|
#define INVITE_PROTO_BOTH 0x03
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
struct InviteAddrC {
|
|
int family;
|
|
uint8_t address[16];
|
|
uint8_t socketId;
|
|
uint8_t proto;
|
|
uint16_t port;
|
|
};
|
|
|
|
struct InviteDataC {
|
|
uint64_t channelId;
|
|
uint8_t pubkey[INVITE_PUBKEY_SIZE];
|
|
uint64_t nodeId;
|
|
uint8_t addrCount;
|
|
struct InviteAddrC addrs[INVITE_ADDR_MAX];
|
|
char password[INVITE_PASS_MAX]; /* empty = no password (v1 compat) */
|
|
uint8_t password_len;
|
|
};
|
|
|
|
/* decode utun://base64 link string, returns 0 on success, -1 on error.
|
|
error buffer must be at least 256 bytes */
|
|
int invite_link_decode(const char* link, size_t link_len, struct InviteDataC* out,
|
|
char* error_buf, size_t error_buf_size);
|
|
|
|
/* encode invite data to utun://base64 string.
|
|
password may be NULL (v1 format, no password).
|
|
out buffer must be large enough (~512 bytes safe).
|
|
returns written length (excluding null), or -1 on error */
|
|
int invite_link_encode(const struct InviteDataC* data, const char* password, char* out, size_t out_size);
|
|
|
|
/* serialize per-addr format for chat_sync_connect_from_invite():
|
|
family(1) + socketId(1) + proto(1) + address(4|16) + port(2 BE)
|
|
returns total bytes written, or -1 if buf too small */
|
|
int invite_serialize_addrs(const struct InviteDataC* data, uint8_t* buf, size_t buf_size);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif /* INVITE_LINK_C_H */
|