3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 10:42:52 +01:00

fix the atheme side of #1864

Import stored certfps from Atheme as well.
This commit is contained in:
Shivaram Lingamneni 2021-12-13 02:07:56 -05:00
parent 98e87f6cc0
commit 8fc20d8eed

View File

@ -1,5 +1,6 @@
#!/usr/bin/python3
import binascii
import json
import logging
import re
@ -19,6 +20,14 @@ CMODE_FLAG_TO_MODE = {
0x100: 't', # CMODE_TOPIC
}
# attempt to interpret certfp as a hex-encoded SHA-256 fingerprint
def validate_certfp(certfp):
try:
dec = binascii.unhexlify(certfp)
except:
return False
return len(dec) == 32
def convert(infile):
out = {
'version': 1,
@ -70,6 +79,11 @@ def convert(infile):
if parts[2] == 'private:usercloak':
username = parts[1]
out['users'][username]['vhost'] = parts[3]
elif category == 'MCFP':
username, certfp = parts[1], parts[2]
if validate_certfp(certfp):
user = out['users'][username]
user.setdefault('certfps', []).append(certfp.lower())
elif category == 'MC':
# channel registration
# MC #mychannel 1600134478 1600467343 +v 272 0 0