feat: same-Realm peer discovery via UDP and local registry (0.9.10)
Advertise instances with a multicast beacon and a config-dir registry so same-machine and LAN peers that share a Realm fingerprint can find each other without TOFU pairing. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
#ifndef CST_DISCOVER_H
|
||||
#define CST_DISCOVER_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Same-Realm peer discovery: UDP multicast beacon + local instance file.
|
||||
* mDNS (_cst-parliament._tcp) can replace the beacon later without changing
|
||||
* this surface. */
|
||||
|
||||
#define CST_DISCOVER_PORT 45454
|
||||
#define CST_DISCOVER_GROUP "239.255.77.77"
|
||||
|
||||
typedef struct {
|
||||
char instance_id[64];
|
||||
char realm_fp[33];
|
||||
char name[64];
|
||||
char host[64];
|
||||
int port;
|
||||
} cst_peer_info_t;
|
||||
|
||||
typedef struct cst_discover cst_discover_t;
|
||||
|
||||
/* Advertise this instance and collect peers that share realm_fp.
|
||||
* peer_port is the TCP parliament port peers should dial. */
|
||||
cst_discover_t *cst_discover_start(const char *realm_fp, const char *instance_id,
|
||||
const char *name, int peer_port);
|
||||
void cst_discover_stop(cst_discover_t *d);
|
||||
|
||||
/* Copy up to max known peers (excluding self). Returns count. */
|
||||
int cst_discover_peers(cst_discover_t *d, cst_peer_info_t *out, int max);
|
||||
|
||||
/* Same-machine registry under <config>/realm/local-instances.json. */
|
||||
int cst_discover_local_put(const char *realm_fp, const char *instance_id,
|
||||
const char *name, int peer_port);
|
||||
int cst_discover_local_del(const char *instance_id);
|
||||
int cst_discover_local_list(const char *realm_fp, cst_peer_info_t *out, int max);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#define CST_VERSION_MAJOR 0
|
||||
#define CST_VERSION_MINOR 9
|
||||
#define CST_VERSION_PATCH 9
|
||||
#define CST_VERSION_PATCH 10
|
||||
|
||||
#define CST_VERSION_STR_(x) #x
|
||||
#define CST_VERSION_STR(x) CST_VERSION_STR_(x)
|
||||
|
||||
Reference in New Issue
Block a user