Explorar el Código

fix the atheme side of #1864

Import stored certfps from Atheme as well.
tags/v2.9.0-rc1
Shivaram Lingamneni hace 2 años
padre
commit
8fc20d8eed
Se han modificado 1 ficheros con 14 adiciones y 0 borrados
  1. 14
    0
      distrib/atheme/atheme2json.py

+ 14
- 0
distrib/atheme/atheme2json.py Ver fichero

1
 #!/usr/bin/python3
1
 #!/usr/bin/python3
2
 
2
 
3
+import binascii
3
 import json
4
 import json
4
 import logging
5
 import logging
5
 import re
6
 import re
19
     0x100: 't', # CMODE_TOPIC
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
 def convert(infile):
31
 def convert(infile):
23
     out = {
32
     out = {
24
         'version': 1,
33
         'version': 1,
70
             if parts[2] == 'private:usercloak':
79
             if parts[2] == 'private:usercloak':
71
                 username = parts[1]
80
                 username = parts[1]
72
                 out['users'][username]['vhost'] = parts[3]
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
         elif category == 'MC':
87
         elif category == 'MC':
74
             # channel registration
88
             # channel registration
75
             # MC #mychannel 1600134478 1600467343 +v 272 0 0
89
             # MC #mychannel 1600134478 1600467343 +v 272 0 0

Loading…
Cancelar
Guardar