Skip to content

Commit

Permalink
Clear separation of Veilid Testing parts
Browse files Browse the repository at this point in the history
  • Loading branch information
rasswanth-s committed Feb 24, 2024
1 parent 287e84b commit 9a3ab55
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 101 deletions.
File renamed without changes.
2 changes: 0 additions & 2 deletions packages/grid/veilid/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
flask==2.3.2
flask_shell2http==1.9.1
veilid==0.2.5
5 changes: 1 addition & 4 deletions packages/grid/veilid/start.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/usr/bin/env bash

export PATH="/root/.local/bin:${PATH}"
export FLASK_APP=veilid
/veilid/veilid-server -c /veilid/veilid-server.conf --debug &
flask run -p 4000 --host=0.0.0.0
/veilid/veilid-server -c /veilid/veilid-server.conf --debug

10 changes: 8 additions & 2 deletions packages/grid/veilid/veilid.dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# ======== [Stage 1] Build Veilid Server ========== #

FROM rust as build
RUN apt update && apt install -y git
RUN git clone -b v0.2.5 https://gitlab.com/veilid/veilid
WORKDIR /veilid
RUN bash -c "source scripts/earthly/install_capnproto.sh"
RUN bash -c "source scripts/earthly/install_protoc.sh"
RUN cd veilid-server && cargo build --release -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core
RUN cd veilid-server && cargo build --release -p veilid-server

RUN cp /veilid/target/release/veilid-server /app
# ========== [Stage 2] Dependency Install ========== #

FROM python:3.11-bookworm
COPY --from=build /veilid/target/release/veilid-server /veilid/veilid-server
Expand All @@ -18,11 +20,15 @@ COPY ./start.sh /app/start.sh
RUN chmod +x /app/start.sh
COPY ./veilid.py /app/veilid.py
COPY ./veilid-server.conf /veilid

# ========== [Final] Start Veilid Server and Python Web Server ========== #

CMD ["sh", "-c", "/app/start.sh"]
EXPOSE 5959/udp
EXPOSE 5959
EXPOSE 4000
RUN apt update && apt install netcat-openbsd

# docker build -f veilid.dockerfile . -t veilid
# docker run -it -p 4000:4000 -p 5959:5959 -p 5959:5959/udp veilid
# /root/.local/share/veilid
93 changes: 0 additions & 93 deletions packages/grid/veilid/veilid.py
Original file line number Diff line number Diff line change
@@ -1,93 +0,0 @@
# stdlib
import functools
import os
from typing import Any
from typing import Callable
from typing import Type

# third party
from flask import Flask
from flask_executor import Executor
from flask_shell2http import Shell2HTTP

# Flask application instance
app = Flask(__name__)

executor = Executor(app)
shell2http = Shell2HTTP(app=app, executor=executor, base_url_prefix="/commands/")

# key = os.environ.get("STACK_API_KEY", None) # Get key from environment
# if key is None:
# print("No STACK_API_KEY found, exiting.")
# sys.exit(1)


def check_stack_api_key(challenge_key: str) -> bool:
key = os.environ.get("STACK_API_KEY", None) # Get key from environment
if key is None:
return False
if challenge_key == key:
return True
return False


def basic_auth_check(f: Any) -> Callable:
@functools.wraps(f)
def inner_decorator(*args: Any, **kwargs: Any) -> Type:
# stack_api_key = request.headers.get("X-STACK-API-KEY", "")
# if not check_stack_api_key(challenge_key=stack_api_key):
# raise Exception("STACK_API_KEY doesn't match.")
return f(*args, **kwargs)

return inner_decorator


# def down_callback(context: Dict, future: Future) -> None:
# # optional user-defined callback function
# print(context, future.result())


# def up_callback(context: Dict, future: Future) -> None:
# # optional user-defined callback function
# print(context, future.result())


# shell2http.register_command(
# endpoint="down",
# command_name="tailscale down",
# callback_fn=down_callback,
# decorators=[basic_auth_check],
# )

# shell2http.register_command(
# endpoint="up",
# command_name="tailscale up",
# callback_fn=up_callback,
# decorators=[basic_auth_check],
# )


# def status_callback(context: Dict, future: Future) -> None:
# # optional user-defined callback function
# print(context, future.result())


# shell2http.register_command(
# endpoint="status",
# command_name="tailscale status",
# callback_fn=status_callback,
# decorators=[basic_auth_check],
# )


# def debug_prefs_callback(context: Dict, future: Future) -> None:
# # optional user-defined callback function
# print(context, future.result())


# shell2http.register_command(
# endpoint="debug",
# command_name="tailscale debug prefs",
# callback_fn=debug_prefs_callback,
# decorators=[basic_auth_check],
# )

0 comments on commit 9a3ab55

Please sign in to comment.