mirror of
https://gitee.com/fantix/kloop.git
synced 2024-11-22 02:11:01 +00:00
Add debug script and certs
This commit is contained in:
parent
d659f7d533
commit
479d8be584
3 changed files with 134 additions and 0 deletions
28
tests/cert.pem
Normal file
28
tests/cert.pem
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIErjCCApYCCQDzWJgnuLzufzANBgkqhkiG9w0BAQsFADAZMRcwFQYDVQQDDA5s
|
||||||
|
b2NhbGhvc3Q6ODA4ODAeFw0yMjA3MDIyMDQ5MzZaFw0yMzA3MDIyMDQ5MzZaMBkx
|
||||||
|
FzAVBgNVBAMMDmxvY2FsaG9zdDo4MDg4MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
|
||||||
|
MIICCgKCAgEAsTtnZV5hayOTVfyq6MbkLRaJj4tVoamMXmqTepqpEwQFxUY80MUi
|
||||||
|
iTcnoxeKTHyToEcPDBINxDAQyvYZQyReo2CScPEBeYlW8Ur6DcZ6CslcrQKIAQEp
|
||||||
|
JQ6a/DwZT/GS71qQfaOkiO+tKU7TbaPvF3a6kK+JFOgBaFbkfcb6Ef0xUfhrgfut
|
||||||
|
fQFDrF4up3otlFY3thofTgoLcpx04OHIeveMWHEemEi8LOr/LRV5MDAwlWSqSHuF
|
||||||
|
JMn/U9fPXZXiv450QINtrBY43n9xAP1sQZL4YowYbkbxWjj/ghpzwqqWZz/sxzHr
|
||||||
|
ayy6UJcOkYiY+RzkLPZ5GLU1BJlWUKNueUtZZQ+n3OOYUGFpbeGnOl6YB1qqvNtn
|
||||||
|
8Lvsmqu0nc3gDsINnxi4E3KEstAJlk7X1M8l7XCgjXhTXrv2ebvQyd7gEAMIXtuy
|
||||||
|
Rpv75Kga+ydapxLnI1spF0q31eYuA0EJlWBcLd0nnU/e0GuhmqWB7PCFm2JQ3LyY
|
||||||
|
1GFUuvR0/VAoDf06vyicpTIkuCMrSsbSUqNZamyKyfujUgLqbUlfBfkV++q1cFGY
|
||||||
|
MQJBTI6U9qNc4JBxuiHbPENMVLQQAUsSEbdltsaOYV9rMhZn5FdZa/plOuC7Q5+C
|
||||||
|
7SllnnRKWJIl7pQh3bF6NNq3cjtuu3suDipFoFcyo5f06wpxJHbiZH0CAwEAATAN
|
||||||
|
BgkqhkiG9w0BAQsFAAOCAgEAcc7L+4z7B9SESGKeVVZavt6pvApM9JIJ7SsRjuDp
|
||||||
|
I026Ld7LkOp+QyQ30yVhmYCxKYFCaJSngHsusk8/TMr5OU80ixGEzUXzaq82UJkQ
|
||||||
|
zkfMHm7k3/UKkJ4I4pT7lLeG20M+QQVB5a8tTFBGDt3Rkc54nuxKNq5JKwQ0AaHz
|
||||||
|
aid8LhHZwQMOiRMJgaga0bjrKo8I9yTcOvip+4UFitJe0EiSjLKWS4eyrWN7I7t9
|
||||||
|
T1OctNWb8aILnO9SvjREvVFk5rN70F0nOM0PSQGUdO0KfNAuE+2e47avlTHwH+I9
|
||||||
|
0m1PEDcLikcoo0rCC+8tLDvwuBS+GdH+NKQYSdlnik9EU7dSo+cRHDzTS9oU8/Kv
|
||||||
|
81teIY45pUN0AzoySxgjBr8Z/lKiEXhUq/OCZHEl6lOZGtExuwlwr8ZSZNqNFZkh
|
||||||
|
iqNb8p81ER8nbk6U2T6tx7heBFb0hipfp5hywLL7DMffx1iqEdsIEqYJiFPT4oen
|
||||||
|
34zM0vft/zMys8oqvo82sNSeQUwFfq0Tr5IopJSaGjud+x1qqRW8XEsyW5t5YEsk
|
||||||
|
BjEcRgXWHsXOKRGuTdosftJyf6S/3MCysLrkwftOxWNi8Hin55XxzS6nmoGy0Y4y
|
||||||
|
SOvyGjrlkzRdb187E5Exm2gqArTDJgvl0wFegRxqmQnAe0ABdLz/BYm9nt4AUQca
|
||||||
|
ZeY=
|
||||||
|
-----END CERTIFICATE-----
|
54
tests/debug.py
Normal file
54
tests/debug.py
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
import asyncio
|
||||||
|
import ssl
|
||||||
|
import socket
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
import pathlib
|
||||||
|
|
||||||
|
import kloop
|
||||||
|
|
||||||
|
|
||||||
|
def server():
|
||||||
|
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
|
||||||
|
cur = pathlib.Path(__file__).parent
|
||||||
|
ctx.load_cert_chain(cur / "cert.pem", cur / "key.pem")
|
||||||
|
|
||||||
|
ss = socket.socket()
|
||||||
|
ss.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
|
ss.bind(("localhost", 8088))
|
||||||
|
ss.listen(1)
|
||||||
|
s, addr = ss.accept()
|
||||||
|
s = ctx.wrap_socket(s, server_side=True)
|
||||||
|
print(s)
|
||||||
|
while True:
|
||||||
|
req = s.recv(65536)
|
||||||
|
print("<<<", req)
|
||||||
|
if req == b'Hello':
|
||||||
|
s.send(b'world\n')
|
||||||
|
elif req.startswith(b'Sleep'):
|
||||||
|
time.sleep(float(req.split()[1]))
|
||||||
|
s.send(b'Sleep done\n')
|
||||||
|
elif req == b'Bye':
|
||||||
|
s.send(b'So long!\n')
|
||||||
|
s.close()
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
s.send(b'unknown command\n')
|
||||||
|
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
ctx = ssl.create_default_context(cafile="tests/cert.pem")
|
||||||
|
r, w = await asyncio.open_connection("localhost", 8088, ssl=ctx)
|
||||||
|
print(r, w)
|
||||||
|
w.write(b'Sleep 3')
|
||||||
|
print(await r.readline())
|
||||||
|
w.write(b'Hello')
|
||||||
|
print(await r.readline())
|
||||||
|
|
||||||
|
|
||||||
|
t = threading.Thread(target=server)
|
||||||
|
t.daemon = True
|
||||||
|
t.start()
|
||||||
|
|
||||||
|
asyncio.set_event_loop_policy(kloop.KLoopPolicy())
|
||||||
|
asyncio.run(main())
|
52
tests/key.pem
Normal file
52
tests/key.pem
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
-----BEGIN PRIVATE KEY-----
|
||||||
|
MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQCxO2dlXmFrI5NV
|
||||||
|
/KroxuQtFomPi1WhqYxeapN6mqkTBAXFRjzQxSKJNyejF4pMfJOgRw8MEg3EMBDK
|
||||||
|
9hlDJF6jYJJw8QF5iVbxSvoNxnoKyVytAogBASklDpr8PBlP8ZLvWpB9o6SI760p
|
||||||
|
TtNto+8XdrqQr4kU6AFoVuR9xvoR/TFR+GuB+619AUOsXi6nei2UVje2Gh9OCgty
|
||||||
|
nHTg4ch694xYcR6YSLws6v8tFXkwMDCVZKpIe4Ukyf9T189dleK/jnRAg22sFjje
|
||||||
|
f3EA/WxBkvhijBhuRvFaOP+CGnPCqpZnP+zHMetrLLpQlw6RiJj5HOQs9nkYtTUE
|
||||||
|
mVZQo255S1llD6fc45hQYWlt4ac6XpgHWqq822fwu+yaq7SdzeAOwg2fGLgTcoSy
|
||||||
|
0AmWTtfUzyXtcKCNeFNeu/Z5u9DJ3uAQAwhe27JGm/vkqBr7J1qnEucjWykXSrfV
|
||||||
|
5i4DQQmVYFwt3SedT97Qa6GapYHs8IWbYlDcvJjUYVS69HT9UCgN/Tq/KJylMiS4
|
||||||
|
IytKxtJSo1lqbIrJ+6NSAuptSV8F+RX76rVwUZgxAkFMjpT2o1zgkHG6Ids8Q0xU
|
||||||
|
tBABSxIRt2W2xo5hX2syFmfkV1lr+mU64LtDn4LtKWWedEpYkiXulCHdsXo02rdy
|
||||||
|
O267ey4OKkWgVzKjl/TrCnEkduJkfQIDAQABAoICAQCTIsYMGfa2g6pl0IXzCmuU
|
||||||
|
IwnA6eQFekTWfZRCTPPgnY5M4KrMh1zMncWCWKCwLxxAC74qPzK+lUjbtsPyQddv
|
||||||
|
u1TX/r1CsQpE+AHwPb5EBjeySk+uxc/qu91fWmWJQPzDSWR7acfHB3Oyv4Y3l8l+
|
||||||
|
qUrpo1Ei0hmZDcpTwUUKejDf5GUcXF0DUnFkQCxrTbtZU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gcu40ohT0LIBlE+E4j7TT5DXwD9l9Hd3LHbqkykxiRUEW8
|
||||||
|
2G2PL45qGu9JSA5Yh2QgQxRy8BNe/ilzDE14YWnr+5XaLaMDOAAFwpwHQkzEpAqh
|
||||||
|
o2eLJ6BHn0qL328uX30FlnURjKig4Ag8uPuDmf6UIyIqs4IlfnML+x7UKNprTBgl
|
||||||
|
5vctgcD6xt6fYYcA4GHyibJWqPWw2+6wQgEuCSCP5qqIqksj2ageB4nU3acF5mZR
|
||||||
|
V7Mcta2iP9uSawKCAQACbvqrPX4hB/F0V67G1uSpcphAG/AssZGvSw7PY5tMHD4G
|
||||||
|
MTppPkenUimOVo3vF6FUD1c7eL0ta0myjjQKVD8OtxblyD8e7rOE7i6BvsZRVqiy
|
||||||
|
QHEtnf6q/zIlEd4s28Jz09trwW1a/C/5l/7LxUBIlYb9qk7C2tFaq91oTOkkf9Yd
|
||||||
|
Zwae8H/RZ1cXFDhLXjErRftAOErxX07pSWo61BF95E5aFYfWq18bypqgVaDo+apo
|
||||||
|
jnLi6//OmOl7Ww58ZLvrqVnxu/QvLg2P01Ea24cABs5/r2nUtjFQlfDvPN6xqZrh
|
||||||
|
akUsZoGmxS2HIJ3kNAoOI2Ceno5bmZVATmSfAlO/AoIBACtKUSOFOv989Ucxh227
|
||||||
|
BnDEs8S90OlVxndsr2dIx7aszI+M5biSjw8jc5YlLDpeFeK9OlfXsXtX34Z+R5rh
|
||||||
|
96kFTOdCUa7IXaIxe2v7kPS1+M/+HyFqgZjHTe6e8I6e4Dnxy91if5rbXbk1G3XN
|
||||||
|
9RqS2N0bNfGmpGIpak6800r4IiViio/hlOV8pFE9R/uui6fZjR5Xl0iL0C+/x5Oa
|
||||||
|
CaeI/CmN6iKtg+T7YPFLLkAAOUT0j9IJDVD9vSFiH1fTiimFeaIzuc+UBBd2soKE
|
||||||
|
ewUC1v/IKeZpcBT51+hFdyj7AR80xvWomcqymdA26vCkowXLzefBLWBUhjJUwIuW
|
||||||
|
+TMCggEBAIe10HbMp0nbogdAGE28gEpjzkBBeEl/EgMhN8EjemrLmjWI4rK3+Nyh
|
||||||
|
Jo6W4QG4dT9C7KUP9RzDOoF4kkaFaPZ/KqlSn2qUVYLf9N4s95qQvGlVFIjy5tEp
|
||||||
|
ChYdiuP71DNXCjolQIq7nb1zkgbTbvuwVSnw2QwQnYdkZMulgjVrvsK55jrOnsuO
|
||||||
|
EMxjVrlNxeUrb2zLaBsfA5uTPgKgtDGmTDMx+wFAay5jKc9Zmgr1+z834bCKStAh
|
||||||
|
7gcRoVAjkiu2hoNxBTXgqtFtCizyajiiUUYfFAswJ9RLv7qdrqnpuCv1cffrALmd
|
||||||
|
PcTNbfrOMsRvyHwyfUIHDaBT62YTztQ=
|
||||||
|
-----END PRIVATE KEY-----
|
Loading…
Reference in a new issue