fix(client)!: fix name of client address field (#754)

This commit is contained in:
Zac Bergquist 2025-04-16 02:23:49 -06:00 committed by GitHub
parent a82e280b93
commit bdde2c76de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 32 additions and 32 deletions

View file

@ -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)"));

View file

@ -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 {

View file

@ -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");

View file

@ -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());

View file

@ -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")?;

View file

@ -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));

View file

@ -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

View file

@ -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)
{

View file

@ -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(())
}