use dial9_tokio_telemetry::telemetry::{TelemetryHandle, clock_monotonic_ns, record_event};
use dial9_trace_format::TraceEvent;
use rama_net::address::Host;
#[derive(TraceEvent)]
pub struct Socks5HandshakeAuth {
#[traceevent(timestamp)]
pub timestamp_ns: u64,
pub auth_method: u32,
pub success: bool,
}
#[derive(TraceEvent)]
pub struct Socks5HandshakeConnect {
#[traceevent(timestamp)]
pub timestamp_ns: u64,
pub destination_host: Host,
pub destination_port: u32,
pub reply_kind: u32,
}
#[inline]
pub(crate) fn record_handshake_auth(auth_method: u8, success: bool) {
let handle = TelemetryHandle::current();
if handle.is_enabled() {
record_event(
Socks5HandshakeAuth {
timestamp_ns: clock_monotonic_ns(),
auth_method: auth_method as u32,
success,
},
&handle,
);
}
}
#[inline]
pub(crate) fn record_handshake_connect(host: Host, port: u16, reply_kind: u8) {
let handle = TelemetryHandle::current();
if handle.is_enabled() {
record_event(
Socks5HandshakeConnect {
timestamp_ns: clock_monotonic_ns(),
destination_host: host,
destination_port: port as u32,
reply_kind: reply_kind as u32,
},
&handle,
);
}
}