This commit is contained in:
kxtzownsu 2025-03-07 06:55:22 +00:00
parent 7b077423c6
commit 38fcf57424
2 changed files with 8 additions and 11 deletions

View File

@ -6,12 +6,10 @@ import socket
from urllib import parse
class A(BaseHTTPRequestHandler):
def do_POST(self):
dat = self.rfile.read(int(self.headers.get('Content-Length')))
dmr = device_management_pb2.DeviceManagementRequest()
dmr.ParseFromString(dat)
print(dmr)
# print(dmr)
if (dmr.HasField('device_state_retrieval_request')):
# Expecting a device state response
print("intercepting")
@ -44,11 +42,12 @@ class A(BaseHTTPRequestHandler):
self.end_headers()
dmr = device_management_pb2.DeviceManagementResponse()
dmr.ParseFromString(con.content)
print(dmr)
# print(dmr)
self.wfile.write(dmr.SerializeToString())
# self.wfile.close()
print("Starting internal server!")
print("Starting dmbackend!")
hs = HTTPServer(("0.0.0.0", 3040), A,bind_and_activate=False)
hs.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True)
hs.server_bind()

View File

@ -1,13 +1,11 @@
#!/bin/bash
echo "$@"
SCRIPTDIR=$(readlink -f "$(dirname "$0")")
pushd "${SCRIPTDIR}" || exit
SCRIPT_DIR=$(dirname "$0")
SCRIPT_DIR=${SCRIPT_DIR:-"."}
if [ ! -e ".venv" ]
then
python3 -m venv .venv
fi
source .venv/bin/activate
pip3 install -r requirements.txt
python3 "$SCRIPTDIR"/server.py
popd || exit 0
pip3 install -r requirements.txt &> /dev/null
python3 "$SCRIPT_DIR"/server.py