handle duplicate hostname entries to same b32/b64

main
simp 2025-08-08 07:23:12 +00:00
parent c14b568399
commit 6bc7a6de7c
2 changed files with 10 additions and 4 deletions

View File

@ -1,6 +1,6 @@
# b32lookup
Accepts hostname, b32, or b64 and gives the other 2.
Accepts hostname, b32, or b64 and gives the other 2. Displays other hostnames if any others were registered with same b32 (like git.i2p and git.community.i2p).
Needs "hosts.txt" file in same directory as the script. Get this from notbob.i2p, reg.i2p, stats.i2p.

View File

@ -46,9 +46,15 @@ def get_dict(lines_list:list, which:int)->dict:
for item in lines_list:
host, b64, b32 = parse_hostentry(item)
if which == 1:
hosts_dict[b32] = {'host': host,'b64': b64,}
if b32 not in hosts_dict:
hosts_dict[b32] = {'host': host,'b64': b64,}
else:
hosts_dict[b32] = {'host': f"{hosts_dict[b32]['host']}\n{host}",'b64': b64,}
elif which == 2:
hosts_dict[b64] = {'host': host,'b32': b32,}
if b64 not in hosts_dict:
hosts_dict[b64] = {'host': host,'b32': b32,}
else:
hosts_dict[b64] = {'host': f"{hosts_dict[b64]['host']}\n{host}",'b32': b32,}
if which == 3:
hosts_dict[host] = {'b32': b32,'b64': b64,}
return hosts_dict
@ -84,5 +90,5 @@ if __name__ == "__main__":
else:
output_msg = f'{Cl.yellow}[Not found]{Cl.normal} {args.hostname}'
else:
output_msg = f'{Cl.green}[Lookup] {Cl.normal}Accepts b32, b64, or hostname. -h, --h for options.'
output_msg = f'{Cl.green}[Lookup] {Cl.normal}Accepts b32, b64, or hostname. -h, --help for options.'
print(output_msg)