Commit 93ff92eb authored by Michal Horejsek's avatar Michal Horejsek

Simplified start of proxy

parent fcd18dd8
......@@ -2,8 +2,8 @@
.PHONY: all prepare-dev test lint run-py2 run-py3 build clean
# Normally it would be just twistd but it runs always with Python 2 in this moment.
TWISTD_CMD=-c "from twisted.scripts.twistd import run; run()"
TWISTD_RUN_ARGS=-l haas.log --pidfile haas.pid haas_proxy -d 42
TWISTD_CMD=-m haas_proxy
TWISTD_RUN_ARGS=-l haas.log -n haas_proxy -d ${DEVICE_TOKEN}
FPM_CMD=fpm -f -d sshpass -m 'haas@nic.cz' -s python
FPM_CMD_PY2=${FPM_CMD} --python-bin /usr/bin/python2 --python-package-name-prefix python
......@@ -35,14 +35,12 @@ test:
if [ `which python3` ]; then python3 -m pytest test_haas_proxy.py; fi
lint:
python3 -m pylint --rcfile=pylintrc haas_proxy twisted/plugins/haas_proxy_plugin.py
python3 -m pylint --rcfile=pylintrc haas_proxy haas_proxy/twisted/plugins/haas_proxy_plugin.py
run-py2: run-kill
run-py2:
sudo python2 ${TWISTD_CMD} ${TWISTD_RUN_ARGS}
run-py3: run-kill
run-py3:
sudo python3 ${TWISTD_CMD} ${TWISTD_RUN_ARGS}
run-kill:
kill `cat haas.pid` >/dev/null || true
build:
# Debian packages
......
......@@ -3,8 +3,8 @@ Proxy for project Honepot as a Service by CZ.NIC. This proxy is needed to
tag SSH activity with your account ID so you can watch your log online.
Script has hardcoded address of honeypot running at CZ.NIC. It shouldn't
be changed but if does or you need to use proxy or send it to own honeypot,
use optional arguments `--honeypot-host` and `--honeypot-port`.
be changed but if does or you need to use proxy, use optional arguments
`--honeypot-host` and `--honeypot-port`.
Script contains one pre-generated key. If you want to use own, create one
with the following command:
......@@ -17,7 +17,12 @@ Store it in some path and then pass it as arguments:
Example usage:
$ twistd -l /tmp/haas.log --pidfile /tmp/haas.pid haas_proxy --device-token XXX
$ sudo python -m haas_proxy -l /tmp/haas.log --pidfile /tmp/haas.pid haas_proxy --device-token XXX
Note that there is not used script `twistd` but `python -m haas_proxy`. It's
because you would need to pass PYTHONPATH by hand which is not comfortable.
The rest of arguments works the same way. Also note that running of proxy
needs root privileges.
"""
from haas_proxy import constants
......
"""
Entry script for the proxy. Twisted needs configured PYTHONPATH to properly
load all 3rd party plugins. This entry script simplifies it little bit.
"""
import os
import sys
from twisted.scripts.twistd import run
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
run()
......@@ -24,7 +24,7 @@ setup(
version='1.0',
packages=[
'haas_proxy',
'twisted.plugins',
'haas_proxy.twisted.plugins',
],
install_requires=[
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment