mirror of
https://github.com/Devolutions/IronRDP.git
synced 2025-08-04 15:18:17 +00:00
fix(client)!: fix name of client address field (#754)
This commit is contained in:
parent
a82e280b93
commit
bdde2c76de
9 changed files with 32 additions and 32 deletions
|
@ -132,7 +132,7 @@ async fn connect(
|
|||
let mut framed = ironrdp_tokio::TokioFramed::new(stream);
|
||||
|
||||
let mut connector = connector::ClientConnector::new(config.connector.clone())
|
||||
.with_server_addr(server_addr)
|
||||
.with_client_addr(server_addr)
|
||||
.with_static_channel(
|
||||
ironrdp::dvc::DrdynvcClient::new().with_dynamic_channel(DisplayControlClient::new(|_| Ok(Vec::new()))),
|
||||
)
|
||||
|
@ -335,7 +335,7 @@ where
|
|||
.parse()
|
||||
.map_err(|e| connector::custom_err!("failed to parse server address sent by proxy", e))?;
|
||||
|
||||
connector.attach_server_addr(server_addr);
|
||||
connector.attach_client_addr(server_addr);
|
||||
|
||||
let connector::ClientConnectorState::ConnectionInitiationWaitConfirm { .. } = connector.state else {
|
||||
return Err(connector::general_err!("invalid connector state (wait confirm)"));
|
||||
|
|
|
@ -123,7 +123,7 @@ impl State for ClientConnectorState {
|
|||
pub struct ClientConnector {
|
||||
pub config: Config,
|
||||
pub state: ClientConnectorState,
|
||||
pub server_addr: Option<SocketAddr>,
|
||||
pub client_addr: Option<SocketAddr>,
|
||||
pub static_channels: StaticChannelSet,
|
||||
}
|
||||
|
||||
|
@ -132,21 +132,21 @@ impl ClientConnector {
|
|||
Self {
|
||||
config,
|
||||
state: ClientConnectorState::ConnectionInitiationSendRequest,
|
||||
server_addr: None,
|
||||
client_addr: None,
|
||||
static_channels: StaticChannelSet::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Must be set to the actual target server address (as opposed to the proxy)
|
||||
/// Sets the client address to be used in the Client Info PDU.
|
||||
#[must_use]
|
||||
pub fn with_server_addr(mut self, addr: SocketAddr) -> Self {
|
||||
self.server_addr = Some(addr);
|
||||
pub fn with_client_addr(mut self, addr: SocketAddr) -> Self {
|
||||
self.client_addr = Some(addr);
|
||||
self
|
||||
}
|
||||
|
||||
/// Must be set to the actual target server address (as opposed to the proxy)
|
||||
pub fn attach_server_addr(&mut self, addr: SocketAddr) {
|
||||
self.server_addr = Some(addr);
|
||||
/// Sets the client address to be used in the Client Info PDU.
|
||||
pub fn attach_client_addr(&mut self, addr: SocketAddr) {
|
||||
self.client_addr = Some(addr);
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
|
@ -448,12 +448,12 @@ impl Sequence for ClientConnector {
|
|||
} => {
|
||||
debug!("Secure Settings Exchange");
|
||||
|
||||
let routing_addr = self
|
||||
.server_addr
|
||||
let client_addr = self
|
||||
.client_addr
|
||||
.as_ref()
|
||||
.ok_or_else(|| general_err!("server address is missing"))?;
|
||||
.ok_or_else(|| general_err!("client address is missing"))?;
|
||||
|
||||
let client_info = create_client_info_pdu(&self.config, routing_addr);
|
||||
let client_info = create_client_info_pdu(&self.config, client_addr);
|
||||
|
||||
debug!(message = ?client_info, "Send");
|
||||
|
||||
|
@ -710,7 +710,7 @@ fn create_gcc_blocks<'a>(
|
|||
}
|
||||
}
|
||||
|
||||
fn create_client_info_pdu(config: &Config, routing_addr: &SocketAddr) -> rdp::ClientInfoPdu {
|
||||
fn create_client_info_pdu(config: &Config, client_addr: &SocketAddr) -> rdp::ClientInfoPdu {
|
||||
use ironrdp_pdu::rdp::client_info::{
|
||||
AddressFamily, ClientInfo, ClientInfoFlags, CompressionType, Credentials, ExtendedClientInfo,
|
||||
ExtendedClientOptionalInfo,
|
||||
|
@ -757,11 +757,11 @@ fn create_client_info_pdu(config: &Config, routing_addr: &SocketAddr) -> rdp::Cl
|
|||
alternate_shell: String::new(),
|
||||
work_dir: String::new(),
|
||||
extra_info: ExtendedClientInfo {
|
||||
address_family: match routing_addr {
|
||||
address_family: match client_addr {
|
||||
SocketAddr::V4(_) => AddressFamily::INET,
|
||||
SocketAddr::V6(_) => AddressFamily::INET_6,
|
||||
},
|
||||
address: routing_addr.ip().to_string(),
|
||||
address: client_addr.ip().to_string(),
|
||||
dir: config.client_dir.clone(),
|
||||
optional_data: ExtendedClientOptionalInfo::builder()
|
||||
.timezone(TimezoneInfo {
|
||||
|
|
|
@ -198,7 +198,7 @@ where
|
|||
let addr = rx.await.unwrap().unwrap();
|
||||
let tcp_stream = TcpStream::connect(addr).await.expect("TCP connect");
|
||||
let mut framed = ironrdp_tokio::TokioFramed::new(tcp_stream);
|
||||
let mut connector = connector::ClientConnector::new(client_config).with_server_addr(addr);
|
||||
let mut connector = connector::ClientConnector::new(client_config).with_client_addr(addr);
|
||||
let should_upgrade = ironrdp_async::connect_begin(&mut framed, &mut connector)
|
||||
.await
|
||||
.expect("begin connection");
|
||||
|
|
|
@ -1059,7 +1059,7 @@ where
|
|||
.parse()
|
||||
.context("failed to parse server address sent by proxy")?;
|
||||
|
||||
connector.attach_server_addr(server_addr);
|
||||
connector.attach_client_addr(server_addr);
|
||||
|
||||
let connector::ClientConnectorState::ConnectionInitiationWaitConfirm { .. } = connector.state else {
|
||||
return Err(anyhow::Error::msg("invalid connector state (wait confirm)").into());
|
||||
|
|
|
@ -239,7 +239,7 @@ fn connect(
|
|||
|
||||
let mut framed = ironrdp_blocking::Framed::new(tcp_stream);
|
||||
|
||||
let mut connector = connector::ClientConnector::new(config).with_server_addr(server_addr);
|
||||
let mut connector = connector::ClientConnector::new(config).with_client_addr(server_addr);
|
||||
|
||||
let should_upgrade = ironrdp_blocking::connect_begin(&mut framed, &mut connector).context("begin connection")?;
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ public partial class ClientConnector: IDisposable
|
|||
/// Must use
|
||||
/// </summary>
|
||||
/// <exception cref="IronRdpException"></exception>
|
||||
public void WithServerAddr(string serverAddr)
|
||||
public void WithClientAddr(string clientAddr)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
|
@ -67,11 +67,11 @@ public partial class ClientConnector: IDisposable
|
|||
{
|
||||
throw new ObjectDisposedException("ClientConnector");
|
||||
}
|
||||
byte[] serverAddrBuf = DiplomatUtils.StringToUtf8(serverAddr);
|
||||
nuint serverAddrBufLength = (nuint)serverAddrBuf.Length;
|
||||
fixed (byte* serverAddrBufPtr = serverAddrBuf)
|
||||
byte[] clientAddrBuf = DiplomatUtils.StringToUtf8(clientAddr);
|
||||
nuint clientAddrBufLength = (nuint)clientAddrBuf.Length;
|
||||
fixed (byte* clientAddrBufPtr = clientAddrBuf)
|
||||
{
|
||||
Raw.ConnectorFfiResultVoidBoxIronRdpError result = Raw.ClientConnector.WithServerAddr(_inner, serverAddrBufPtr, serverAddrBufLength);
|
||||
Raw.ConnectorFfiResultVoidBoxIronRdpError result = Raw.ClientConnector.WithClientAddr(_inner, clientAddrBufPtr, clientAddrBufLength);
|
||||
if (!result.isOk)
|
||||
{
|
||||
throw new IronRdpException(new IronRdpError(result.Err));
|
||||
|
|
|
@ -22,8 +22,8 @@ public partial struct ClientConnector
|
|||
/// <summary>
|
||||
/// Must use
|
||||
/// </summary>
|
||||
[DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnector_with_server_addr", ExactSpelling = true)]
|
||||
public static unsafe extern ConnectorFfiResultVoidBoxIronRdpError WithServerAddr(ClientConnector* self, byte* serverAddr, nuint serverAddrSz);
|
||||
[DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnector_with_client_addr", ExactSpelling = true)]
|
||||
public static unsafe extern ConnectorFfiResultVoidBoxIronRdpError WithClientAddr(ClientConnector* self, byte* clientAddr, nuint clientAddrSz);
|
||||
|
||||
/// <summary>
|
||||
/// Must use
|
||||
|
|
|
@ -21,8 +21,8 @@ public static class Connection
|
|||
"Cannot resolve DNS to " + serverName);
|
||||
}
|
||||
|
||||
var serverAddr = ip[0] + ":" + port;
|
||||
connector.WithServerAddr(serverAddr);
|
||||
var clientAddr = ip[0] + ":" + port;
|
||||
connector.WithClientAddr(clientAddr);
|
||||
connector.WithDynamicChannelDisplayControl();
|
||||
if (factory != null)
|
||||
{
|
||||
|
|
|
@ -32,12 +32,12 @@ pub mod ffi {
|
|||
}
|
||||
|
||||
/// Must use
|
||||
pub fn with_server_addr(&mut self, server_addr: &str) -> Result<(), Box<IronRdpError>> {
|
||||
pub fn with_client_addr(&mut self, client_addr: &str) -> Result<(), Box<IronRdpError>> {
|
||||
let Some(connector) = self.0.take() else {
|
||||
return Err(IronRdpErrorKind::Consumed.into());
|
||||
};
|
||||
let server_addr = server_addr.parse().map_err(|_| IronRdpErrorKind::Generic)?;
|
||||
self.0 = Some(connector.with_server_addr(server_addr));
|
||||
let client_addr = client_addr.parse().map_err(|_| IronRdpErrorKind::Generic)?;
|
||||
self.0 = Some(connector.with_client_addr(client_addr));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue