bugfix and bulletproof
This commit is contained in:
parent
a871c2a681
commit
3ab429628a
@ -241,16 +241,15 @@ def lProcessGroups(state, index, length, result, label="GROUPS"):
|
|||||||
"""
|
"""
|
||||||
global sENC
|
global sENC
|
||||||
lIN = []
|
lIN = []
|
||||||
i = 0
|
|
||||||
if not msgpack:
|
if not msgpack:
|
||||||
LOG.warn(f"process_chunk Groups = NO msgpack bytes={length}")
|
LOG.warn(f"process_chunk Groups = NO msgpack bytes={length}")
|
||||||
return []
|
return []
|
||||||
try:
|
try:
|
||||||
groups = msgpack.loads(result, raw=True)
|
groups = msgpack.loads(result, raw=True)
|
||||||
LOG.info(f"{label} {len(groups)} groups")
|
LOG.info(f"{label} {len(groups)} groups")
|
||||||
|
i = 0
|
||||||
for group in groups:
|
for group in groups:
|
||||||
assert len(group) == 7, group
|
assert len(group) == 7, group
|
||||||
i += 1
|
|
||||||
|
|
||||||
state_values, \
|
state_values, \
|
||||||
state_bin, \
|
state_bin, \
|
||||||
@ -260,6 +259,9 @@ def lProcessGroups(state, index, length, result, label="GROUPS"):
|
|||||||
self_info, \
|
self_info, \
|
||||||
saved_peers, = group
|
saved_peers, = group
|
||||||
|
|
||||||
|
if state_values is None:
|
||||||
|
LOG.warn(f"lProcessGroups #{i} state_values is None")
|
||||||
|
else:
|
||||||
assert len(state_values) == 8, state_values
|
assert len(state_values) == 8, state_values
|
||||||
manually_disconnected, \
|
manually_disconnected, \
|
||||||
group_name_len, \
|
group_name_len, \
|
||||||
@ -274,6 +276,9 @@ def lProcessGroups(state, index, length, result, label="GROUPS"):
|
|||||||
"Privacy_state": privacy_state}
|
"Privacy_state": privacy_state}
|
||||||
lIN += [{"State_values": dBINS}]
|
lIN += [{"State_values": dBINS}]
|
||||||
|
|
||||||
|
if state_bin is None:
|
||||||
|
LOG.warn(f"lProcessGroups #{i} state_bin is None")
|
||||||
|
else:
|
||||||
assert len(state_bin) == 5, state_bin
|
assert len(state_bin) == 5, state_bin
|
||||||
shared_state_sig, \
|
shared_state_sig, \
|
||||||
founder_public_key, \
|
founder_public_key, \
|
||||||
@ -284,26 +289,38 @@ def lProcessGroups(state, index, length, result, label="GROUPS"):
|
|||||||
dBINS = {"Founder_public_key": bin_to_hex(founder_public_key)}
|
dBINS = {"Founder_public_key": bin_to_hex(founder_public_key)}
|
||||||
lIN += [{"State_bin": dBINS}]
|
lIN += [{"State_bin": dBINS}]
|
||||||
|
|
||||||
|
if topic_info is None:
|
||||||
|
LOG.warn(f"lProcessGroups #{i} topic_info is None")
|
||||||
|
else:
|
||||||
assert len(topic_info) == 6, topic_info
|
assert len(topic_info) == 6, topic_info
|
||||||
topic_info_topic = str(topic_info[3], sENC)
|
topic_info_topic = str(topic_info[3], sENC)
|
||||||
LOG.info(f"lProcessGroups #{i} topic_info_topic={topic_info_topic}")
|
LOG.info(f"lProcessGroups #{i} topic_info_topic={topic_info_topic}")
|
||||||
dBINS = {"topic_info_topic": topic_info_topic}
|
dBINS = {"topic_info_topic": topic_info_topic}
|
||||||
lIN += [{"Topic_info": dBINS}]
|
lIN += [{"Topic_info": dBINS}]
|
||||||
|
|
||||||
|
if mod_list is None:
|
||||||
|
LOG.warn(f"lProcessGroups #{i} mod_list is None")
|
||||||
|
else:
|
||||||
assert len(mod_list) == 2, mod_list
|
assert len(mod_list) == 2, mod_list
|
||||||
num_moderators = mod_list[0]
|
num_moderators = mod_list[0]
|
||||||
LOG.info(f"lProcessGroups #{i} num moderators={mod_list[0]}")
|
LOG.info(f"lProcessGroups #{i} num moderators={mod_list[0]}")
|
||||||
#define CRYPTO_SIGN_PUBLIC_KEY_SIZE 32
|
#define CRYPTO_SIGN_PUBLIC_KEY_SIZE 32
|
||||||
|
lMODS = []
|
||||||
|
if not num_moderators:
|
||||||
|
LOG.warn(f"lProcessGroups #{i} num_moderators is 0")
|
||||||
|
else:
|
||||||
mods = mod_list[1]
|
mods = mod_list[1]
|
||||||
assert len(mods) % 32 == 0, len(mods)
|
assert len(mods) % 32 == 0, len(mods)
|
||||||
assert len(mods) == num_moderators * 32, len(mods)
|
assert len(mods) == num_moderators * 32, len(mods)
|
||||||
lMODS = []
|
|
||||||
for j in range(num_moderators):
|
for j in range(num_moderators):
|
||||||
mod = mods[j*32:j*32 + 32]
|
mod = mods[j*32:j*32 + 32]
|
||||||
LOG.info(f"lProcessGroups group#{i} mod#{j} sig_pk={bin_to_hex(mod)}")
|
LOG.info(f"lProcessGroups group#{i} mod#{j} sig_pk={bin_to_hex(mod)}")
|
||||||
lMODS += [{"Sig_pk": bin_to_hex(mod)}]
|
lMODS += [{"Sig_pk": bin_to_hex(mod)}]
|
||||||
lIN += [{"Moderators": lMODS}]
|
lIN += [{"Moderators": lMODS}]
|
||||||
|
|
||||||
|
if keys is None:
|
||||||
|
LOG.warn(f"lProcessGroups #{i} keys is None")
|
||||||
|
else:
|
||||||
assert len(keys) == 4, keys
|
assert len(keys) == 4, keys
|
||||||
LOG.debug(f"lProcessGroups #{i} {repr(list(map(len, keys)))}")
|
LOG.debug(f"lProcessGroups #{i} {repr(list(map(len, keys)))}")
|
||||||
chat_public_key, \
|
chat_public_key, \
|
||||||
@ -322,14 +339,25 @@ def lProcessGroups(state, index, length, result, label="GROUPS"):
|
|||||||
LOG.info(f"lProcessGroups #{i} self_secret_key={bin_to_hex(self_secret_key)}")
|
LOG.info(f"lProcessGroups #{i} self_secret_key={bin_to_hex(self_secret_key)}")
|
||||||
lIN[0].update({"Self_secret_key": bin_to_hex(self_secret_key)})
|
lIN[0].update({"Self_secret_key": bin_to_hex(self_secret_key)})
|
||||||
|
|
||||||
|
if self_info is None:
|
||||||
|
LOG.warn(f"lProcessGroups #{i} self_info is None")
|
||||||
|
else:
|
||||||
assert len(self_info) == 4, self_info
|
assert len(self_info) == 4, self_info
|
||||||
self_nick_len, self_role, self_status, self_nick = self_info
|
self_nick_len, self_role, self_status, self_nick = self_info
|
||||||
self_nick = str(self_nick, sENC)
|
self_nick = str(self_nick, sENC)
|
||||||
LOG.info(f"lProcessGroups #{i} self_nick={self_nick}")
|
dBINS = {"Self_nick": self_nick,
|
||||||
dBINS = {"Self_nick": self_nick}
|
"Self_role": self_role,
|
||||||
lIN += [{"Self_info": dBINS}]
|
"Self_status": self_status,
|
||||||
|
"Self_info": self_info,
|
||||||
|
}
|
||||||
|
LOG.info(f"lProcessGroups #{i} {repr(dBINS)}")
|
||||||
|
lIN += [dBINS]
|
||||||
|
|
||||||
|
if saved_peers is None:
|
||||||
|
LOG.warn(f"lProcessGroups #{i} saved_peers is None")
|
||||||
|
else:
|
||||||
assert len(saved_peers) == 2, saved_peers
|
assert len(saved_peers) == 2, saved_peers
|
||||||
|
i += 1
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.warn(f"process_chunk Groups #{i} error={e}")
|
LOG.warn(f"process_chunk Groups #{i} error={e}")
|
||||||
@ -381,9 +409,9 @@ The Node Info data structure contains a Transport Protocol, a Socket
|
|||||||
"Ip": ipaddr,
|
"Ip": ipaddr,
|
||||||
"Port": port,
|
"Port": port,
|
||||||
"Pk": pk}]
|
"Pk": pk}]
|
||||||
|
relay += 1
|
||||||
delta += total
|
delta += total
|
||||||
length -= total
|
length -= total
|
||||||
relay += 1
|
|
||||||
return lIN
|
return lIN
|
||||||
|
|
||||||
def lProcessDHTnodes(state, index, length, result, label="DHTnode"):
|
def lProcessDHTnodes(state, index, length, result, label="DHTnode"):
|
||||||
@ -427,9 +455,9 @@ def lProcessDHTnodes(state, index, length, result, label="DHTnode"):
|
|||||||
"Port": port,
|
"Port": port,
|
||||||
"Pk": pk}]
|
"Pk": pk}]
|
||||||
offset += subtotal
|
offset += subtotal
|
||||||
|
relay += 1
|
||||||
delta += total
|
delta += total
|
||||||
length -= total
|
length -= total
|
||||||
relay += 1
|
|
||||||
return lIN
|
return lIN
|
||||||
|
|
||||||
def process_chunk(index, state, oArgs=None):
|
def process_chunk(index, state, oArgs=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user