summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <tom@vanderlee.io>2021-12-30 09:51:00 +0100
committerGravatar Tom van der Lee <tom@vanderlee.io>2021-12-30 09:51:00 +0100
commit35de567b2d3c628ecaeabe19d1ebfff80a82a6b0 (patch)
treeda80d82d68822f5ae2cacbef417964406ce9d935
downloadclient-35de567b2d3c628ecaeabe19d1ebfff80a82a6b0.tar.gz
client-35de567b2d3c628ecaeabe19d1ebfff80a82a6b0.tar.bz2
client-35de567b2d3c628ecaeabe19d1ebfff80a82a6b0.zip
Initial code
-rw-r--r--.gitignore145
-rw-r--r--requirements.txt1
-rw-r--r--ttun/__init__.py0
-rw-r--r--ttun/__main__.py17
4 files changed, 163 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4906f4c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,145 @@
1
2# Created by https://www.toptal.com/developers/gitignore/api/python
3# Edit at https://www.toptal.com/developers/gitignore?templates=python
4
5### Python ###
6# Byte-compiled / optimized / DLL files
7__pycache__/
8*.py[cod]
9*$py.class
10
11# C extensions
12*.so
13
14# Distribution / packaging
15.Python
16build/
17develop-eggs/
18dist/
19downloads/
20eggs/
21.eggs/
22lib/
23lib64/
24parts/
25sdist/
26var/
27wheels/
28share/python-wheels/
29*.egg-info/
30.installed.cfg
31*.egg
32MANIFEST
33
34# PyInstaller
35# Usually these files are written by a python script from a template
36# before PyInstaller builds the exe, so as to inject date/other infos into it.
37*.manifest
38*.spec
39
40# Installer logs
41pip-log.txt
42pip-delete-this-directory.txt
43
44# Unit test / coverage reports
45htmlcov/
46.tox/
47.nox/
48.coverage
49.coverage.*
50.cache
51nosetests.xml
52coverage.xml
53*.cover
54*.py,cover
55.hypothesis/
56.pytest_cache/
57cover/
58
59# Translations
60*.mo
61*.pot
62
63# Django stuff:
64*.log
65local_settings.py
66db.sqlite3
67db.sqlite3-journal
68
69# Flask stuff:
70instance/
71.webassets-cache
72
73# Scrapy stuff:
74.scrapy
75
76# Sphinx documentation
77docs/_build/
78
79# PyBuilder
80.pybuilder/
81target/
82
83# Jupyter Notebook
84.ipynb_checkpoints
85
86# IPython
87profile_default/
88ipython_config.py
89
90# pyenv
91# For a library or package, you might want to ignore these files since the code is
92# intended to run in multiple environments; otherwise, check them in:
93# .python-version
94
95# pipenv
96# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
97# However, in case of collaboration, if having platform-specific dependencies or dependencies
98# having no cross-platform support, pipenv may install dependencies that don't work, or not
99# install all needed dependencies.
100#Pipfile.lock
101
102# PEP 582; used by e.g. github.com/David-OConnor/pyflow
103__pypackages__/
104
105# Celery stuff
106celerybeat-schedule
107celerybeat.pid
108
109# SageMath parsed files
110*.sage.py
111
112# Environments
113.env
114.venv
115env/
116venv/
117ENV/
118env.bak/
119venv.bak/
120
121# Spyder project settings
122.spyderproject
123.spyproject
124
125# Rope project settings
126.ropeproject
127
128# mkdocs documentation
129/site
130
131# mypy
132.mypy_cache/
133.dmypy.json
134dmypy.json
135
136# Pyre type checker
137.pyre/
138
139# pytype static type analyzer
140.pytype/
141
142# Cython debug symbols
143cython_debug/
144
145# End of https://www.toptal.com/developers/gitignore/api/python
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..86290f8
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1 @@
websockets ~= 10.0
diff --git a/ttun/__init__.py b/ttun/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ttun/__init__.py
diff --git a/ttun/__main__.py b/ttun/__main__.py
new file mode 100644
index 0000000..36e074e
--- /dev/null
+++ b/ttun/__main__.py
@@ -0,0 +1,17 @@
1import asyncio
2import json
3
4import websockets
5from websockets import WebSocketClientProtocol
6
7async def test():
8 async with websockets.connect('ws://localhost:8000/tunnel/') as websocket:
9 ws: WebSocketClientProtocol = websocket
10
11 await ws.send(json.dumps({ 'Lol': 'Test' }))
12
13 while True:
14 data = await ws.recv()
15 print(data)
16
17asyncio.run(test())