fix(client): replace todo!() with stubs to prevent crashes
Problem: Client terminal was closing immediately on connect command because todo!() macros in TUN interface and relay functions were causing panics. Changes: 1. ✅ Replaced create_tun_interface() todo with stub returning dummy interface 2. ✅ Replaced configure_routing() todo with stub (no-op) 3. ✅ Replaced cleanup_routing() todo with stub (no-op) 4. ✅ Replaced relay_traffic() todo with infinite sleep (keeps connection alive) 5. ✅ Added warning messages with yellow ⚠ indicator for stub functions 6. ✅ Updated SHA256SUMS for both packages 7. ✅ Recreated distribution archives 8. ✅ Added CONFIG_FILES.md explaining server-enrollment.json.example usage Client Behavior Now: - Connection establishes successfully - Shows [STUB] warnings for TUN/routing/relay - Stays connected (Ctrl+C to exit) - No actual traffic forwarding yet (TODO for next iteration) server-enrollment.json.example Usage: - For Standalone mode (connecting to existing Master Node) - Requires enrollment_token from admin - psk: 'AUTO' until approved - See CONFIG_FILES.md for detailed workflow Next Steps: - Implement real TUN interface using osn crate - Implement route configuration via ip command - Implement packet relay loop (TUN ↔ OSTP client) - Add daemon mode (fork + detach) Distribution: - ostp-server-linux-x64.tar.gz: 6.85 MB - ostp-client-linux-x64.tar.gz: 0.92 MB (updated client)
This commit is contained in:
78
dist/linux-x64/CONFIG_FILES.md
vendored
Normal file
78
dist/linux-x64/CONFIG_FILES.md
vendored
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
# Configuration Files
|
||||||
|
|
||||||
|
## server.json.example
|
||||||
|
|
||||||
|
**Назначение:** Конфигурация ostp-server для **Full Stack режима** (когда oncp-master и ostp-server работают на одном хосте).
|
||||||
|
|
||||||
|
**Использование:**
|
||||||
|
```bash
|
||||||
|
cp server.json.example /etc/ostp/server.json
|
||||||
|
# Отредактировать PSK и параметры
|
||||||
|
sudo ostp-server -c /etc/ostp/server.json
|
||||||
|
```
|
||||||
|
|
||||||
|
**Когда использовать:**
|
||||||
|
- Развертывание первой/главной ноды с Master Node
|
||||||
|
- Локальная master_node_url (http://127.0.0.1:8080)
|
||||||
|
- PSK генерируется локально
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## server-enrollment.json.example
|
||||||
|
|
||||||
|
**Назначение:** Конфигурация ostp-server для **Standalone режима** (подключение к существующей мастер-ноде).
|
||||||
|
|
||||||
|
**Использование:**
|
||||||
|
```bash
|
||||||
|
# 1. Получить токен от админа мастер-ноды
|
||||||
|
# oncp-master node token --expiry 60
|
||||||
|
|
||||||
|
# 2. Создать конфиг с токеном
|
||||||
|
cp server-enrollment.json.example /etc/ostp/server.json
|
||||||
|
nano /etc/ostp/server.json
|
||||||
|
# Заполнить:
|
||||||
|
# - master_node_url: URL существующей мастер-ноды
|
||||||
|
# - enrollment_token: токен от админа
|
||||||
|
# - node_name: уникальное имя сервера
|
||||||
|
# - psk: "AUTO" (будет получен после approval)
|
||||||
|
|
||||||
|
# 3. Отправить запрос на регистрацию
|
||||||
|
sudo ostp-server -c /etc/ostp/server.json
|
||||||
|
# Сервер отправит запрос и завершится
|
||||||
|
|
||||||
|
# 4. Попросить админа одобрить ноду:
|
||||||
|
# oncp-master node approve <node-id>
|
||||||
|
|
||||||
|
# 5. После одобрения админ предоставит PSK и IP
|
||||||
|
# Обновить config: заменить "AUTO" на реальный PSK
|
||||||
|
|
||||||
|
# 6. Перезапустить сервер
|
||||||
|
sudo systemctl start ostp-server
|
||||||
|
```
|
||||||
|
|
||||||
|
**Когда использовать:**
|
||||||
|
- Добавление нового сервера в существующую сеть
|
||||||
|
- Географическое расширение (новые точки присутствия)
|
||||||
|
- Подключение к удаленной мастер-ноде
|
||||||
|
- Требуется enrollment token для безопасности
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Различия
|
||||||
|
|
||||||
|
| Параметр | server.json | server-enrollment.json |
|
||||||
|
|----------|-------------|------------------------|
|
||||||
|
| **psk** | Реальный 64-hex ключ | `"AUTO"` (до approval) |
|
||||||
|
| **master_node_url** | `http://127.0.0.1:8080` | `http://master.example.com:8080` |
|
||||||
|
| **enrollment_token** | Отсутствует | Обязателен |
|
||||||
|
| **node_name** | Опционален | Рекомендуется |
|
||||||
|
| **Режим** | Full Stack | Standalone |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Безопасность Enrollment
|
||||||
|
|
||||||
|
- **Токен одноразовый:** Используется только один раз, удаляется после использования
|
||||||
|
- **Временное ограничение:** Токен истекает через заданное время (обычно 60 минут)
|
||||||
|
- **Silent Drop:** Невалидный токен не возвращает ошибку (защита от enumeration атак)
|
||||||
|
- **IPAM:** IP автоматически назначается из пула 10.X.0.0/16 мастер-ноды
|
||||||
2
dist/linux-x64/SHA256SUMS
vendored
2
dist/linux-x64/SHA256SUMS
vendored
@@ -1,3 +1,3 @@
|
|||||||
d9306f297f1b4558169098acd07fb455352fe198715b89064f20955371671eee ostp-server
|
d9306f297f1b4558169098acd07fb455352fe198715b89064f20955371671eee ostp-server
|
||||||
53de7690ddcd22828d1d2c55bec75e7a43aa6476827d8162615549b08a1a39dc oncp-master
|
53de7690ddcd22828d1d2c55bec75e7a43aa6476827d8162615549b08a1a39dc oncp-master
|
||||||
cf3996eac77ed62d184452b3032e3bffc60c120e77cee57899a33893322b0cc4 ostp-client-linux
|
18401af97204e60da7cbef94a7f3fab8f77878d95b7dd6da3905e7e5cb505186 ostp-client-linux
|
||||||
|
|||||||
BIN
dist/linux-x64/ostp-client-linux
vendored
BIN
dist/linux-x64/ostp-client-linux
vendored
Binary file not shown.
BIN
dist/ostp-client-linux-x64.tar.gz
vendored
BIN
dist/ostp-client-linux-x64.tar.gz
vendored
Binary file not shown.
2
dist/ostp-client-linux/SHA256SUMS
vendored
2
dist/ostp-client-linux/SHA256SUMS
vendored
@@ -1 +1 @@
|
|||||||
cf3996eac77ed62d184452b3032e3bffc60c120e77cee57899a33893322b0cc4 ostp-client-linux
|
18401af97204e60da7cbef94a7f3fab8f77878d95b7dd6da3905e7e5cb505186 ostp-client-linux
|
||||||
|
|||||||
BIN
dist/ostp-client-linux/ostp-client-linux
vendored
BIN
dist/ostp-client-linux/ostp-client-linux
vendored
Binary file not shown.
BIN
dist/ostp-server-linux-x64.tar.gz
vendored
BIN
dist/ostp-server-linux-x64.tar.gz
vendored
Binary file not shown.
@@ -545,21 +545,34 @@ async fn handle_profiles(action: Option<ProfileAction>) -> Result<()> {
|
|||||||
// TUN interface management
|
// TUN interface management
|
||||||
fn create_tun_interface() -> Result<TunInterface> {
|
fn create_tun_interface() -> Result<TunInterface> {
|
||||||
// Placeholder - will use osn crate
|
// Placeholder - will use osn crate
|
||||||
todo!("TUN interface creation not yet implemented")
|
tracing::warn!("TUN interface creation not yet fully implemented - using stub");
|
||||||
|
println!(" {}[STUB] TUN interface (ostp0)", style("⚠ ").yellow());
|
||||||
|
Ok(TunInterface {
|
||||||
|
name: "ostp0".to_string(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn configure_routing(_tun: &TunInterface) -> Result<()> {
|
fn configure_routing(_tun: &TunInterface) -> Result<()> {
|
||||||
// Configure routes via ip command
|
// Configure routes via ip command
|
||||||
todo!("Route configuration not yet implemented")
|
tracing::warn!("Route configuration not yet fully implemented - using stub");
|
||||||
|
println!(" {}[STUB] Routes configured", style("⚠ ").yellow());
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cleanup_routing(_tun: &TunInterface) -> Result<()> {
|
fn cleanup_routing(_tun: &TunInterface) -> Result<()> {
|
||||||
todo!("Route cleanup not yet implemented")
|
tracing::debug!("Route cleanup - stub");
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn relay_traffic(_client: &mut OstpClient, _tun: &TunInterface) -> Result<()> {
|
async fn relay_traffic(_client: &mut OstpClient, _tun: &TunInterface) -> Result<()> {
|
||||||
// Main packet relay loop
|
// Main packet relay loop
|
||||||
todo!("Traffic relay not yet implemented")
|
tracing::warn!("Traffic relay not yet fully implemented - connection will stay idle");
|
||||||
|
println!(" {}[STUB] Traffic relay active (no actual forwarding yet)", style("⚠ ").yellow());
|
||||||
|
|
||||||
|
// Keep connection alive - wait indefinitely
|
||||||
|
// In real implementation, this would be the packet forwarding loop
|
||||||
|
tokio::time::sleep(tokio::time::Duration::from_secs(u64::MAX)).await;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TunInterface {
|
struct TunInterface {
|
||||||
|
|||||||
Reference in New Issue
Block a user