feat: VNC、RTSP 服务支持监听 ipv6 地址

This commit is contained in:
mofeng-git
2026-07-05 21:20:23 +08:00
parent 16a65289f2
commit b346af35d3
4 changed files with 131 additions and 6 deletions

View File

@@ -8,6 +8,7 @@ use tokio::sync::{broadcast, Mutex, RwLock};
use crate::config::RtspConfig;
use crate::error::{AppError, Result};
use crate::utils::{bind_socket_addr, bind_tcp_listener};
use crate::video::VideoStreamManager;
use super::auth::{extract_basic_auth, rtsp_auth_credentials};
@@ -73,13 +74,18 @@ impl RtspService {
tracing::debug!("Failed to request keyframe on RTSP start: {}", err);
}
let bind_addr: SocketAddr = format!("{}:{}", config.bind, config.port)
.parse()
let bind_addr = bind_socket_addr(&config.bind, config.port)
.map_err(|e| AppError::BadRequest(format!("Invalid RTSP bind address: {}", e)))?;
let listener = TcpListener::bind(bind_addr).await.map_err(|e| {
let listener = bind_tcp_listener(bind_addr).map_err(|e| {
AppError::Io(io::Error::new(e.kind(), format!("RTSP bind failed: {}", e)))
})?;
let listener = TcpListener::from_std(listener).map_err(|e| {
AppError::Io(io::Error::new(
e.kind(),
format!("RTSP listener setup failed: {}", e),
))
})?;
let service_config = self.config.clone();
let video_manager = self.video_manager.clone();