Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 3 additions & 128 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,129 +1,4 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
*.pyc
.DS_Store
.gitkeep
6 changes: 6 additions & 0 deletions application/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM python:3.11-alpine
RUN apk add --no-cache iproute2 iptables tcpdump curl
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY app.py /app/app.py
WORKDIR /app
19 changes: 19 additions & 0 deletions application/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from flask import Flask
import json

app = Flask(__name__)

@app.route('/get', methods=['GET'])
def get_handler():
return json.dumps({"method": "GET", "status": "ok"})

@app.route('/post', methods=['POST'])
def post_handler():
return json.dumps({"method": "POST", "status": "ok"})

@app.route('/put', methods=['PUT'])
def put_handler():
return json.dumps({"method": "PUT", "status": "ok"})

if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
1 change: 1 addition & 0 deletions application/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flask==3.0.0
3 changes: 3 additions & 0 deletions configs/nodeA/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
ip route add 192.168.12.0/24 via 192.168.11.1
python /app/app.py
13 changes: 13 additions & 0 deletions configs/nodeB/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
echo 1 > /proc/sys/net/ipv4/ip_forward

IFACE_SERVER=$(ip route show 192.168.11.0/24 | awk '{print $3}')
IFACE_CLIENT=$(ip route show 192.168.12.0/24 | awk '{print $3}')

iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i "$IFACE_SERVER" -o "$IFACE_CLIENT" -p tcp --dport 5000 --syn -j ACCEPT
iptables -A FORWARD -i "$IFACE_CLIENT" -o "$IFACE_SERVER" -p tcp --dport 5000 --syn -j ACCEPT
iptables -P FORWARD DROP

tcpdump -i any port 5000 -n -l &
sleep infinity
3 changes: 3 additions & 0 deletions configs/nodeC/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
ip route add 192.168.11.0/24 via 192.168.12.10
sleep infinity
57 changes: 57 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
services:
node_a:
build: ./application
container_name: linux_a
hostname: golikov_server
networks:
servernet:
ipv4_address: 192.168.11.10
cap_add:
- NET_ADMIN
entrypoint: ["/bin/sh", "/configs/entrypoint.sh"]
volumes:
- ./configs/nodeA/entrypoint.sh:/configs/entrypoint.sh
restart: always

node_b:
build: ./application
container_name: linux_b
hostname: golikov_gateway
networks:
servernet:
ipv4_address: 192.168.11.1
clientnet:
ipv4_address: 192.168.12.10
privileged: true
entrypoint: ["/bin/sh", "/configs/entrypoint.sh"]
volumes:
- ./configs/nodeB/entrypoint.sh:/configs/entrypoint.sh
restart: always

node_c:
build: ./application
container_name: linux_c
hostname: golikov_client
networks:
clientnet:
ipv4_address: 192.168.12.100
cap_add:
- NET_ADMIN
entrypoint: ["/bin/sh", "/configs/entrypoint.sh"]
volumes:
- ./configs/nodeC/entrypoint.sh:/configs/entrypoint.sh
restart: always

networks:
servernet:
driver: bridge
ipam:
config:
- subnet: 192.168.11.0/24
gateway: 192.168.11.254
clientnet:
driver: bridge
ipam:
config:
- subnet: 192.168.12.0/24
gateway: 192.168.12.254
Loading