16
16
# along with this program. If not, see <http://www.gnu.org/licenses/>
17
17
#
18
18
19
- from typing import Any , Union
19
+ from typing import Any , Union , Optional
20
20
21
21
import dataclasses
22
22
import json
@@ -35,6 +35,19 @@ class Versions:
35
35
container_version : str = ""
36
36
37
37
38
+ @dataclasses .dataclass
39
+ class SessionCrypto :
40
+ cipher : str
41
+ degree : str
42
+
43
+ @classmethod
44
+ def load (cls , json_object : dict [str , Any ]) -> Self :
45
+ cipher = json_object .get ("cipher" , "" )
46
+ cipher = "" if cipher == "-" else cipher
47
+ degree = json_object .get ("degree" , "" )
48
+ return cls (cipher = cipher , degree = degree )
49
+
50
+
38
51
@dataclasses .dataclass
39
52
class Session :
40
53
session_id : str
@@ -45,9 +58,15 @@ class Session:
45
58
session_dialect : str
46
59
uid : int
47
60
gid : int
61
+ encryption : Optional [SessionCrypto ] = None
62
+ signing : Optional [SessionCrypto ] = None
48
63
49
64
@classmethod
50
65
def load (cls , json_object : dict [str , Any ]) -> Self :
66
+ _encryption = json_object .get ("encryption" )
67
+ encryption = SessionCrypto .load (_encryption ) if _encryption else None
68
+ _signing = json_object .get ("signing" )
69
+ signing = SessionCrypto .load (_signing ) if _signing else None
51
70
return cls (
52
71
session_id = json_object .get ("session_id" , "" ),
53
72
username = json_object .get ("username" , "" ),
@@ -57,6 +76,8 @@ def load(cls, json_object: dict[str, Any]) -> Self:
57
76
session_dialect = json_object .get ("session_dialect" , "" ),
58
77
uid = int (json_object .get ("uid" , - 1 )),
59
78
gid = int (json_object .get ("gid" , - 1 )),
79
+ encryption = encryption ,
80
+ signing = signing ,
60
81
)
61
82
62
83
0 commit comments