1#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
3pub struct RequestActiveConnections {
4 #[prost(string, optional, tag = "2")]
5 pub pod_ip: ::core::option::Option<::prost::alloc::string::String>,
6}
7#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
8pub struct ConnectionEvent {
9 #[prost(string, tag = "1")]
10 pub event_id: ::prost::alloc::string::String,
11 #[prost(string, tag = "2")]
13 pub src_ip_port: ::prost::alloc::string::String,
14 #[prost(string, tag = "3")]
16 pub dst_ip_port: ::prost::alloc::string::String,
17}
18#[derive(Clone, PartialEq, ::prost::Message)]
19pub struct ActiveConnectionResponse {
20 #[prost(string, tag = "1")]
21 pub status: ::prost::alloc::string::String,
22 #[prost(message, repeated, tag = "2")]
24 pub events: ::prost::alloc::vec::Vec<ConnectionEvent>,
25}
26#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
27pub struct LatencyMetric {
28 #[prost(uint64, tag = "1")]
30 pub delta_us: u64,
31 #[prost(uint64, tag = "2")]
33 pub timestamp_us: u64,
34 #[prost(uint32, tag = "3")]
36 pub tgid: u32,
37 #[prost(string, tag = "4")]
39 pub process_name: ::prost::alloc::string::String,
40 #[prost(uint32, tag = "5")]
42 pub local_port: u32,
43 #[prost(uint32, tag = "6")]
45 pub remote_port: u32,
46 #[prost(uint32, tag = "7")]
48 pub address_family: u32,
49 #[prost(string, tag = "8")]
51 pub src_address_v4: ::prost::alloc::string::String,
52 #[prost(string, tag = "9")]
54 pub dst_address_v4: ::prost::alloc::string::String,
55 #[prost(string, tag = "10")]
57 pub src_address_v6: ::prost::alloc::string::String,
58 #[prost(string, tag = "11")]
60 pub dst_address_v6: ::prost::alloc::string::String,
61}
62#[derive(Clone, PartialEq, ::prost::Message)]
63pub struct LatencyMetricsResponse {
64 #[prost(string, tag = "1")]
65 pub status: ::prost::alloc::string::String,
66 #[prost(message, repeated, tag = "2")]
67 pub metrics: ::prost::alloc::vec::Vec<LatencyMetric>,
68 #[prost(uint32, tag = "3")]
69 pub total_count: u32,
70 #[prost(double, tag = "4")]
72 pub average_latency_us: f64,
73 #[prost(double, tag = "5")]
75 pub min_latency_us: f64,
76 #[prost(double, tag = "6")]
78 pub max_latency_us: f64,
79}
80#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
81pub struct DroppedPacketMetric {
82 #[prost(uint32, tag = "1")]
84 pub tgid: u32,
85 #[prost(string, tag = "2")]
87 pub process_name: ::prost::alloc::string::String,
88 #[prost(int32, tag = "3")]
90 pub sk_drops: i32,
91 #[prost(int32, tag = "4")]
93 pub sk_err: i32,
94 #[prost(int32, tag = "5")]
96 pub sk_err_soft: i32,
97 #[prost(uint32, tag = "6")]
99 pub sk_backlog_len: u32,
100 #[prost(int32, tag = "7")]
102 pub sk_wmem_queued: i32,
103 #[prost(int32, tag = "8")]
105 pub sk_rcvbuf: i32,
106 #[prost(uint32, tag = "9")]
108 pub sk_ack_backlog: u32,
109 #[prost(uint64, tag = "10")]
111 pub timestamp_us: u64,
112}
113#[derive(Clone, PartialEq, ::prost::Message)]
114pub struct DroppedPacketsResponse {
115 #[prost(string, tag = "1")]
116 pub status: ::prost::alloc::string::String,
117 #[prost(message, repeated, tag = "2")]
118 pub metrics: ::prost::alloc::vec::Vec<DroppedPacketMetric>,
119 #[prost(uint32, tag = "3")]
121 pub total_drops: u32,
122}
123#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
124pub struct VethResponse {
125 #[prost(string, tag = "1")]
126 pub status: ::prost::alloc::string::String,
127 #[prost(string, repeated, tag = "2")]
129 pub veth_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
130 #[prost(int32, tag = "3")]
131 pub tot_monitored_veth: i32,
132}
133#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
134pub struct VethEvent {
135 #[prost(string, tag = "1")]
137 pub name: ::prost::alloc::string::String,
138 #[prost(uint64, tag = "2")]
140 pub state: u64,
141 #[prost(string, tag = "3")]
143 pub dev_addr: ::prost::alloc::string::String,
144 #[prost(uint32, tag = "4")]
146 pub event_type: u32,
147 #[prost(uint32, tag = "5")]
149 pub netns: u32,
150 #[prost(uint32, tag = "6")]
152 pub pid: u32,
153}
154#[derive(Clone, PartialEq, ::prost::Message)]
156pub struct VethHashMapResponse {
157 #[prost(string, tag = "1")]
158 pub status: ::prost::alloc::string::String,
159 #[prost(map = "string, string", tag = "2")]
160 pub veths: ::std::collections::HashMap<
161 ::prost::alloc::string::String,
162 ::prost::alloc::string::String,
163 >,
164}
165#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
166pub struct AddIpToBlocklistRequest {
167 #[prost(string, optional, tag = "1")]
168 pub ip: ::core::option::Option<::prost::alloc::string::String>,
169}
170#[derive(Clone, PartialEq, ::prost::Message)]
171pub struct BlocklistResponse {
172 #[prost(string, tag = "1")]
173 pub status: ::prost::alloc::string::String,
174 #[prost(map = "string, string", tag = "2")]
175 pub events: ::std::collections::HashMap<
176 ::prost::alloc::string::String,
177 ::prost::alloc::string::String,
178 >,
179}
180#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
181pub struct RmIpFromBlocklistRequest {
182 #[prost(string, tag = "1")]
183 pub ip: ::prost::alloc::string::String,
184}
185#[derive(Clone, PartialEq, ::prost::Message)]
186pub struct RmIpFromBlocklistResponse {
187 #[prost(string, tag = "1")]
188 pub status: ::prost::alloc::string::String,
189 #[prost(map = "string, string", tag = "2")]
190 pub events: ::std::collections::HashMap<
191 ::prost::alloc::string::String,
192 ::prost::alloc::string::String,
193 >,
194}
195pub mod agent_client {
197 #![allow(
198 unused_variables,
199 dead_code,
200 missing_docs,
201 clippy::wildcard_imports,
202 clippy::let_unit_value,
203 )]
204 use tonic::codegen::*;
205 use tonic::codegen::http::Uri;
206 #[derive(Debug, Clone)]
207 pub struct AgentClient<T> {
208 inner: tonic::client::Grpc<T>,
209 }
210 impl AgentClient<tonic::transport::Channel> {
211 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
213 where
214 D: TryInto<tonic::transport::Endpoint>,
215 D::Error: Into<StdError>,
216 {
217 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
218 Ok(Self::new(conn))
219 }
220 }
221 impl<T> AgentClient<T>
222 where
223 T: tonic::client::GrpcService<tonic::body::Body>,
224 T::Error: Into<StdError>,
225 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
226 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
227 {
228 pub fn new(inner: T) -> Self {
229 let inner = tonic::client::Grpc::new(inner);
230 Self { inner }
231 }
232 pub fn with_origin(inner: T, origin: Uri) -> Self {
233 let inner = tonic::client::Grpc::with_origin(inner, origin);
234 Self { inner }
235 }
236 pub fn with_interceptor<F>(
237 inner: T,
238 interceptor: F,
239 ) -> AgentClient<InterceptedService<T, F>>
240 where
241 F: tonic::service::Interceptor,
242 T::ResponseBody: Default,
243 T: tonic::codegen::Service<
244 http::Request<tonic::body::Body>,
245 Response = http::Response<
246 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
247 >,
248 >,
249 <T as tonic::codegen::Service<
250 http::Request<tonic::body::Body>,
251 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
252 {
253 AgentClient::new(InterceptedService::new(inner, interceptor))
254 }
255 #[must_use]
260 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
261 self.inner = self.inner.send_compressed(encoding);
262 self
263 }
264 #[must_use]
266 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
267 self.inner = self.inner.accept_compressed(encoding);
268 self
269 }
270 #[must_use]
274 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
275 self.inner = self.inner.max_decoding_message_size(limit);
276 self
277 }
278 #[must_use]
282 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
283 self.inner = self.inner.max_encoding_message_size(limit);
284 self
285 }
286 pub async fn active_connections(
288 &mut self,
289 request: impl tonic::IntoRequest<super::RequestActiveConnections>,
290 ) -> std::result::Result<
291 tonic::Response<super::ActiveConnectionResponse>,
292 tonic::Status,
293 > {
294 self.inner
295 .ready()
296 .await
297 .map_err(|e| {
298 tonic::Status::unknown(
299 format!("Service was not ready: {}", e.into()),
300 )
301 })?;
302 let codec = tonic_prost::ProstCodec::default();
303 let path = http::uri::PathAndQuery::from_static(
304 "/agent.Agent/ActiveConnections",
305 );
306 let mut req = request.into_request();
307 req.extensions_mut()
308 .insert(GrpcMethod::new("agent.Agent", "ActiveConnections"));
309 self.inner.unary(req, path, codec).await
310 }
311 pub async fn add_ip_to_blocklist(
313 &mut self,
314 request: impl tonic::IntoRequest<super::AddIpToBlocklistRequest>,
315 ) -> std::result::Result<
316 tonic::Response<super::BlocklistResponse>,
317 tonic::Status,
318 > {
319 self.inner
320 .ready()
321 .await
322 .map_err(|e| {
323 tonic::Status::unknown(
324 format!("Service was not ready: {}", e.into()),
325 )
326 })?;
327 let codec = tonic_prost::ProstCodec::default();
328 let path = http::uri::PathAndQuery::from_static(
329 "/agent.Agent/AddIpToBlocklist",
330 );
331 let mut req = request.into_request();
332 req.extensions_mut()
333 .insert(GrpcMethod::new("agent.Agent", "AddIpToBlocklist"));
334 self.inner.unary(req, path, codec).await
335 }
336 pub async fn check_blocklist(
337 &mut self,
338 request: impl tonic::IntoRequest<()>,
339 ) -> std::result::Result<
340 tonic::Response<super::BlocklistResponse>,
341 tonic::Status,
342 > {
343 self.inner
344 .ready()
345 .await
346 .map_err(|e| {
347 tonic::Status::unknown(
348 format!("Service was not ready: {}", e.into()),
349 )
350 })?;
351 let codec = tonic_prost::ProstCodec::default();
352 let path = http::uri::PathAndQuery::from_static(
353 "/agent.Agent/CheckBlocklist",
354 );
355 let mut req = request.into_request();
356 req.extensions_mut()
357 .insert(GrpcMethod::new("agent.Agent", "CheckBlocklist"));
358 self.inner.unary(req, path, codec).await
359 }
360 pub async fn rm_ip_from_blocklist(
362 &mut self,
363 request: impl tonic::IntoRequest<super::RmIpFromBlocklistRequest>,
364 ) -> std::result::Result<
365 tonic::Response<super::RmIpFromBlocklistResponse>,
366 tonic::Status,
367 > {
368 self.inner
369 .ready()
370 .await
371 .map_err(|e| {
372 tonic::Status::unknown(
373 format!("Service was not ready: {}", e.into()),
374 )
375 })?;
376 let codec = tonic_prost::ProstCodec::default();
377 let path = http::uri::PathAndQuery::from_static(
378 "/agent.Agent/RmIpFromBlocklist",
379 );
380 let mut req = request.into_request();
381 req.extensions_mut()
382 .insert(GrpcMethod::new("agent.Agent", "RmIpFromBlocklist"));
383 self.inner.unary(req, path, codec).await
384 }
385 pub async fn get_latency_metrics(
387 &mut self,
388 request: impl tonic::IntoRequest<()>,
389 ) -> std::result::Result<
390 tonic::Response<super::LatencyMetricsResponse>,
391 tonic::Status,
392 > {
393 self.inner
394 .ready()
395 .await
396 .map_err(|e| {
397 tonic::Status::unknown(
398 format!("Service was not ready: {}", e.into()),
399 )
400 })?;
401 let codec = tonic_prost::ProstCodec::default();
402 let path = http::uri::PathAndQuery::from_static(
403 "/agent.Agent/GetLatencyMetrics",
404 );
405 let mut req = request.into_request();
406 req.extensions_mut()
407 .insert(GrpcMethod::new("agent.Agent", "GetLatencyMetrics"));
408 self.inner.unary(req, path, codec).await
409 }
410 pub async fn get_dropped_packets_metrics(
412 &mut self,
413 request: impl tonic::IntoRequest<()>,
414 ) -> std::result::Result<
415 tonic::Response<super::DroppedPacketsResponse>,
416 tonic::Status,
417 > {
418 self.inner
419 .ready()
420 .await
421 .map_err(|e| {
422 tonic::Status::unknown(
423 format!("Service was not ready: {}", e.into()),
424 )
425 })?;
426 let codec = tonic_prost::ProstCodec::default();
427 let path = http::uri::PathAndQuery::from_static(
428 "/agent.Agent/GetDroppedPacketsMetrics",
429 );
430 let mut req = request.into_request();
431 req.extensions_mut()
432 .insert(GrpcMethod::new("agent.Agent", "GetDroppedPacketsMetrics"));
433 self.inner.unary(req, path, codec).await
434 }
435 pub async fn get_tracked_veth(
438 &mut self,
439 request: impl tonic::IntoRequest<()>,
440 ) -> std::result::Result<tonic::Response<super::VethResponse>, tonic::Status> {
441 self.inner
442 .ready()
443 .await
444 .map_err(|e| {
445 tonic::Status::unknown(
446 format!("Service was not ready: {}", e.into()),
447 )
448 })?;
449 let codec = tonic_prost::ProstCodec::default();
450 let path = http::uri::PathAndQuery::from_static(
451 "/agent.Agent/GetTrackedVeth",
452 );
453 let mut req = request.into_request();
454 req.extensions_mut()
455 .insert(GrpcMethod::new("agent.Agent", "GetTrackedVeth"));
456 self.inner.unary(req, path, codec).await
457 }
458 pub async fn get_tracked_veth_from_hash_map(
460 &mut self,
461 request: impl tonic::IntoRequest<()>,
462 ) -> std::result::Result<
463 tonic::Response<super::VethHashMapResponse>,
464 tonic::Status,
465 > {
466 self.inner
467 .ready()
468 .await
469 .map_err(|e| {
470 tonic::Status::unknown(
471 format!("Service was not ready: {}", e.into()),
472 )
473 })?;
474 let codec = tonic_prost::ProstCodec::default();
475 let path = http::uri::PathAndQuery::from_static(
476 "/agent.Agent/GetTrackedVethFromHashMap",
477 );
478 let mut req = request.into_request();
479 req.extensions_mut()
480 .insert(GrpcMethod::new("agent.Agent", "GetTrackedVethFromHashMap"));
481 self.inner.unary(req, path, codec).await
482 }
483 }
484}
485pub mod agent_server {
487 #![allow(
488 unused_variables,
489 dead_code,
490 missing_docs,
491 clippy::wildcard_imports,
492 clippy::let_unit_value,
493 )]
494 use tonic::codegen::*;
495 #[async_trait]
497 pub trait Agent: std::marker::Send + std::marker::Sync + 'static {
498 async fn active_connections(
500 &self,
501 request: tonic::Request<super::RequestActiveConnections>,
502 ) -> std::result::Result<
503 tonic::Response<super::ActiveConnectionResponse>,
504 tonic::Status,
505 >;
506 async fn add_ip_to_blocklist(
508 &self,
509 request: tonic::Request<super::AddIpToBlocklistRequest>,
510 ) -> std::result::Result<
511 tonic::Response<super::BlocklistResponse>,
512 tonic::Status,
513 >;
514 async fn check_blocklist(
515 &self,
516 request: tonic::Request<()>,
517 ) -> std::result::Result<
518 tonic::Response<super::BlocklistResponse>,
519 tonic::Status,
520 >;
521 async fn rm_ip_from_blocklist(
523 &self,
524 request: tonic::Request<super::RmIpFromBlocklistRequest>,
525 ) -> std::result::Result<
526 tonic::Response<super::RmIpFromBlocklistResponse>,
527 tonic::Status,
528 >;
529 async fn get_latency_metrics(
531 &self,
532 request: tonic::Request<()>,
533 ) -> std::result::Result<
534 tonic::Response<super::LatencyMetricsResponse>,
535 tonic::Status,
536 >;
537 async fn get_dropped_packets_metrics(
539 &self,
540 request: tonic::Request<()>,
541 ) -> std::result::Result<
542 tonic::Response<super::DroppedPacketsResponse>,
543 tonic::Status,
544 >;
545 async fn get_tracked_veth(
548 &self,
549 request: tonic::Request<()>,
550 ) -> std::result::Result<tonic::Response<super::VethResponse>, tonic::Status>;
551 async fn get_tracked_veth_from_hash_map(
553 &self,
554 request: tonic::Request<()>,
555 ) -> std::result::Result<
556 tonic::Response<super::VethHashMapResponse>,
557 tonic::Status,
558 >;
559 }
560 #[derive(Debug)]
561 pub struct AgentServer<T> {
562 inner: Arc<T>,
563 accept_compression_encodings: EnabledCompressionEncodings,
564 send_compression_encodings: EnabledCompressionEncodings,
565 max_decoding_message_size: Option<usize>,
566 max_encoding_message_size: Option<usize>,
567 }
568 impl<T> AgentServer<T> {
569 pub fn new(inner: T) -> Self {
570 Self::from_arc(Arc::new(inner))
571 }
572 pub fn from_arc(inner: Arc<T>) -> Self {
573 Self {
574 inner,
575 accept_compression_encodings: Default::default(),
576 send_compression_encodings: Default::default(),
577 max_decoding_message_size: None,
578 max_encoding_message_size: None,
579 }
580 }
581 pub fn with_interceptor<F>(
582 inner: T,
583 interceptor: F,
584 ) -> InterceptedService<Self, F>
585 where
586 F: tonic::service::Interceptor,
587 {
588 InterceptedService::new(Self::new(inner), interceptor)
589 }
590 #[must_use]
592 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
593 self.accept_compression_encodings.enable(encoding);
594 self
595 }
596 #[must_use]
598 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
599 self.send_compression_encodings.enable(encoding);
600 self
601 }
602 #[must_use]
606 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
607 self.max_decoding_message_size = Some(limit);
608 self
609 }
610 #[must_use]
614 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
615 self.max_encoding_message_size = Some(limit);
616 self
617 }
618 }
619 impl<T, B> tonic::codegen::Service<http::Request<B>> for AgentServer<T>
620 where
621 T: Agent,
622 B: Body + std::marker::Send + 'static,
623 B::Error: Into<StdError> + std::marker::Send + 'static,
624 {
625 type Response = http::Response<tonic::body::Body>;
626 type Error = std::convert::Infallible;
627 type Future = BoxFuture<Self::Response, Self::Error>;
628 fn poll_ready(
629 &mut self,
630 _cx: &mut Context<'_>,
631 ) -> Poll<std::result::Result<(), Self::Error>> {
632 Poll::Ready(Ok(()))
633 }
634 fn call(&mut self, req: http::Request<B>) -> Self::Future {
635 match req.uri().path() {
636 "/agent.Agent/ActiveConnections" => {
637 #[allow(non_camel_case_types)]
638 struct ActiveConnectionsSvc<T: Agent>(pub Arc<T>);
639 impl<
640 T: Agent,
641 > tonic::server::UnaryService<super::RequestActiveConnections>
642 for ActiveConnectionsSvc<T> {
643 type Response = super::ActiveConnectionResponse;
644 type Future = BoxFuture<
645 tonic::Response<Self::Response>,
646 tonic::Status,
647 >;
648 fn call(
649 &mut self,
650 request: tonic::Request<super::RequestActiveConnections>,
651 ) -> Self::Future {
652 let inner = Arc::clone(&self.0);
653 let fut = async move {
654 <T as Agent>::active_connections(&inner, request).await
655 };
656 Box::pin(fut)
657 }
658 }
659 let accept_compression_encodings = self.accept_compression_encodings;
660 let send_compression_encodings = self.send_compression_encodings;
661 let max_decoding_message_size = self.max_decoding_message_size;
662 let max_encoding_message_size = self.max_encoding_message_size;
663 let inner = self.inner.clone();
664 let fut = async move {
665 let method = ActiveConnectionsSvc(inner);
666 let codec = tonic_prost::ProstCodec::default();
667 let mut grpc = tonic::server::Grpc::new(codec)
668 .apply_compression_config(
669 accept_compression_encodings,
670 send_compression_encodings,
671 )
672 .apply_max_message_size_config(
673 max_decoding_message_size,
674 max_encoding_message_size,
675 );
676 let res = grpc.unary(method, req).await;
677 Ok(res)
678 };
679 Box::pin(fut)
680 }
681 "/agent.Agent/AddIpToBlocklist" => {
682 #[allow(non_camel_case_types)]
683 struct AddIpToBlocklistSvc<T: Agent>(pub Arc<T>);
684 impl<
685 T: Agent,
686 > tonic::server::UnaryService<super::AddIpToBlocklistRequest>
687 for AddIpToBlocklistSvc<T> {
688 type Response = super::BlocklistResponse;
689 type Future = BoxFuture<
690 tonic::Response<Self::Response>,
691 tonic::Status,
692 >;
693 fn call(
694 &mut self,
695 request: tonic::Request<super::AddIpToBlocklistRequest>,
696 ) -> Self::Future {
697 let inner = Arc::clone(&self.0);
698 let fut = async move {
699 <T as Agent>::add_ip_to_blocklist(&inner, request).await
700 };
701 Box::pin(fut)
702 }
703 }
704 let accept_compression_encodings = self.accept_compression_encodings;
705 let send_compression_encodings = self.send_compression_encodings;
706 let max_decoding_message_size = self.max_decoding_message_size;
707 let max_encoding_message_size = self.max_encoding_message_size;
708 let inner = self.inner.clone();
709 let fut = async move {
710 let method = AddIpToBlocklistSvc(inner);
711 let codec = tonic_prost::ProstCodec::default();
712 let mut grpc = tonic::server::Grpc::new(codec)
713 .apply_compression_config(
714 accept_compression_encodings,
715 send_compression_encodings,
716 )
717 .apply_max_message_size_config(
718 max_decoding_message_size,
719 max_encoding_message_size,
720 );
721 let res = grpc.unary(method, req).await;
722 Ok(res)
723 };
724 Box::pin(fut)
725 }
726 "/agent.Agent/CheckBlocklist" => {
727 #[allow(non_camel_case_types)]
728 struct CheckBlocklistSvc<T: Agent>(pub Arc<T>);
729 impl<T: Agent> tonic::server::UnaryService<()>
730 for CheckBlocklistSvc<T> {
731 type Response = super::BlocklistResponse;
732 type Future = BoxFuture<
733 tonic::Response<Self::Response>,
734 tonic::Status,
735 >;
736 fn call(&mut self, request: tonic::Request<()>) -> Self::Future {
737 let inner = Arc::clone(&self.0);
738 let fut = async move {
739 <T as Agent>::check_blocklist(&inner, request).await
740 };
741 Box::pin(fut)
742 }
743 }
744 let accept_compression_encodings = self.accept_compression_encodings;
745 let send_compression_encodings = self.send_compression_encodings;
746 let max_decoding_message_size = self.max_decoding_message_size;
747 let max_encoding_message_size = self.max_encoding_message_size;
748 let inner = self.inner.clone();
749 let fut = async move {
750 let method = CheckBlocklistSvc(inner);
751 let codec = tonic_prost::ProstCodec::default();
752 let mut grpc = tonic::server::Grpc::new(codec)
753 .apply_compression_config(
754 accept_compression_encodings,
755 send_compression_encodings,
756 )
757 .apply_max_message_size_config(
758 max_decoding_message_size,
759 max_encoding_message_size,
760 );
761 let res = grpc.unary(method, req).await;
762 Ok(res)
763 };
764 Box::pin(fut)
765 }
766 "/agent.Agent/RmIpFromBlocklist" => {
767 #[allow(non_camel_case_types)]
768 struct RmIpFromBlocklistSvc<T: Agent>(pub Arc<T>);
769 impl<
770 T: Agent,
771 > tonic::server::UnaryService<super::RmIpFromBlocklistRequest>
772 for RmIpFromBlocklistSvc<T> {
773 type Response = super::RmIpFromBlocklistResponse;
774 type Future = BoxFuture<
775 tonic::Response<Self::Response>,
776 tonic::Status,
777 >;
778 fn call(
779 &mut self,
780 request: tonic::Request<super::RmIpFromBlocklistRequest>,
781 ) -> Self::Future {
782 let inner = Arc::clone(&self.0);
783 let fut = async move {
784 <T as Agent>::rm_ip_from_blocklist(&inner, request).await
785 };
786 Box::pin(fut)
787 }
788 }
789 let accept_compression_encodings = self.accept_compression_encodings;
790 let send_compression_encodings = self.send_compression_encodings;
791 let max_decoding_message_size = self.max_decoding_message_size;
792 let max_encoding_message_size = self.max_encoding_message_size;
793 let inner = self.inner.clone();
794 let fut = async move {
795 let method = RmIpFromBlocklistSvc(inner);
796 let codec = tonic_prost::ProstCodec::default();
797 let mut grpc = tonic::server::Grpc::new(codec)
798 .apply_compression_config(
799 accept_compression_encodings,
800 send_compression_encodings,
801 )
802 .apply_max_message_size_config(
803 max_decoding_message_size,
804 max_encoding_message_size,
805 );
806 let res = grpc.unary(method, req).await;
807 Ok(res)
808 };
809 Box::pin(fut)
810 }
811 "/agent.Agent/GetLatencyMetrics" => {
812 #[allow(non_camel_case_types)]
813 struct GetLatencyMetricsSvc<T: Agent>(pub Arc<T>);
814 impl<T: Agent> tonic::server::UnaryService<()>
815 for GetLatencyMetricsSvc<T> {
816 type Response = super::LatencyMetricsResponse;
817 type Future = BoxFuture<
818 tonic::Response<Self::Response>,
819 tonic::Status,
820 >;
821 fn call(&mut self, request: tonic::Request<()>) -> Self::Future {
822 let inner = Arc::clone(&self.0);
823 let fut = async move {
824 <T as Agent>::get_latency_metrics(&inner, request).await
825 };
826 Box::pin(fut)
827 }
828 }
829 let accept_compression_encodings = self.accept_compression_encodings;
830 let send_compression_encodings = self.send_compression_encodings;
831 let max_decoding_message_size = self.max_decoding_message_size;
832 let max_encoding_message_size = self.max_encoding_message_size;
833 let inner = self.inner.clone();
834 let fut = async move {
835 let method = GetLatencyMetricsSvc(inner);
836 let codec = tonic_prost::ProstCodec::default();
837 let mut grpc = tonic::server::Grpc::new(codec)
838 .apply_compression_config(
839 accept_compression_encodings,
840 send_compression_encodings,
841 )
842 .apply_max_message_size_config(
843 max_decoding_message_size,
844 max_encoding_message_size,
845 );
846 let res = grpc.unary(method, req).await;
847 Ok(res)
848 };
849 Box::pin(fut)
850 }
851 "/agent.Agent/GetDroppedPacketsMetrics" => {
852 #[allow(non_camel_case_types)]
853 struct GetDroppedPacketsMetricsSvc<T: Agent>(pub Arc<T>);
854 impl<T: Agent> tonic::server::UnaryService<()>
855 for GetDroppedPacketsMetricsSvc<T> {
856 type Response = super::DroppedPacketsResponse;
857 type Future = BoxFuture<
858 tonic::Response<Self::Response>,
859 tonic::Status,
860 >;
861 fn call(&mut self, request: tonic::Request<()>) -> Self::Future {
862 let inner = Arc::clone(&self.0);
863 let fut = async move {
864 <T as Agent>::get_dropped_packets_metrics(&inner, request)
865 .await
866 };
867 Box::pin(fut)
868 }
869 }
870 let accept_compression_encodings = self.accept_compression_encodings;
871 let send_compression_encodings = self.send_compression_encodings;
872 let max_decoding_message_size = self.max_decoding_message_size;
873 let max_encoding_message_size = self.max_encoding_message_size;
874 let inner = self.inner.clone();
875 let fut = async move {
876 let method = GetDroppedPacketsMetricsSvc(inner);
877 let codec = tonic_prost::ProstCodec::default();
878 let mut grpc = tonic::server::Grpc::new(codec)
879 .apply_compression_config(
880 accept_compression_encodings,
881 send_compression_encodings,
882 )
883 .apply_max_message_size_config(
884 max_decoding_message_size,
885 max_encoding_message_size,
886 );
887 let res = grpc.unary(method, req).await;
888 Ok(res)
889 };
890 Box::pin(fut)
891 }
892 "/agent.Agent/GetTrackedVeth" => {
893 #[allow(non_camel_case_types)]
894 struct GetTrackedVethSvc<T: Agent>(pub Arc<T>);
895 impl<T: Agent> tonic::server::UnaryService<()>
896 for GetTrackedVethSvc<T> {
897 type Response = super::VethResponse;
898 type Future = BoxFuture<
899 tonic::Response<Self::Response>,
900 tonic::Status,
901 >;
902 fn call(&mut self, request: tonic::Request<()>) -> Self::Future {
903 let inner = Arc::clone(&self.0);
904 let fut = async move {
905 <T as Agent>::get_tracked_veth(&inner, request).await
906 };
907 Box::pin(fut)
908 }
909 }
910 let accept_compression_encodings = self.accept_compression_encodings;
911 let send_compression_encodings = self.send_compression_encodings;
912 let max_decoding_message_size = self.max_decoding_message_size;
913 let max_encoding_message_size = self.max_encoding_message_size;
914 let inner = self.inner.clone();
915 let fut = async move {
916 let method = GetTrackedVethSvc(inner);
917 let codec = tonic_prost::ProstCodec::default();
918 let mut grpc = tonic::server::Grpc::new(codec)
919 .apply_compression_config(
920 accept_compression_encodings,
921 send_compression_encodings,
922 )
923 .apply_max_message_size_config(
924 max_decoding_message_size,
925 max_encoding_message_size,
926 );
927 let res = grpc.unary(method, req).await;
928 Ok(res)
929 };
930 Box::pin(fut)
931 }
932 "/agent.Agent/GetTrackedVethFromHashMap" => {
933 #[allow(non_camel_case_types)]
934 struct GetTrackedVethFromHashMapSvc<T: Agent>(pub Arc<T>);
935 impl<T: Agent> tonic::server::UnaryService<()>
936 for GetTrackedVethFromHashMapSvc<T> {
937 type Response = super::VethHashMapResponse;
938 type Future = BoxFuture<
939 tonic::Response<Self::Response>,
940 tonic::Status,
941 >;
942 fn call(&mut self, request: tonic::Request<()>) -> Self::Future {
943 let inner = Arc::clone(&self.0);
944 let fut = async move {
945 <T as Agent>::get_tracked_veth_from_hash_map(
946 &inner,
947 request,
948 )
949 .await
950 };
951 Box::pin(fut)
952 }
953 }
954 let accept_compression_encodings = self.accept_compression_encodings;
955 let send_compression_encodings = self.send_compression_encodings;
956 let max_decoding_message_size = self.max_decoding_message_size;
957 let max_encoding_message_size = self.max_encoding_message_size;
958 let inner = self.inner.clone();
959 let fut = async move {
960 let method = GetTrackedVethFromHashMapSvc(inner);
961 let codec = tonic_prost::ProstCodec::default();
962 let mut grpc = tonic::server::Grpc::new(codec)
963 .apply_compression_config(
964 accept_compression_encodings,
965 send_compression_encodings,
966 )
967 .apply_max_message_size_config(
968 max_decoding_message_size,
969 max_encoding_message_size,
970 );
971 let res = grpc.unary(method, req).await;
972 Ok(res)
973 };
974 Box::pin(fut)
975 }
976 _ => {
977 Box::pin(async move {
978 let mut response = http::Response::new(
979 tonic::body::Body::default(),
980 );
981 let headers = response.headers_mut();
982 headers
983 .insert(
984 tonic::Status::GRPC_STATUS,
985 (tonic::Code::Unimplemented as i32).into(),
986 );
987 headers
988 .insert(
989 http::header::CONTENT_TYPE,
990 tonic::metadata::GRPC_CONTENT_TYPE,
991 );
992 Ok(response)
993 })
994 }
995 }
996 }
997 }
998 impl<T> Clone for AgentServer<T> {
999 fn clone(&self) -> Self {
1000 let inner = self.inner.clone();
1001 Self {
1002 inner,
1003 accept_compression_encodings: self.accept_compression_encodings,
1004 send_compression_encodings: self.send_compression_encodings,
1005 max_decoding_message_size: self.max_decoding_message_size,
1006 max_encoding_message_size: self.max_encoding_message_size,
1007 }
1008 }
1009 }
1010 pub const SERVICE_NAME: &str = "agent.Agent";
1012 impl<T> tonic::server::NamedService for AgentServer<T> {
1013 const NAME: &'static str = SERVICE_NAME;
1014 }
1015}