mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-02 17:01:30 +03:00
show TCP/UDP/IPv6 in tooltip (#12613)
* add punch type log Signed-off-by: 21pages <sunboeasy@gmail.com> * show TCP/UDP/IPv6 in tooltip Signed-off-by: 21pages <sunboeasy@gmail.com> * Skip udp punch if udp nat port is 0 Signed-off-by: 21pages <sunboeasy@gmail.com> --------- Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
@@ -192,7 +192,13 @@ impl Client {
|
||||
conn_type: ConnType,
|
||||
interface: impl Interface,
|
||||
) -> ResultType<(
|
||||
(Stream, bool, Option<Vec<u8>>, Option<KcpStream>),
|
||||
(
|
||||
Stream,
|
||||
bool,
|
||||
Option<Vec<u8>>,
|
||||
Option<KcpStream>,
|
||||
&'static str,
|
||||
),
|
||||
(i32, String),
|
||||
)> {
|
||||
debug_assert!(peer == interface.get_id());
|
||||
@@ -219,7 +225,13 @@ impl Client {
|
||||
conn_type: ConnType,
|
||||
interface: impl Interface,
|
||||
) -> ResultType<(
|
||||
(Stream, bool, Option<Vec<u8>>, Option<KcpStream>),
|
||||
(
|
||||
Stream,
|
||||
bool,
|
||||
Option<Vec<u8>>,
|
||||
Option<KcpStream>,
|
||||
&'static str,
|
||||
),
|
||||
(i32, String),
|
||||
)> {
|
||||
if config::is_incoming_only() {
|
||||
@@ -234,6 +246,7 @@ impl Client {
|
||||
true,
|
||||
None,
|
||||
None,
|
||||
"TCP",
|
||||
),
|
||||
(0, "".to_owned()),
|
||||
));
|
||||
@@ -246,6 +259,7 @@ impl Client {
|
||||
true,
|
||||
None,
|
||||
None,
|
||||
"TCP",
|
||||
),
|
||||
(0, "".to_owned()),
|
||||
));
|
||||
@@ -257,7 +271,7 @@ impl Client {
|
||||
} else {
|
||||
(peer, "", key, token)
|
||||
};
|
||||
let (mut rendezvous_server, servers, contained) = if other_server.is_empty() {
|
||||
let (rendezvous_server, servers, contained) = if other_server.is_empty() {
|
||||
crate::get_rendezvous_server(1_000).await
|
||||
} else {
|
||||
if other_server == PUBLIC_SERVER {
|
||||
@@ -346,7 +360,13 @@ impl Client {
|
||||
servers: Vec<String>,
|
||||
contained: bool,
|
||||
) -> ResultType<(
|
||||
(Stream, bool, Option<Vec<u8>>, Option<KcpStream>),
|
||||
(
|
||||
Stream,
|
||||
bool,
|
||||
Option<Vec<u8>>,
|
||||
Option<KcpStream>,
|
||||
&'static str,
|
||||
),
|
||||
(i32, String),
|
||||
)> {
|
||||
let mut start = Instant::now();
|
||||
@@ -417,6 +437,12 @@ impl Client {
|
||||
(None, None)
|
||||
};
|
||||
let udp_nat_port = udp.1.map(|x| *x.lock().unwrap()).unwrap_or(0);
|
||||
if udp.0.is_some() && udp_nat_port == 0 {
|
||||
let err_msg = "skip udp punch because udp nat port is 0";
|
||||
log::info!("{}", err_msg);
|
||||
bail!(err_msg);
|
||||
}
|
||||
let punch_type = if udp_nat_port > 0 { "UDP" } else { "TCP" };
|
||||
msg_out.set_punch_hole_request(PunchHoleRequest {
|
||||
id: peer.to_owned(),
|
||||
token: token.to_owned(),
|
||||
@@ -430,7 +456,13 @@ impl Client {
|
||||
..Default::default()
|
||||
});
|
||||
for i in 1..=3 {
|
||||
log::info!("#{} punch attempt with {}, id: {}", i, my_addr, peer);
|
||||
log::info!(
|
||||
"#{} {} punch attempt with {}, id: {}",
|
||||
i,
|
||||
punch_type,
|
||||
my_addr,
|
||||
peer
|
||||
);
|
||||
socket.send(&msg_out).await?;
|
||||
// below timeout should not bigger than hbbs's connection timeout.
|
||||
if let Some(msg_in) =
|
||||
@@ -481,7 +513,7 @@ impl Client {
|
||||
}
|
||||
}
|
||||
}
|
||||
log::info!("Hole Punched {} = {}", peer, peer_addr);
|
||||
log::info!("{} Hole Punched {} = {}", punch_type, peer, peer_addr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -529,7 +561,7 @@ impl Client {
|
||||
log::info!("{:?} used to establish {typ} connection", start.elapsed());
|
||||
let pk =
|
||||
Self::secure_connection(&peer, signed_id_pk, &key, &mut conn).await?;
|
||||
return Ok(((conn, false, pk, kcp), (feedback, rendezvous_server)));
|
||||
return Ok(((conn, false, pk, kcp, typ), (feedback, rendezvous_server)));
|
||||
}
|
||||
_ => {
|
||||
log::error!("Unexpected protobuf msg received: {:?}", msg_in);
|
||||
@@ -543,8 +575,9 @@ impl Client {
|
||||
}
|
||||
let time_used = start.elapsed().as_millis() as u64;
|
||||
log::info!(
|
||||
"{} ms used to punch hole, relay_server: {}, {}",
|
||||
"{} ms used to {} punch hole, relay_server: {}, {}",
|
||||
time_used,
|
||||
punch_type,
|
||||
relay_server,
|
||||
if is_local {
|
||||
"is_local: true".to_owned()
|
||||
@@ -570,6 +603,7 @@ impl Client {
|
||||
interface,
|
||||
udp.0,
|
||||
ipv6.0,
|
||||
punch_type,
|
||||
)
|
||||
.await?,
|
||||
(feedback, rendezvous_server),
|
||||
@@ -594,7 +628,14 @@ impl Client {
|
||||
interface: impl Interface,
|
||||
udp_socket_nat: Option<Arc<UdpSocket>>,
|
||||
udp_socket_v6: Option<Arc<UdpSocket>>,
|
||||
) -> ResultType<(Stream, bool, Option<Vec<u8>>, Option<KcpStream>)> {
|
||||
punch_type: &str,
|
||||
) -> ResultType<(
|
||||
Stream,
|
||||
bool,
|
||||
Option<Vec<u8>>,
|
||||
Option<KcpStream>,
|
||||
&'static str,
|
||||
)> {
|
||||
let direct_failures = interface.get_lch().read().unwrap().direct_failures;
|
||||
let mut connect_timeout = 0;
|
||||
const MIN: u64 = 1000;
|
||||
@@ -681,9 +722,14 @@ impl Client {
|
||||
interface.get_lch().write().unwrap().set_direct_failure(n);
|
||||
}
|
||||
let mut conn = conn?;
|
||||
log::info!("{:?} used to establish {typ} connection", start.elapsed());
|
||||
log::info!(
|
||||
"{:?} used to establish {typ} connection with {} punch",
|
||||
start.elapsed(),
|
||||
punch_type
|
||||
);
|
||||
let pk = Self::secure_connection(peer_id, signed_id_pk, key, &mut conn).await?;
|
||||
Ok((conn, direct, pk, kcp))
|
||||
log::info!("{} punch secure_connection ok", punch_type);
|
||||
Ok((conn, direct, pk, kcp, typ))
|
||||
}
|
||||
|
||||
/// Establish secure connection with the server.
|
||||
|
||||
@@ -174,13 +174,14 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(((mut peer, direct, pk, kcp), (feedback, rendezvous_server))) => {
|
||||
Ok(((mut peer, direct, pk, kcp, stream_type), (feedback, rendezvous_server))) => {
|
||||
self.handler
|
||||
.connection_round_state
|
||||
.lock()
|
||||
.unwrap()
|
||||
.set_connected();
|
||||
self.handler.set_connection_type(peer.is_secured(), direct); // flutter -> connection_ready
|
||||
self.handler
|
||||
.set_connection_type(peer.is_secured(), direct, stream_type); // flutter -> connection_ready
|
||||
self.handler.update_direct(Some(direct));
|
||||
if conn_type == ConnType::DEFAULT_CONN || conn_type == ConnType::VIEW_CAMERA {
|
||||
self.handler
|
||||
|
||||
@@ -716,12 +716,13 @@ impl InvokeUiSession for FlutterHandler {
|
||||
);
|
||||
}
|
||||
|
||||
fn set_connection_type(&self, is_secured: bool, direct: bool) {
|
||||
fn set_connection_type(&self, is_secured: bool, direct: bool, stream_type: &str) {
|
||||
self.push_event(
|
||||
"connection_ready",
|
||||
&[
|
||||
("secure", &is_secured.to_string()),
|
||||
("direct", &direct.to_string()),
|
||||
("stream_type", &stream_type.to_string()),
|
||||
],
|
||||
&[],
|
||||
);
|
||||
|
||||
@@ -118,7 +118,7 @@ async fn connect_and_login(
|
||||
} else {
|
||||
ConnType::PORT_FORWARD
|
||||
};
|
||||
let ((mut stream, direct, _pk, _kcp), (feedback, rendezvous_server)) =
|
||||
let ((mut stream, direct, _pk, _kcp, _stream_type), (feedback, rendezvous_server)) =
|
||||
Client::start(id, key, token, conn_type, interface.clone()).await?;
|
||||
interface.update_direct(Some(direct));
|
||||
let mut buffer = Vec::new();
|
||||
|
||||
@@ -117,6 +117,13 @@ class Header: Reactor.Component {
|
||||
icon_conn = svg_insecure_relay;
|
||||
title_conn = translate("Relayed and unencrypted connection");
|
||||
}
|
||||
var stream_type = this.stream_type;
|
||||
if (stream_type == "Relay") {
|
||||
stream_type = "TCP";
|
||||
}
|
||||
if (stream_type) {
|
||||
title_conn += " (" + stream_type + ")";
|
||||
}
|
||||
var title = get_id();
|
||||
if (pi.hostname) title += "(" + pi.username + "@" + pi.hostname + ")";
|
||||
if ((pi.displays || []).length == 0) {
|
||||
@@ -695,10 +702,11 @@ function startChat() {
|
||||
chatbox = view.window(params);
|
||||
}
|
||||
|
||||
handler.setConnectionType = function(secured, direct) {
|
||||
handler.setConnectionType = function(secured, direct, stream_type) {
|
||||
header.update({
|
||||
secure_connection: secured,
|
||||
direct_connection: direct,
|
||||
stream_type: stream_type,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -178,8 +178,11 @@ impl InvokeUiSession for SciterHandler {
|
||||
self.call("setCursorPosition", &make_args!(cp.x, cp.y));
|
||||
}
|
||||
|
||||
fn set_connection_type(&self, is_secured: bool, direct: bool) {
|
||||
self.call("setConnectionType", &make_args!(is_secured, direct));
|
||||
fn set_connection_type(&self, is_secured: bool, direct: bool, stream_type: &str) {
|
||||
self.call(
|
||||
"setConnectionType",
|
||||
&make_args!(is_secured, direct, stream_type.to_string()),
|
||||
);
|
||||
}
|
||||
|
||||
fn set_fingerprint(&self, _fingerprint: String) {}
|
||||
|
||||
@@ -192,7 +192,11 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
}
|
||||
|
||||
pub fn is_default(&self) -> bool {
|
||||
self.lc.read().unwrap().conn_type.eq(&ConnType::DEFAULT_CONN)
|
||||
self.lc
|
||||
.read()
|
||||
.unwrap()
|
||||
.conn_type
|
||||
.eq(&ConnType::DEFAULT_CONN)
|
||||
}
|
||||
|
||||
pub fn is_view_camera(&self) -> bool {
|
||||
@@ -804,7 +808,6 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
self.send(Data::Message(msg_out));
|
||||
}
|
||||
|
||||
|
||||
pub fn capture_displays(&self, add: Vec<i32>, sub: Vec<i32>, set: Vec<i32>) {
|
||||
let mut misc = Misc::new();
|
||||
misc.set_capture_displays(CaptureDisplays {
|
||||
@@ -1611,7 +1614,7 @@ pub trait InvokeUiSession: Send + Sync + Clone + 'static + Sized + Default {
|
||||
fn set_permission(&self, name: &str, value: bool);
|
||||
fn close_success(&self);
|
||||
fn update_quality_status(&self, qs: QualityStatus);
|
||||
fn set_connection_type(&self, is_secured: bool, direct: bool);
|
||||
fn set_connection_type(&self, is_secured: bool, direct: bool, stream_type: &str);
|
||||
fn set_fingerprint(&self, fingerprint: String);
|
||||
fn job_error(&self, id: i32, err: String, file_num: i32);
|
||||
fn job_done(&self, id: i32, file_num: i32);
|
||||
|
||||
Reference in New Issue
Block a user