23 lines
742 B
Python
23 lines
742 B
Python
import argparse
|
|
import json
|
|
|
|
|
|
def run(parser: argparse.ArgumentParser, arguments: argparse.Namespace):
|
|
import ssl
|
|
import socket
|
|
|
|
context = ssl.SSLContext(protocol=ssl.PROTOCOL_TLS_SERVER)
|
|
context.load_cert_chain(arguments.certificate, arguments.private_key)
|
|
|
|
with (
|
|
socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock_server,
|
|
context.wrap_socket(sock_server, server_side=True) as ssl_sock_server
|
|
):
|
|
ssl_sock_server.bind((arguments.hostname, arguments.port))
|
|
ssl_sock_server.listen(5)
|
|
|
|
while True:
|
|
print("waiting for a connection...")
|
|
connect, address = ssl_sock_server.accept()
|
|
data = json.loads(connect.recv())
|
|
print(data)
|