|
|
|
@ -222,11 +222,10 @@ static int _member_get_items(void* ctx, const char* ns, uint8_t level, |
|
|
|
static int _member_apply_items(void* ctx, const char* ns, uint64_t from_peer, |
|
|
|
static int _member_apply_items(void* ctx, const char* ns, uint64_t from_peer, |
|
|
|
const uint8_t* data, size_t len) { |
|
|
|
const uint8_t* data, size_t len) { |
|
|
|
struct UTUN_INSTANCE* inst = (struct UTUN_INSTANCE*)ctx; |
|
|
|
struct UTUN_INSTANCE* inst = (struct UTUN_INSTANCE*)ctx; |
|
|
|
(void)from_peer; |
|
|
|
|
|
|
|
if (len < 2) return -1; |
|
|
|
if (len < 2) return -1; |
|
|
|
|
|
|
|
|
|
|
|
uint16_t count; memcpy(&count, data, 2); |
|
|
|
uint16_t count; memcpy(&count, data, 2); |
|
|
|
DEBUG_TRACE(DEBUG_CATEGORY_DB_SYNC, "%s: apply_items ns=%s count=%u", MS_ID, ns, count); |
|
|
|
DEBUG_TRACE(DEBUG_CATEGORY_DB_SYNC, "%s: apply_items ns=%s count=%u from=%016llx", MS_ID, ns, count, (unsigned long long)from_peer); |
|
|
|
const uint8_t* mp = data + 2; size_t mrem = len - 2; |
|
|
|
const uint8_t* mp = data + 2; size_t mrem = len - 2; |
|
|
|
|
|
|
|
|
|
|
|
for (uint16_t i = 0; i < count && mrem >= 148; i++) { |
|
|
|
for (uint16_t i = 0; i < count && mrem >= 148; i++) { |
|
|
|
@ -281,6 +280,8 @@ static int _member_apply_items(void* ctx, const char* ns, uint64_t from_peer, |
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: [ADDR_SYNC] member_sync recv ns=%s nid=0x%016llx ac=%d", MS_ID, ns, (unsigned long long)nid, ac); |
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: [ADDR_SYNC] member_sync recv ns=%s nid=0x%016llx ac=%d", MS_ID, ns, (unsigned long long)nid, ac); |
|
|
|
mp += consumed; mrem -= (size_t)consumed; |
|
|
|
mp += consumed; mrem -= (size_t)consumed; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (count > 0) |
|
|
|
|
|
|
|
merkle_sync_broadcast(inst, ns, from_peer, data, len); |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|