From 33256b73a7b230654a6cb7bc349c58826118a7d1 Mon Sep 17 00:00:00 2001 From: Lachezar Todorov Date: Sat, 16 Oct 2021 12:55:00 -0400 Subject: [PATCH 01/12] Created a new file that encrypts and decrypts a message using the rsa library. Note: make sure to install the rsa library before using the following code. --- src/py-cli/encrypt_decrypt.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 src/py-cli/encrypt_decrypt.py diff --git a/src/py-cli/encrypt_decrypt.py b/src/py-cli/encrypt_decrypt.py new file mode 100755 index 0000000..e02d4e0 --- /dev/null +++ b/src/py-cli/encrypt_decrypt.py @@ -0,0 +1,29 @@ +""" +Encrypting and decrypting a message + +@author Todorov-Lachezar +""" + +import rsa + +# Generates public and private keys +# Method takes in key length as a parameter +# Note: the key length should be >16 +publicKey, privateKey = rsa.newkeys(512) + +# the message we want to encrypt +message = "Hello World" + +# Encrypts the message with the public key +# Note: make sure to encode the message before encrypting +encMessage = rsa.encrypt(message.encode(), + publicKey) + +print("original string: ", message) +print("encrypted string: ", encMessage) + +# Decrypts the encrypted message with the private key +# Note: make sure to decode the message after decryption +decMessage = rsa.decrypt(encMessage, privateKey).decode() + +print("decrypted string: ", decMessage) \ No newline at end of file From f98c630ea248b2305d9844560a7dfb615a43c169 Mon Sep 17 00:00:00 2001 From: Lachezar Todorov Date: Sat, 16 Oct 2021 13:10:11 -0400 Subject: [PATCH 02/12] Added in URL to where I found information on the rsa library and the functions used to encrypt and decrypt. --- src/py-cli/encrypt_decrypt.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/py-cli/encrypt_decrypt.py b/src/py-cli/encrypt_decrypt.py index e02d4e0..9565085 100755 --- a/src/py-cli/encrypt_decrypt.py +++ b/src/py-cli/encrypt_decrypt.py @@ -1,6 +1,8 @@ """ Encrypting and decrypting a message +https://www.geeksforgeeks.org/how-to-encrypt-and-decrypt-strings-in-python/ + @author Todorov-Lachezar """ From 2b1f25e131bd501d0f23a0e7e4af4d5e474062a4 Mon Sep 17 00:00:00 2001 From: Lachezar <31971186+Todorov-Lachezar@users.noreply.github.com> Date: Sun, 17 Oct 2021 04:16:54 -0400 Subject: [PATCH 03/12] Took the encrypt_decrypt class and changed it to a class with functions. Added in alice.py and bob.py. The idea is that from main.py, Alice is called and encrypts then sends a message, while Bob receives the message and decrypts it. At some point the after Bob decrypts it the plaintext should be printed to show that Bob did it successfully, however nothing gets printed at the moment. --- src/py-cli/encrypt_decrypt.py | 51 ++++++++++++++++++++--------------- src/py-cli/main.py | 21 ++++++++++++++- src/py-cli/websock/alice.py | 22 +++++++++++++++ src/py-cli/websock/bob.py | 24 +++++++++++++++++ 4 files changed, 95 insertions(+), 23 deletions(-) mode change 100755 => 100644 src/py-cli/encrypt_decrypt.py create mode 100644 src/py-cli/websock/alice.py create mode 100644 src/py-cli/websock/bob.py diff --git a/src/py-cli/encrypt_decrypt.py b/src/py-cli/encrypt_decrypt.py old mode 100755 new mode 100644 index 9565085..b24c438 --- a/src/py-cli/encrypt_decrypt.py +++ b/src/py-cli/encrypt_decrypt.py @@ -7,25 +7,32 @@ https://www.geeksforgeeks.org/how-to-encrypt-and-decrypt-strings-in-python/ """ import rsa - -# Generates public and private keys -# Method takes in key length as a parameter -# Note: the key length should be >16 -publicKey, privateKey = rsa.newkeys(512) - -# the message we want to encrypt -message = "Hello World" - -# Encrypts the message with the public key -# Note: make sure to encode the message before encrypting -encMessage = rsa.encrypt(message.encode(), - publicKey) - -print("original string: ", message) -print("encrypted string: ", encMessage) - -# Decrypts the encrypted message with the private key -# Note: make sure to decode the message after decryption -decMessage = rsa.decrypt(encMessage, privateKey).decode() - -print("decrypted string: ", decMessage) \ No newline at end of file + +class encrypt_decrypt(): + + # the message we want to encrypt + message = "Hello World" + + def make_keys(key_length): + publicKey, privateKey = "" + # Generates public and private keys + # Method takes in key length as a parameter + # Note: the key length should be >16 + if(key_length < 16): + publicKey, privateKey = rsa.newkeys(key_length) + return publicKey, privateKey + else: + return "Enter a key_length of >16" + + + def encryption(plaintext, publicKey): + # Encrypts the message with the public key + # Note: make sure to encode the message before encrypting + encMessage = rsa.encrypt(plaintext.encode(), publicKey) + return encMessage + + def decryption(ciphertext, privateKey): + # Decrypts the encrypted message with the private key + # Note: make sure to decode the message after decryption + decMessage = rsa.decrypt(ciphertext, privateKey).decode() + return decMessage diff --git a/src/py-cli/main.py b/src/py-cli/main.py index f556c5f..f54e232 100644 --- a/src/py-cli/main.py +++ b/src/py-cli/main.py @@ -1,5 +1,24 @@ """ A client to send an encrypted message to another client -@author hornetfighter515 +@author hornetfighter515, Lachezar Todorov """ +import encrypt_decrypt +import websock.alice +import websock.bob +import asyncio + +def main(): + message = "Hello World" + + key_length = 512 + + publicKey, privateKey = encrypt_decrypt.encrypt_decrypt.make_keys(key_length) + + asyncio.run(websock.alice.Alice.messageEncrypt("ws://localhost:8765", publicKey, message)) + + asyncio.run(websock.bob.Bob.messageDecrypt(privateKey)) + + + + diff --git a/src/py-cli/websock/alice.py b/src/py-cli/websock/alice.py new file mode 100644 index 0000000..49c6a42 --- /dev/null +++ b/src/py-cli/websock/alice.py @@ -0,0 +1,22 @@ +""" +!/usr/bin/env python + +https://pypi.org/project/websockets/ + +@author Lachezar Todorov +""" + +import asyncio +import encrypt_decrypt + +from websockets import connect + +class Alice(): + async def messageEncrypt(uri, publicKey, message): + encryptedMessage = encrypt_decrypt.encrypt_decrypt.encryption(message, publicKey) + async with connect(uri) as websocket: + await websocket.send(encryptedMessage) + message = await websocket.recv() + print(message) + + #asyncio.run(hello("ws://localhost:8765")) \ No newline at end of file diff --git a/src/py-cli/websock/bob.py b/src/py-cli/websock/bob.py new file mode 100644 index 0000000..81a2563 --- /dev/null +++ b/src/py-cli/websock/bob.py @@ -0,0 +1,24 @@ +""" +!/usr/bin/env python + +https://pypi.org/project/websockets/ + +@author Lachezar Todorov +""" + +import asyncio +import encrypt_decrypt +from websockets import serve + +class Bob(): + async def decrypt(websocket, path, privateKey): + async for message in websocket: + message = await websocket.recv() + decryptedMessage = encrypt_decrypt.encrypt_decrypt.decryption(message, privateKey) + await websocket.send(decryptedMessage) + + async def main(privateKey): + async with serve(Bob.decrypt, "localhost", 8765, privateKey): + await asyncio.Future() # run forever + + #asyncio.run(main()) \ No newline at end of file From b9cf6dc6b5a04f5c6eda23ce90f21a3e429ac962 Mon Sep 17 00:00:00 2001 From: Lachezar Todorov Date: Sun, 17 Oct 2021 17:38:16 -0400 Subject: [PATCH 04/12] Made Alice and Bob classes. Alice encrypts a message and sends it to Bob, who decrypts the message and should print the plaintext to show he decrypted it. However, that is not the case. --- .gitignore | 0 LICENSE | 0 README.md | 0 src/py-cli/encrypt_decrypt.py | 0 src/py-cli/main.py | 0 src/py-cli/websock/alice.py | 42 ++++++++++++++++---------------- src/py-cli/websock/bob.py | 46 +++++++++++++++++------------------ 7 files changed, 44 insertions(+), 44 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 LICENSE mode change 100644 => 100755 README.md mode change 100644 => 100755 src/py-cli/encrypt_decrypt.py mode change 100644 => 100755 src/py-cli/main.py mode change 100644 => 100755 src/py-cli/websock/alice.py mode change 100644 => 100755 src/py-cli/websock/bob.py diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/src/py-cli/encrypt_decrypt.py b/src/py-cli/encrypt_decrypt.py old mode 100644 new mode 100755 diff --git a/src/py-cli/main.py b/src/py-cli/main.py old mode 100644 new mode 100755 diff --git a/src/py-cli/websock/alice.py b/src/py-cli/websock/alice.py old mode 100644 new mode 100755 index 49c6a42..6704e39 --- a/src/py-cli/websock/alice.py +++ b/src/py-cli/websock/alice.py @@ -1,22 +1,22 @@ -""" -!/usr/bin/env python - -https://pypi.org/project/websockets/ - -@author Lachezar Todorov -""" - -import asyncio -import encrypt_decrypt - -from websockets import connect - -class Alice(): - async def messageEncrypt(uri, publicKey, message): - encryptedMessage = encrypt_decrypt.encrypt_decrypt.encryption(message, publicKey) - async with connect(uri) as websocket: - await websocket.send(encryptedMessage) - message = await websocket.recv() - print(message) - +""" +!/usr/bin/env python + +https://pypi.org/project/websockets/ + +@author Lachezar Todorov +""" + +import asyncio +import encrypt_decrypt + +from websockets import connect + +class Alice(): + async def messageEncrypt(uri, publicKey, message): + encryptedMessage = encrypt_decrypt.encrypt_decrypt.encryption(message, publicKey) + async with connect(uri) as websocket: + await websocket.send(encryptedMessage) + message = await websocket.recv() + print(message) + #asyncio.run(hello("ws://localhost:8765")) \ No newline at end of file diff --git a/src/py-cli/websock/bob.py b/src/py-cli/websock/bob.py old mode 100644 new mode 100755 index 81a2563..9cf6b87 --- a/src/py-cli/websock/bob.py +++ b/src/py-cli/websock/bob.py @@ -1,24 +1,24 @@ -""" -!/usr/bin/env python - -https://pypi.org/project/websockets/ - -@author Lachezar Todorov -""" - -import asyncio -import encrypt_decrypt -from websockets import serve - -class Bob(): - async def decrypt(websocket, path, privateKey): - async for message in websocket: - message = await websocket.recv() - decryptedMessage = encrypt_decrypt.encrypt_decrypt.decryption(message, privateKey) - await websocket.send(decryptedMessage) - - async def main(privateKey): - async with serve(Bob.decrypt, "localhost", 8765, privateKey): - await asyncio.Future() # run forever - +""" +!/usr/bin/env python + +https://pypi.org/project/websockets/ + +@author Lachezar Todorov +""" + +import asyncio +import encrypt_decrypt +from websockets import serve + +class Bob(): + async def decrypt(websocket, path, privateKey): + async for message in websocket: + message = await websocket.recv() + decryptedMessage = encrypt_decrypt.encrypt_decrypt.decryption(message, privateKey) + await websocket.send(decryptedMessage) + + async def main(privateKey): + async with serve(Bob.decrypt, "localhost", 8765, privateKey): + await asyncio.Future() # run forever + #asyncio.run(main()) \ No newline at end of file From 9bd87725d3c92252fedb2478cebc6f219ae07a2d Mon Sep 17 00:00:00 2001 From: Lachezar Todorov Date: Sun, 17 Oct 2021 18:15:12 -0400 Subject: [PATCH 05/12] Made some improvements to the readability of the code and changed it to that Bob just prints the decrypted message rather than sending it to Alice to print it --- src/py-cli/main.py | 1 + src/py-cli/websock/alice.py | 4 ++-- src/py-cli/websock/bob.py | 15 +++++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/py-cli/main.py b/src/py-cli/main.py index f54e232..7f2ec33 100755 --- a/src/py-cli/main.py +++ b/src/py-cli/main.py @@ -13,6 +13,7 @@ def main(): key_length = 512 + #Bob's keys publicKey, privateKey = encrypt_decrypt.encrypt_decrypt.make_keys(key_length) asyncio.run(websock.alice.Alice.messageEncrypt("ws://localhost:8765", publicKey, message)) diff --git a/src/py-cli/websock/alice.py b/src/py-cli/websock/alice.py index 6704e39..bad5596 100755 --- a/src/py-cli/websock/alice.py +++ b/src/py-cli/websock/alice.py @@ -16,7 +16,7 @@ class Alice(): encryptedMessage = encrypt_decrypt.encrypt_decrypt.encryption(message, publicKey) async with connect(uri) as websocket: await websocket.send(encryptedMessage) - message = await websocket.recv() - print(message) + #message = await websocket.recv() + #print(message) #asyncio.run(hello("ws://localhost:8765")) \ No newline at end of file diff --git a/src/py-cli/websock/bob.py b/src/py-cli/websock/bob.py index 9cf6b87..a566bf3 100755 --- a/src/py-cli/websock/bob.py +++ b/src/py-cli/websock/bob.py @@ -11,14 +11,21 @@ import encrypt_decrypt from websockets import serve class Bob(): - async def decrypt(websocket, path, privateKey): + def __init__(self,privateKey): + self.pk = privateKey + + async def decrypt(websocket, path): + privateKey = "" #dummy variable to make code work, please change! async for message in websocket: message = await websocket.recv() decryptedMessage = encrypt_decrypt.encrypt_decrypt.decryption(message, privateKey) - await websocket.send(decryptedMessage) + #await websocket.send(decryptedMessage) + print(decryptedMessage) - async def main(privateKey): - async with serve(Bob.decrypt, "localhost", 8765, privateKey): + async def messageDecrypt(privateKey): + #do something with privateKey to send it to decrypt + + async with serve(Bob.decrypt, "localhost", 8765): await asyncio.Future() # run forever #asyncio.run(main()) \ No newline at end of file From bdd2c0f91dd652a0f5e11a4c4cf1d8da991f61d3 Mon Sep 17 00:00:00 2001 From: hornet Date: Tue, 19 Oct 2021 14:08:05 -0400 Subject: [PATCH 06/12] Writing test websocket client --- src/client/cli.py | 34 +++++++++++++++++++++++++++++++++ src/client/test-cli.py | 43 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 src/client/cli.py create mode 100644 src/client/test-cli.py diff --git a/src/client/cli.py b/src/client/cli.py new file mode 100644 index 0000000..02a3d95 --- /dev/null +++ b/src/client/cli.py @@ -0,0 +1,34 @@ +import websocket +import _thread +import time +import ssl + +def on_message(ws, message): + print(f"<< {message}") + +def on_error(ws, error): + print(error) + +def on_close(ws, close_status_code, close_msg): + print(f"### closed. reason: {close_msg} ###") + +def on_open(ws): + def run(*args): + running = True + while running: + outbound = input(">") + if outbound == 'q': + running = False + else: + ws.send(outbound) + ws.close() + _thread.start_new_thread(run, ()) + +if __name__ == "__main__": + websocket.enableTrace(True) + ws = websocket.WebSocketApp("wss://hornetfighter.com:9443", + on_open=on_open, + on_message=on_message, + on_error=on_error, + on_close=on_close) + ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE}) diff --git a/src/client/test-cli.py b/src/client/test-cli.py new file mode 100644 index 0000000..02daae0 --- /dev/null +++ b/src/client/test-cli.py @@ -0,0 +1,43 @@ +import websocket +import _thread +import ssl +import json + +def on_message(ws, message): + print(f"<< {message}") + +def on_error(ws, error): + print(error) + +def on_close(ws, close_status_code, close_msg): + print(f"### closed. reason: {close_msg} ###") + +def on_open(ws): + def run(*args): + running = True + uname = input('input username:') + msg = { + "user":uname, + "content":None + } + ws.send(json.dumps(msg)) + while running: + outbound = input(">") + if outbound == 'q': + running = False + else: + msg = { + "user":uname, + "content":outbound + } + ws.send(json.dumps(msg)) + ws.close() + _thread.start_new_thread(run, ()) + +if __name__ == "__main__": + ws = websocket.WebSocketApp("wss://hornetfighter.com:9443", + on_open=on_open, + on_message=on_message, + on_error=on_error, + on_close=on_close) + ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE}) From 6ec668d7a4b585ae1870dfda0059fd07a81697a4 Mon Sep 17 00:00:00 2001 From: hornet Date: Tue, 9 Nov 2021 14:24:58 -0500 Subject: [PATCH 07/12] Added client code --- src/client/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/cli.py b/src/client/cli.py index 02a3d95..ae0d7ae 100644 --- a/src/client/cli.py +++ b/src/client/cli.py @@ -26,7 +26,7 @@ def on_open(ws): if __name__ == "__main__": websocket.enableTrace(True) - ws = websocket.WebSocketApp("wss://hornetfighter.com:9443", + ws = websocket.WebSocketApp("ws://localhost:6873", on_open=on_open, on_message=on_message, on_error=on_error, From d7cc314ffe8088923c1ba66b224ebd329c3642a3 Mon Sep 17 00:00:00 2001 From: Lachezar <31971186+Todorov-Lachezar@users.noreply.github.com> Date: Tue, 9 Nov 2021 14:36:03 -0500 Subject: [PATCH 08/12] Delete alice.py --- src/py-cli/websock/alice.py | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100755 src/py-cli/websock/alice.py diff --git a/src/py-cli/websock/alice.py b/src/py-cli/websock/alice.py deleted file mode 100755 index bad5596..0000000 --- a/src/py-cli/websock/alice.py +++ /dev/null @@ -1,22 +0,0 @@ -""" -!/usr/bin/env python - -https://pypi.org/project/websockets/ - -@author Lachezar Todorov -""" - -import asyncio -import encrypt_decrypt - -from websockets import connect - -class Alice(): - async def messageEncrypt(uri, publicKey, message): - encryptedMessage = encrypt_decrypt.encrypt_decrypt.encryption(message, publicKey) - async with connect(uri) as websocket: - await websocket.send(encryptedMessage) - #message = await websocket.recv() - #print(message) - - #asyncio.run(hello("ws://localhost:8765")) \ No newline at end of file From 3d8db78895e3beba30606f7476b2cbc1692268a6 Mon Sep 17 00:00:00 2001 From: Lachezar <31971186+Todorov-Lachezar@users.noreply.github.com> Date: Tue, 9 Nov 2021 14:36:13 -0500 Subject: [PATCH 09/12] Delete bob.py --- src/py-cli/websock/bob.py | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100755 src/py-cli/websock/bob.py diff --git a/src/py-cli/websock/bob.py b/src/py-cli/websock/bob.py deleted file mode 100755 index a566bf3..0000000 --- a/src/py-cli/websock/bob.py +++ /dev/null @@ -1,31 +0,0 @@ -""" -!/usr/bin/env python - -https://pypi.org/project/websockets/ - -@author Lachezar Todorov -""" - -import asyncio -import encrypt_decrypt -from websockets import serve - -class Bob(): - def __init__(self,privateKey): - self.pk = privateKey - - async def decrypt(websocket, path): - privateKey = "" #dummy variable to make code work, please change! - async for message in websocket: - message = await websocket.recv() - decryptedMessage = encrypt_decrypt.encrypt_decrypt.decryption(message, privateKey) - #await websocket.send(decryptedMessage) - print(decryptedMessage) - - async def messageDecrypt(privateKey): - #do something with privateKey to send it to decrypt - - async with serve(Bob.decrypt, "localhost", 8765): - await asyncio.Future() # run forever - - #asyncio.run(main()) \ No newline at end of file From f8edfdbd3b0fa64f79a00092435feb2415393180 Mon Sep 17 00:00:00 2001 From: hornet Date: Tue, 9 Nov 2021 14:36:37 -0500 Subject: [PATCH 10/12] Deleted test files --- src/py-cli/websock/alice.py | 22 ---------------------- src/py-cli/websock/bob.py | 31 ------------------------------- 2 files changed, 53 deletions(-) delete mode 100755 src/py-cli/websock/alice.py delete mode 100755 src/py-cli/websock/bob.py diff --git a/src/py-cli/websock/alice.py b/src/py-cli/websock/alice.py deleted file mode 100755 index bad5596..0000000 --- a/src/py-cli/websock/alice.py +++ /dev/null @@ -1,22 +0,0 @@ -""" -!/usr/bin/env python - -https://pypi.org/project/websockets/ - -@author Lachezar Todorov -""" - -import asyncio -import encrypt_decrypt - -from websockets import connect - -class Alice(): - async def messageEncrypt(uri, publicKey, message): - encryptedMessage = encrypt_decrypt.encrypt_decrypt.encryption(message, publicKey) - async with connect(uri) as websocket: - await websocket.send(encryptedMessage) - #message = await websocket.recv() - #print(message) - - #asyncio.run(hello("ws://localhost:8765")) \ No newline at end of file diff --git a/src/py-cli/websock/bob.py b/src/py-cli/websock/bob.py deleted file mode 100755 index a566bf3..0000000 --- a/src/py-cli/websock/bob.py +++ /dev/null @@ -1,31 +0,0 @@ -""" -!/usr/bin/env python - -https://pypi.org/project/websockets/ - -@author Lachezar Todorov -""" - -import asyncio -import encrypt_decrypt -from websockets import serve - -class Bob(): - def __init__(self,privateKey): - self.pk = privateKey - - async def decrypt(websocket, path): - privateKey = "" #dummy variable to make code work, please change! - async for message in websocket: - message = await websocket.recv() - decryptedMessage = encrypt_decrypt.encrypt_decrypt.decryption(message, privateKey) - #await websocket.send(decryptedMessage) - print(decryptedMessage) - - async def messageDecrypt(privateKey): - #do something with privateKey to send it to decrypt - - async with serve(Bob.decrypt, "localhost", 8765): - await asyncio.Future() # run forever - - #asyncio.run(main()) \ No newline at end of file From 4760930c4f243fcc256532cbbd581c974fd8172c Mon Sep 17 00:00:00 2001 From: hornet Date: Tue, 9 Nov 2021 14:58:41 -0500 Subject: [PATCH 11/12] Add test config --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b6e4761..1ae7480 100755 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ __pycache__/ *.py[cod] *$py.class +config.yaml # C extensions *.so From e8d230b31a705f630e05f72fff85e0ba97808728 Mon Sep 17 00:00:00 2001 From: hornet Date: Tue, 9 Nov 2021 15:14:06 -0500 Subject: [PATCH 12/12] Now loads config from YAMl --- src/client/cli.py | 12 ++++++++++-- src/client/test_config.yaml | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 src/client/test_config.yaml diff --git a/src/client/cli.py b/src/client/cli.py index ae0d7ae..074ebe1 100644 --- a/src/client/cli.py +++ b/src/client/cli.py @@ -2,6 +2,7 @@ import websocket import _thread import time import ssl +import yaml def on_message(ws, message): print(f"<< {message}") @@ -24,11 +25,18 @@ def on_open(ws): ws.close() _thread.start_new_thread(run, ()) -if __name__ == "__main__": +def open_socket(url, port): websocket.enableTrace(True) - ws = websocket.WebSocketApp("ws://localhost:6873", + ws = websocket.WebSocketApp(f"ws://{url}:{port}", on_open=on_open, on_message=on_message, on_error=on_error, on_close=on_close) ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE}) + + +if __name__ == "__main__": + with open('config.yaml', 'r') as f: + conf = yaml.safe_load(f) + open_socket(conf['ws']['url'], conf['ws']['port']) + diff --git a/src/client/test_config.yaml b/src/client/test_config.yaml new file mode 100644 index 0000000..23ac0a0 --- /dev/null +++ b/src/client/test_config.yaml @@ -0,0 +1,3 @@ +ws: + url: localhost + port: 6873