-
Notifications
You must be signed in to change notification settings - Fork 4
/
gen.py
87 lines (58 loc) · 2.23 KB
/
gen.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# -*- coding: UTF-8 -*-
from modules import server
from utils import main
from utils import config
from utils import is_value_in_array
from os.path import isdir
from time import sleep
import threading
# Configuración global
configuration = config.conf
# Configuración de RSA
rsa_settings = configuration['rsa_setting']
rsa_bitsize = rsa_settings['bitsize']
# Configuración del servidor
socket_settings = configuration['socket_setting']
socket_lhost = socket_settings['lhost']
socket_lport = socket_settings['lport']
socket_family = socket_settings['family']
socket_protocol = socket_settings['protocol']
socket_buffer_limit = socket_settings['buffer_limit']
socket_limit = socket_settings['limit']
# Configuración del tiempo
time_settings = configuration['time_setting']
time_sleep = time_settings['sleep']
# Configuración de estilos
style_settings = configuration['style']
style_input_string = style_settings['input_string']
server_thread = threading.Thread(target=server.run_server, name='Server', args=(socket_lhost, socket_lport, socket_limit, socket_family, socket_protocol, socket_buffer_limit))
server_thread.setDaemon(True)
server_thread.start()
# Si se usa como api se necesitara información
clients = []
clients_for_interact = []
clients_to_socket = {}
server_obj = None
# Menu
control = main.main()
# Detección de clientes
def client_detection():
global control, server, time_sleep, clients, clients_for_interact, clients_to_socket, server_obj
while True:
control.clients = server.clients
control.clients_for_interact = server.clients_for_interact
control.clients_to_socket = server.clients_to_socket
control.server_obj = server.server_obj
# Definimos las variables de el script principal
clients = server.clients
clients_for_interact = server.clients_for_interact
clients_to_socket = server.clients_to_socket
server_obj = server.server_obj
sleep(time_sleep)
client_detection_thread = threading.Thread(target=client_detection, name="Client_Detection")
client_detection_thread.setDaemon(True)
client_detection_thread.start()
# Ejecutamos la entrada de datos
control.config = configuration
if __name__ == '__main__':
control.entry_mode_init()