Add SOCKS5 CONNECT support
This commit is contained in:
1 parent
f191d66ee4
commit
488f25491d
10 files changed
+1145
-65
No files matched your search
+23
-9
@@ -128,42 +128,53 @@ impl Metrics {
|
||||
);
|
||||
}
|
||||
|
||||
pub fn acl_decision(&self, decision: &str, reason: &str) {
|
||||
pub fn acl_decision(&self, protocol: &str, decision: &str, reason: &str) {
|
||||
self.acl_decisions.add(
|
||||
1,
|
||||
&[
|
||||
KeyValue::new("proxy.protocol", protocol.to_owned()),
|
||||
KeyValue::new("acl.decision", decision.to_owned()),
|
||||
KeyValue::new("acl.reason", reason.to_owned()),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
pub fn tunnel_started(&self) -> ActiveTunnel {
|
||||
self.active_tunnels.add(1, &[]);
|
||||
pub fn tunnel_started(&self, protocol: &'static str) -> ActiveTunnel {
|
||||
self.active_tunnels
|
||||
.add(1, &[KeyValue::new("proxy.protocol", protocol)]);
|
||||
ActiveTunnel {
|
||||
metrics: self.clone(),
|
||||
protocol,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tunnel_finished(
|
||||
&self,
|
||||
protocol: &str,
|
||||
duration: Duration,
|
||||
client_to_upstream: u64,
|
||||
upstream_to_client: u64,
|
||||
error_type: Option<&str>,
|
||||
) {
|
||||
let attributes = error_type
|
||||
.map(|value| vec![KeyValue::new("error.type", value.to_owned())])
|
||||
.unwrap_or_default();
|
||||
let mut attributes = vec![KeyValue::new("proxy.protocol", protocol.to_owned())];
|
||||
if let Some(error_type) = error_type {
|
||||
attributes.push(KeyValue::new("error.type", error_type.to_owned()));
|
||||
}
|
||||
self.tunnel_duration
|
||||
.record(duration.as_secs_f64(), &attributes);
|
||||
self.tunnel_bytes.add(
|
||||
client_to_upstream,
|
||||
&[KeyValue::new("direction", "client_to_upstream")],
|
||||
&[
|
||||
KeyValue::new("proxy.protocol", protocol.to_owned()),
|
||||
KeyValue::new("direction", "client_to_upstream"),
|
||||
],
|
||||
);
|
||||
self.tunnel_bytes.add(
|
||||
upstream_to_client,
|
||||
&[KeyValue::new("direction", "upstream_to_client")],
|
||||
&[
|
||||
KeyValue::new("proxy.protocol", protocol.to_owned()),
|
||||
KeyValue::new("direction", "upstream_to_client"),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -180,10 +191,13 @@ impl Drop for ActiveRequest {
|
||||
|
||||
pub(crate) struct ActiveTunnel {
|
||||
metrics: Metrics,
|
||||
protocol: &'static str,
|
||||
}
|
||||
|
||||
impl Drop for ActiveTunnel {
|
||||
fn drop(&mut self) {
|
||||
self.metrics.active_tunnels.add(-1, &[]);
|
||||
self.metrics
|
||||
.active_tunnels
|
||||
.add(-1, &[KeyValue::new("proxy.protocol", self.protocol)]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user