-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.py
40 lines (30 loc) · 1003 Bytes
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from dataclasses import dataclass
import socket
import rsa
from rsa import PublicKey, PrivateKey
@dataclass
class Config:
host: str
login_port: int
other_port: int
server_public: "PublicKey"
server_private: "PrivateKey"
alice_public: "PublicKey"
alice_private: "PrivateKey"
def load_public_key(filename):
with open(filename, 'rb') as file:
return rsa.PublicKey.load_pkcs1(file.read())
def load_private_key(filename):
with open(filename, 'rb') as file:
return rsa.PrivateKey.load_pkcs1(file.read())
server_public, server_private = load_public_key('server_public.key'), load_private_key('server_private.key')
alice_public, alice_private = load_public_key('alice_public.key'), load_private_key('alice_private.key')
main_config = Config(
host=socket.gethostname(),
login_port=9000,
other_port=9001,
server_public=server_public,
server_private=server_private,
alice_public=alice_public,
alice_private=alice_private,
)