fix: inject socket local address for the client addr (#759)

We used to inject the resolved target server address, but that is not
what is expected. Server typically ignores this field so this was not a
problem up until now.
This commit is contained in:
Benoît Cortier 2025-04-21 11:08:50 +02:00 committed by GitHub
parent ec1832bba0
commit 712da42ded
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 125 additions and 112 deletions

View file

@ -123,32 +123,21 @@ impl State for ClientConnectorState {
pub struct ClientConnector {
pub config: Config,
pub state: ClientConnectorState,
pub client_addr: Option<SocketAddr>,
/// The client address to be used in the Client Info PDU.
pub client_addr: SocketAddr,
pub static_channels: StaticChannelSet,
}
impl ClientConnector {
pub fn new(config: Config) -> Self {
pub fn new(config: Config, client_addr: SocketAddr) -> Self {
Self {
config,
state: ClientConnectorState::ConnectionInitiationSendRequest,
client_addr: None,
client_addr,
static_channels: StaticChannelSet::new(),
}
}
/// Sets the client address to be used in the Client Info PDU.
#[must_use]
pub fn with_client_addr(mut self, addr: SocketAddr) -> Self {
self.client_addr = Some(addr);
self
}
/// 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]
pub fn with_static_channel<T>(mut self, channel: T) -> Self
where
@ -448,12 +437,7 @@ impl Sequence for ClientConnector {
} => {
debug!("Secure Settings Exchange");
let client_addr = self
.client_addr
.as_ref()
.ok_or_else(|| general_err!("client address is missing"))?;
let client_info = create_client_info_pdu(&self.config, client_addr);
let client_info = create_client_info_pdu(&self.config, &self.client_addr);
debug!(message = ?client_info, "Send");