|
@@ -1,5 +1,6 @@
|
1
|
1
|
#!/usr/bin/python3
|
2
|
2
|
|
|
3
|
+import binascii
|
3
|
4
|
import json
|
4
|
5
|
import logging
|
5
|
6
|
import re
|
|
@@ -19,6 +20,14 @@ CMODE_FLAG_TO_MODE = {
|
19
|
20
|
0x100: 't', # CMODE_TOPIC
|
20
|
21
|
}
|
21
|
22
|
|
|
23
|
+# attempt to interpret certfp as a hex-encoded SHA-256 fingerprint
|
|
24
|
+def validate_certfp(certfp):
|
|
25
|
+ try:
|
|
26
|
+ dec = binascii.unhexlify(certfp)
|
|
27
|
+ except:
|
|
28
|
+ return False
|
|
29
|
+ return len(dec) == 32
|
|
30
|
+
|
22
|
31
|
def convert(infile):
|
23
|
32
|
out = {
|
24
|
33
|
'version': 1,
|
|
@@ -70,6 +79,11 @@ def convert(infile):
|
70
|
79
|
if parts[2] == 'private:usercloak':
|
71
|
80
|
username = parts[1]
|
72
|
81
|
out['users'][username]['vhost'] = parts[3]
|
|
82
|
+ elif category == 'MCFP':
|
|
83
|
+ username, certfp = parts[1], parts[2]
|
|
84
|
+ if validate_certfp(certfp):
|
|
85
|
+ user = out['users'][username]
|
|
86
|
+ user.setdefault('certfps', []).append(certfp.lower())
|
73
|
87
|
elif category == 'MC':
|
74
|
88
|
# channel registration
|
75
|
89
|
# MC #mychannel 1600134478 1600467343 +v 272 0 0
|