This commit is contained in:
rustdesk 2024-10-07 16:21:36 +08:00
parent 3b386b6b54
commit 6f18a97644
6 changed files with 44 additions and 13 deletions

2
Cargo.lock generated
View File

@ -779,7 +779,7 @@ dependencies = [
[[package]] [[package]]
name = "hbbs" name = "hbbs"
version = "1.1.11-1" version = "1.1.12"
dependencies = [ dependencies = [
"async-speed-limit", "async-speed-limit",
"async-trait", "async-trait",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "hbbs" name = "hbbs"
version = "1.1.11-1" version = "1.1.12"
authors = ["rustdesk <info@rustdesk.com>"] authors = ["rustdesk <info@rustdesk.com>"]
edition = "2021" edition = "2021"
build = "build.rs" build = "build.rs"

4
debian/changelog vendored
View File

@ -1,3 +1,7 @@
rustdesk-server (1.1.12) UNRELEASED; urgency=medium
* WS real ip
* Bump s6-overlay to v3.2.0.0 and fix env warnings
rustdesk-server (1.1.11-1) UNRELEASED; urgency=medium rustdesk-server (1.1.11-1) UNRELEASED; urgency=medium
* set reuse port to make restart friendly * set reuse port to make restart friendly
* revert hbbr `-k` to not ruin back-compatibility * revert hbbr `-k` to not ruin back-compatibility

View File

@ -392,19 +392,30 @@ async fn handle_connection(
async fn make_pair( async fn make_pair(
stream: TcpStream, stream: TcpStream,
addr: SocketAddr, mut addr: SocketAddr,
key: &str, key: &str,
limiter: Limiter, limiter: Limiter,
ws: bool, ws: bool,
) -> ResultType<()> { ) -> ResultType<()> {
if ws { if ws {
make_pair_( use tokio_tungstenite::tungstenite::handshake::server::{Request, Response};
tokio_tungstenite::accept_async(stream).await?, let callback = |req: &Request, response: Response| {
addr, let headers = req.headers();
key, let real_ip = headers
limiter, .get("X-Real-IP")
) .or_else(|| headers.get("X-Forwarded-For"))
.await; .and_then(|header_value| header_value.to_str().ok());
if let Some(ip) = real_ip {
if ip.contains('.') {
addr = format!("{ip}:0").parse().unwrap_or(addr);
} else {
addr = format!("[{ip}]:0").parse().unwrap_or(addr);
}
}
Ok(response)
};
let ws_stream = tokio_tungstenite::accept_hdr_async(stream, callback).await?;
make_pair_(ws_stream, addr, key, limiter).await;
} else { } else {
make_pair_(FramedStream::from(stream, addr), addr, key, limiter).await; make_pair_(FramedStream::from(stream, addr), addr, key, limiter).await;
} }

View File

@ -1106,13 +1106,29 @@ impl RendezvousServer {
async fn handle_listener_inner( async fn handle_listener_inner(
&mut self, &mut self,
stream: TcpStream, stream: TcpStream,
addr: SocketAddr, mut addr: SocketAddr,
key: &str, key: &str,
ws: bool, ws: bool,
) -> ResultType<()> { ) -> ResultType<()> {
let mut sink; let mut sink;
if ws { if ws {
let ws_stream = tokio_tungstenite::accept_async(stream).await?; use tokio_tungstenite::tungstenite::handshake::server::{Request, Response};
let callback = |req: &Request, response: Response| {
let headers = req.headers();
let real_ip = headers
.get("X-Real-IP")
.or_else(|| headers.get("X-Forwarded-For"))
.and_then(|header_value| header_value.to_str().ok());
if let Some(ip) = real_ip {
if ip.contains('.') {
addr = format!("{ip}:0").parse().unwrap_or(addr);
} else {
addr = format!("[{ip}]:0").parse().unwrap_or(addr);
}
}
Ok(response)
};
let ws_stream = tokio_tungstenite::accept_hdr_async(stream, callback).await?;
let (a, mut b) = ws_stream.split(); let (a, mut b) = ws_stream.split();
sink = Some(Sink::Ws(a)); sink = Some(Sink::Ws(a));
while let Ok(Some(Ok(msg))) = timeout(30_000, b.next()).await { while let Ok(Some(Ok(msg))) = timeout(30_000, b.next()).await {

View File

@ -15,7 +15,7 @@
!define PRODUCT_NAME "rustdesk_server" !define PRODUCT_NAME "rustdesk_server"
!define PRODUCT_DESCRIPTION "Installer for ${PRODUCT_NAME}" !define PRODUCT_DESCRIPTION "Installer for ${PRODUCT_NAME}"
!define COPYRIGHT "Copyright © 2021" !define COPYRIGHT "Copyright © 2021"
!define VERSION "1.1.10" !define VERSION "1.1.12"
VIProductVersion "${VERSION}.0" VIProductVersion "${VERSION}.0"
VIAddVersionKey "ProductName" "${PRODUCT_NAME}" VIAddVersionKey "ProductName" "${PRODUCT_NAME}"