Skip to content

Commit bc2b3dc

Browse files
authored
Support tunnel mode for connections (#20)
* support tunnel Signed-off-by: kerthcet <kerthcet@gmail.com> * update TUNNEL.md Signed-off-by: kerthcet <kerthcet@gmail.com> * fix test Signed-off-by: kerthcet <kerthcet@gmail.com> * fix install.sh Signed-off-by: kerthcet <kerthcet@gmail.com> * address comments Signed-off-by: kerthcet <kerthcet@gmail.com> * separate the e2e tests Signed-off-by: kerthcet <kerthcet@gmail.com> --------- Signed-off-by: kerthcet <kerthcet@gmail.com>
1 parent fdde485 commit bc2b3dc

25 files changed

Lines changed: 1992 additions & 42 deletions

.github/workflows/rust-ci.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,32 @@ jobs:
3636
with:
3737
toolchain: stable
3838

39+
- name: Setup Python
40+
uses: actions/setup-python@v5
41+
with:
42+
python-version: '3.12'
43+
3944
- name: Run tests
4045
run: make test
46+
47+
test-e2e:
48+
name: E2E Tests
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v4
52+
53+
- name: Install Rust toolchain
54+
uses: actions-rust-lang/setup-rust-toolchain@v1
55+
with:
56+
toolchain: stable
57+
58+
- name: Setup Python
59+
uses: actions/setup-python@v5
60+
with:
61+
python-version: '3.12'
62+
63+
- name: Set up Docker Buildx
64+
uses: docker/setup-buildx-action@v3
65+
66+
- name: Run E2E tests
67+
run: make test-e2e

Makefile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ help:
1010
@echo " make build - Build Python package (debug mode)"
1111
@echo " make install - Install Python package locally"
1212
@echo " make dev - Install in development mode with hot reload"
13-
@echo " make test - Run unit and integration tests"
14-
@echo " make test-e2e - Run end-to-end tests with Docker"
13+
@echo " make test - Run unit and integration tests (fast, no Docker)"
14+
@echo " make test-e2e - Run end-to-end tests with Docker (slow)"
1515
@echo " make daemon-build - Build daemon binary (debug)"
1616
@echo " make daemon-release - Build daemon binary (release)"
1717
@echo " make docker-build - Build Docker image for daemon"
@@ -34,8 +34,8 @@ test: lint $(PYTEST) dev
3434
@echo "Running Rust tests (server protocol)..."
3535
cargo test --package sandbox-server --lib
3636
@echo ""
37-
@echo "Running Python tests..."
38-
$(PYTEST) python/tests/
37+
@echo "Running Python tests (excluding e2e)..."
38+
$(PYTEST) python/tests/ -m "not e2e"
3939

4040
daemon-build:
4141
cargo build --package sandd
@@ -53,22 +53,22 @@ clean:
5353

5454
test-e2e: $(PYTEST) dev
5555
@echo "Building Docker images..."
56-
docker compose -f docker-compose.e2e.yml build
56+
docker compose -f hack/docker/docker-compose.e2e.yml build
5757
@echo ""
5858
@echo "Running E2E tests with Docker..."
59-
$(PYTEST) python/tests/test_e2e.py -v -s
59+
$(PYTEST) python/tests/ -m e2e -v -s
6060
@echo ""
6161
@echo "Cleaning up containers..."
62-
docker compose -f docker-compose.e2e.yml down
62+
docker compose -f hack/docker/docker-compose.e2e.yml down
6363

6464
docker-build:
65-
docker compose -f docker-compose.e2e.yml build
65+
docker compose -f hack/docker/docker-compose.e2e.yml build
6666

6767
docker-up:
68-
docker compose -f docker-compose.e2e.yml up -d
68+
docker compose -f hack/docker/docker-compose.e2e.yml up -d
6969

7070
docker-down:
71-
docker compose -f docker-compose.e2e.yml down
71+
docker compose -f hack/docker/docker-compose.e2e.yml down
7272

7373
.PHONY: lint
7474
lint: $(RUFF)

README.md

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,24 @@ make install
7575

7676
### Daemon Binary (Worker)
7777

78-
Install from crates.io:
78+
#### Quick Install
79+
80+
```bash
81+
# Direct mode (no tunnel)
82+
curl -fsSL https://get.sandd.dev/install.sh | sudo bash
83+
84+
# Tunnel mode (with Tailscale)
85+
curl -fsSL https://get.sandd.dev/install.sh | sudo bash -s -- --tunnel
86+
```
87+
88+
#### Alternative Methods
89+
90+
**Install from crates.io:**
7991
```bash
8092
cargo install sandd
8193
```
8294

83-
Or build from source:
95+
**Build from source:**
8496
```bash
8597
git clone https://github.com/InftyAI/SandD
8698
cd SandD
@@ -90,24 +102,50 @@ make daemon-release
90102

91103
## Quick Start
92104

105+
### Direct Mode (Development)
106+
93107
**Start controller:**
94108

95109
```python
96110
from sandd import Server
97111

98-
server = Server("0.0.0.0", 8765)
112+
server = Server() # Direct mode (default)
99113
server.wait_for_daemon("worker-1", timeout=30)
100114

101115
result = server.exec("worker-1", "hostname")
102116
print(result.stdout)
103117
```
104118

105-
**Start worker:**
119+
**Start daemon:**
106120

107121
```bash
122+
# Direct mode
108123
sandd --server-url ws://controller-ip:8765/ws --daemon-id worker-1
124+
125+
# Tunnel mode
126+
sandd --server-url ws://10.200.0.1:8765/ws \
127+
--daemon-id worker-1 \
128+
--tunnel \
129+
--tunnel-authkey YOUR_KEY \
130+
--tunnel-server http://headscale:8080
109131
```
110132

133+
### Tunnel Mode (Production)
134+
135+
For secure multi-cloud deployments with mesh VPN:
136+
137+
```python
138+
from sandd import Server
139+
140+
config = TunnelConfig(
141+
authkey="YOUR_KEY",
142+
server="http://headscale:8080",
143+
)
144+
server = Server(connect="tunnel", tunnel_config=config) # Secure tunnel mode
145+
```
146+
147+
See [Tunnel Mode Guide](./docs/TUNNEL.md) for setup instructions.
148+
111149
## Documentation
112150

113151
- [Quick Start Guide](./docs/QUICKSTART.md)

0 commit comments

Comments
 (0)