fetch: log handshake error
When performing a handshake, the error source is hidden in the error variant and never shown. To get insight as to what the error was, it is logged when it is encounterd. Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
parent
6efd0d97a5
commit
c02ff1e47e
|
|
@ -9,6 +9,7 @@ mod refs;
|
||||||
mod stage;
|
mod stage;
|
||||||
mod state;
|
mod state;
|
||||||
|
|
||||||
|
use gix_protocol::handshake;
|
||||||
pub use handle::Handle;
|
pub use handle::Handle;
|
||||||
pub use policy::{Allowed, BlockList, Scope};
|
pub use policy::{Allowed, BlockList, Scope};
|
||||||
use radicle::storage::ReadRepository as _;
|
use radicle::storage::ReadRepository as _;
|
||||||
|
|
@ -62,10 +63,7 @@ where
|
||||||
if local == remote {
|
if local == remote {
|
||||||
return Err(Error::ReplicateSelf);
|
return Err(Error::ReplicateSelf);
|
||||||
}
|
}
|
||||||
let handshake = handle
|
let handshake = perform_handshake(handle)?;
|
||||||
.transport
|
|
||||||
.handshake()
|
|
||||||
.map_err(|err| Error::Handshake { err })?;
|
|
||||||
let state = FetchState::default();
|
let state = FetchState::default();
|
||||||
|
|
||||||
// N.b. ensure that we ignore the local peer's key.
|
// N.b. ensure that we ignore the local peer's key.
|
||||||
|
|
@ -99,10 +97,7 @@ where
|
||||||
if *handle.local() == remote {
|
if *handle.local() == remote {
|
||||||
return Err(Error::ReplicateSelf);
|
return Err(Error::ReplicateSelf);
|
||||||
}
|
}
|
||||||
let handshake = handle
|
let handshake = perform_handshake(handle)?;
|
||||||
.transport
|
|
||||||
.handshake()
|
|
||||||
.map_err(|err| Error::Handshake { err })?;
|
|
||||||
let state = FetchState::default();
|
let state = FetchState::default();
|
||||||
let result = state
|
let result = state
|
||||||
.run(handle, &handshake, limit, remote, None)
|
.run(handle, &handshake, limit, remote, None)
|
||||||
|
|
@ -116,3 +111,13 @@ where
|
||||||
);
|
);
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn perform_handshake<S>(handle: &mut Handle<S>) -> Result<handshake::Outcome, Error>
|
||||||
|
where
|
||||||
|
S: transport::ConnectionStream,
|
||||||
|
{
|
||||||
|
handle.transport.handshake().map_err(|err| {
|
||||||
|
log::warn!(target: "fetch", "Failed to perform handshake: {err}");
|
||||||
|
Error::Handshake { err }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue