Specify Dockerfile in waylume-server build configuration

This commit is contained in:
ImBenji
2025-08-05 02:53:21 +01:00
parent af5e27b490
commit 7b1278980e
2 changed files with 73 additions and 22 deletions

View File

@@ -32,10 +32,10 @@ Client applications communicate through Supabase to discover available Waylume s
### API Endpoints ### API Endpoints
- `POST /api/peers` - Create new VPN peer with generated keys and configuration - `POST /api/peers` - Create new VPN peer with generated keys and configuration
- `DELETE /api/peers/{publicKey}` - Remove VPN peer - `POST /api/peers/delete` - Remove VPN peer (publicKey in request body)
- `PUT /api/peers/{publicKey}/speed-limit` - Set bandwidth limits for peer - `POST /api/peers/speed-limit` - Set bandwidth limits for peer (publicKey + speedKbps in request body)
- `PUT /api/peers/{publicKey}/data-cap` - Set data usage limits for peer - `POST /api/peers/data-cap` - Set data usage limits for peer (publicKey + dataCapMB in request body)
- `GET /api/peers/{publicKey}/config` - Retrieve peer configuration (not implemented) - `POST /api/peers/config` - Retrieve peer configuration (publicKey in request body, not implemented)
### Security Features ### Security Features
- Peer isolation using iptables rules (prevents peer-to-peer communication) - Peer isolation using iptables rules (prevents peer-to-peer communication)
@@ -119,23 +119,32 @@ Response:
} }
``` ```
### Delete a peer
```bash
curl -X POST http://localhost:3000/api/peers/delete \
-H "Content-Type: application/json" \
-d '{"publicKey": "PEER_PUBLIC_KEY_HERE"}'
```
### Set speed limit for peer ### Set speed limit for peer
```bash ```bash
curl -X PUT http://localhost:3000/api/peers/{publicKey}/speed-limit \ curl -X POST http://localhost:3000/api/peers/speed-limit \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{"speedKbps": 1000}' -d '{"publicKey": "PEER_PUBLIC_KEY_HERE", "speedKbps": 1000}'
``` ```
### Set data cap for peer ### Set data cap for peer
```bash ```bash
curl -X PUT http://localhost:3000/api/peers/{publicKey}/data-cap \ curl -X POST http://localhost:3000/api/peers/data-cap \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{"dataCapMB": 1024}' -d '{"publicKey": "PEER_PUBLIC_KEY_HERE", "dataCapMB": 1024}'
``` ```
### Delete a peer ### Get peer config
```bash ```bash
curl -X DELETE http://localhost:3000/api/peers/{publicKey} curl -X POST http://localhost:3000/api/peers/config \
-H "Content-Type: application/json" \
-d '{"publicKey": "PEER_PUBLIC_KEY_HERE"}'
``` ```
## Network Architecture ## Network Architecture

View File

@@ -9,10 +9,10 @@ class PeerRoutes {
final router = Router(); final router = Router();
router.post('/peers', _createPeer); router.post('/peers', _createPeer);
router.delete('/peers/<publicKey>', _deletePeer); router.post('/peers/delete', _deletePeer);
router.get('/peers/<publicKey>/config', _getPeerConfig); router.post('/peers/config', _getPeerConfig);
router.put('/peers/<publicKey>/speed-limit', _setSpeedLimit); router.post('/peers/speed-limit', _setSpeedLimit);
router.put('/peers/<publicKey>/data-cap', _setDataCap); router.post('/peers/data-cap', _setDataCap);
return router; return router;
} }
@@ -42,9 +42,21 @@ class PeerRoutes {
} }
Future<Response> _deletePeer(Request request) async { Future<Response> _deletePeer(Request request) async {
final publicKey = request.params['publicKey']!;
try { try {
final body = await request.readAsString();
final data = jsonDecode(body) as Map<String, dynamic>;
final publicKey = data['publicKey'] as String?;
if (publicKey == null) {
return Response.badRequest(
body: jsonEncode({
'success': false,
'error': 'publicKey parameter is required',
}),
headers: {'Content-Type': 'application/json'},
);
}
final success = await deletePeer(publicKey); final success = await deletePeer(publicKey);
return Response.ok( return Response.ok(
@@ -66,9 +78,21 @@ class PeerRoutes {
} }
Future<Response> _getPeerConfig(Request request) async { Future<Response> _getPeerConfig(Request request) async {
final publicKey = request.params['publicKey']!;
try { try {
final body = await request.readAsString();
final data = jsonDecode(body) as Map<String, dynamic>;
final publicKey = data['publicKey'] as String?;
if (publicKey == null) {
return Response.badRequest(
body: jsonEncode({
'success': false,
'error': 'publicKey parameter is required',
}),
headers: {'Content-Type': 'application/json'},
);
}
return Response.notFound( return Response.notFound(
jsonEncode({ jsonEncode({
'success': false, 'success': false,
@@ -88,13 +112,22 @@ class PeerRoutes {
} }
Future<Response> _setSpeedLimit(Request request) async { Future<Response> _setSpeedLimit(Request request) async {
final publicKey = request.params['publicKey']!;
try { try {
final body = await request.readAsString(); final body = await request.readAsString();
final data = jsonDecode(body) as Map<String, dynamic>; final data = jsonDecode(body) as Map<String, dynamic>;
final publicKey = data['publicKey'] as String?;
final speedKbps = data['speedKbps'] as int?; final speedKbps = data['speedKbps'] as int?;
if (publicKey == null) {
return Response.badRequest(
body: jsonEncode({
'success': false,
'error': 'publicKey parameter is required',
}),
headers: {'Content-Type': 'application/json'},
);
}
if (speedKbps == null) { if (speedKbps == null) {
return Response.badRequest( return Response.badRequest(
body: jsonEncode({ body: jsonEncode({
@@ -126,13 +159,22 @@ class PeerRoutes {
} }
Future<Response> _setDataCap(Request request) async { Future<Response> _setDataCap(Request request) async {
final publicKey = request.params['publicKey']!;
try { try {
final body = await request.readAsString(); final body = await request.readAsString();
final data = jsonDecode(body) as Map<String, dynamic>; final data = jsonDecode(body) as Map<String, dynamic>;
final publicKey = data['publicKey'] as String?;
final dataCapMB = data['dataCapMB'] as int?; final dataCapMB = data['dataCapMB'] as int?;
if (publicKey == null) {
return Response.badRequest(
body: jsonEncode({
'success': false,
'error': 'publicKey parameter is required',
}),
headers: {'Content-Type': 'application/json'},
);
}
if (dataCapMB == null) { if (dataCapMB == null) {
return Response.badRequest( return Response.badRequest(
body: jsonEncode({ body: jsonEncode({