1#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct HeartbeatRequest {
4 #[prost(string, tag = "1")]
5 pub app_id: ::prost::alloc::string::String,
6 #[prost(string, tag = "2")]
7 pub app_secret: ::prost::alloc::string::String,
8 #[prost(string, tag = "3")]
9 pub device_version: ::prost::alloc::string::String,
10 #[prost(string, tag = "4")]
11 pub device_uuid: ::prost::alloc::string::String,
12}
13#[derive(Clone, PartialEq, ::prost::Message)]
14pub struct HeartbeatResponse {
15 #[prost(string, tag = "1")]
16 pub token: ::prost::alloc::string::String,
17 #[prost(enumeration = "DeviceStatus", tag = "2")]
18 pub status: i32,
19 #[prost(bool, tag = "3")]
20 pub remote_shell_enabled: bool,
21 #[prost(bool, tag = "4")]
22 pub remote_ui_enabled: bool,
23 #[prost(bool, tag = "5")]
24 pub remote_ssh_enabled: bool,
25 #[prost(bool, tag = "6")]
27 pub is_monitoring_enabled: bool,
28 #[prost(bool, tag = "7")]
29 pub is_packet_capture_enabled: bool,
30 #[prost(bool, tag = "8")]
31 pub is_resource_monitoring_enabled: bool,
32}
33#[derive(Clone, PartialEq, ::prost::Message)]
34pub struct CommonResponse {
35 #[prost(string, tag = "1")]
36 pub message: ::prost::alloc::string::String,
37}
38#[derive(serde::Serialize, serde::Deserialize)]
39#[derive(Clone, PartialEq, ::prost::Message)]
40pub struct Packets {
41 #[prost(string, tag = "1")]
42 pub token: ::prost::alloc::string::String,
43 #[prost(string, tag = "2")]
44 pub uuid: ::prost::alloc::string::String,
45 #[prost(message, repeated, tag = "3")]
46 pub packets: ::prost::alloc::vec::Vec<Packet>,
47}
48#[derive(serde::Serialize, serde::Deserialize)]
49#[derive(Clone, PartialEq, ::prost::Message)]
50pub struct Packet {
51 #[prost(string, tag = "1")]
52 pub timestamp: ::prost::alloc::string::String,
53 #[prost(string, tag = "2")]
54 pub interface: ::prost::alloc::string::String,
55 #[prost(int32, tag = "3")]
56 pub link_type: i32,
57 #[prost(bytes = "vec", tag = "4")]
58 pub data: ::prost::alloc::vec::Vec<u8>,
59}
60#[derive(Clone, PartialEq, ::prost::Message)]
61pub struct FileSnapshot {
62 #[prost(string, tag = "1")]
63 pub filename: ::prost::alloc::string::String,
64 #[prost(bytes = "vec", tag = "2")]
65 pub contents: ::prost::alloc::vec::Vec<u8>,
66}
67#[derive(Clone, PartialEq, ::prost::Message)]
68pub struct ConfigSnapshot {
69 #[prost(string, tag = "1")]
70 pub token: ::prost::alloc::string::String,
71 #[prost(message, repeated, tag = "2")]
72 pub files: ::prost::alloc::vec::Vec<FileSnapshot>,
73 #[prost(enumeration = "ConfigStatus", tag = "3")]
74 pub status: i32,
75}
76#[derive(Clone, PartialEq, ::prost::Message)]
77pub struct Logs {
78 #[prost(string, tag = "1")]
79 pub token: ::prost::alloc::string::String,
80 #[prost(message, repeated, tag = "3")]
81 pub logs: ::prost::alloc::vec::Vec<Log>,
82}
83#[derive(serde::Serialize, serde::Deserialize)]
84#[derive(Clone, PartialEq, ::prost::Message)]
85pub struct Log {
86 #[prost(string, tag = "1")]
87 pub timestamp: ::prost::alloc::string::String,
88 #[prost(string, tag = "2")]
89 pub level: ::prost::alloc::string::String,
90 #[prost(string, tag = "3")]
91 pub message: ::prost::alloc::string::String,
92}
93#[derive(serde::Serialize, serde::Deserialize)]
94#[derive(Clone, PartialEq, ::prost::Message)]
95pub struct SystemResources {
96 #[prost(string, tag = "1")]
97 pub token: ::prost::alloc::string::String,
98 #[prost(message, repeated, tag = "2")]
99 pub resources: ::prost::alloc::vec::Vec<SystemResource>,
100}
101#[derive(serde::Serialize, serde::Deserialize)]
102#[derive(Clone, PartialEq, ::prost::Message)]
103pub struct SystemResource {
104 #[prost(string, tag = "1")]
105 pub timestamp: ::prost::alloc::string::String,
106 #[prost(int64, tag = "2")]
107 pub num_cpus: i64,
108 #[prost(float, tag = "3")]
109 pub global_cpu_usage: f32,
110 #[prost(string, tag = "4")]
112 pub cpu_usages: ::prost::alloc::string::String,
113 #[prost(int64, tag = "5")]
114 pub total_memory: i64,
115 #[prost(int64, tag = "6")]
116 pub used_memory: i64,
117 #[prost(int64, tag = "7")]
118 pub total_disk_space: i64,
119 #[prost(int64, tag = "8")]
120 pub available_disk_space: i64,
121 #[prost(int64, tag = "9")]
122 pub read_bytes: i64,
123 #[prost(int64, tag = "10")]
124 pub written_bytes: i64,
125 #[prost(string, tag = "11")]
127 pub temperatures: ::prost::alloc::string::String,
128}
129#[derive(Clone, PartialEq, ::prost::Message)]
130pub struct ControlChannelRequest {
131 #[prost(string, tag = "1")]
132 pub token: ::prost::alloc::string::String,
133 #[prost(string, tag = "2")]
134 pub session_type: ::prost::alloc::string::String,
135}
136#[derive(Clone, PartialEq, ::prost::Message)]
138pub struct ControlChannelResponse {
139 #[prost(string, tag = "1")]
140 pub id: ::prost::alloc::string::String,
141 #[prost(string, tag = "2")]
142 pub r#type: ::prost::alloc::string::String,
143 #[prost(string, optional, tag = "3")]
144 pub protocol: ::core::option::Option<::prost::alloc::string::String>,
145 #[prost(string, optional, tag = "4")]
146 pub ssh_key: ::core::option::Option<::prost::alloc::string::String>,
147 #[prost(int32, optional, tag = "5")]
148 pub ssh_port: ::core::option::Option<i32>,
149}
150#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
151#[repr(i32)]
152pub enum DeviceStatus {
153 DsDraft = 0,
154 DsActive = 1,
155 DsArchived = 2,
156 DsDeleted = 3,
157 DsUnknown = 4,
158}
159impl DeviceStatus {
160 pub fn as_str_name(&self) -> &'static str {
165 match self {
166 Self::DsDraft => "DS_DRAFT",
167 Self::DsActive => "DS_ACTIVE",
168 Self::DsArchived => "DS_ARCHIVED",
169 Self::DsDeleted => "DS_DELETED",
170 Self::DsUnknown => "DS_UNKNOWN",
171 }
172 }
173 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
175 match value {
176 "DS_DRAFT" => Some(Self::DsDraft),
177 "DS_ACTIVE" => Some(Self::DsActive),
178 "DS_ARCHIVED" => Some(Self::DsArchived),
179 "DS_DELETED" => Some(Self::DsDeleted),
180 "DS_UNKNOWN" => Some(Self::DsUnknown),
181 _ => None,
182 }
183 }
184}
185#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
186#[repr(i32)]
187pub enum ConfigStatus {
188 CsDraft = 0,
189 CsApplied = 1,
190 CsUndefined = 2,
191}
192impl ConfigStatus {
193 pub fn as_str_name(&self) -> &'static str {
198 match self {
199 Self::CsDraft => "CS_DRAFT",
200 Self::CsApplied => "CS_APPLIED",
201 Self::CsUndefined => "CS_UNDEFINED",
202 }
203 }
204 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
206 match value {
207 "CS_DRAFT" => Some(Self::CsDraft),
208 "CS_APPLIED" => Some(Self::CsApplied),
209 "CS_UNDEFINED" => Some(Self::CsUndefined),
210 _ => None,
211 }
212 }
213}
214pub mod wall_guard_client {
216 #![allow(
217 unused_variables,
218 dead_code,
219 missing_docs,
220 clippy::wildcard_imports,
221 clippy::let_unit_value,
222 )]
223 use tonic::codegen::*;
224 use tonic::codegen::http::Uri;
225 #[derive(Debug, Clone)]
226 pub struct WallGuardClient<T> {
227 inner: tonic::client::Grpc<T>,
228 }
229 impl WallGuardClient<tonic::transport::Channel> {
230 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
232 where
233 D: TryInto<tonic::transport::Endpoint>,
234 D::Error: Into<StdError>,
235 {
236 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
237 Ok(Self::new(conn))
238 }
239 }
240 impl<T> WallGuardClient<T>
241 where
242 T: tonic::client::GrpcService<tonic::body::Body>,
243 T::Error: Into<StdError>,
244 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
245 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
246 {
247 pub fn new(inner: T) -> Self {
248 let inner = tonic::client::Grpc::new(inner);
249 Self { inner }
250 }
251 pub fn with_origin(inner: T, origin: Uri) -> Self {
252 let inner = tonic::client::Grpc::with_origin(inner, origin);
253 Self { inner }
254 }
255 pub fn with_interceptor<F>(
256 inner: T,
257 interceptor: F,
258 ) -> WallGuardClient<InterceptedService<T, F>>
259 where
260 F: tonic::service::Interceptor,
261 T::ResponseBody: Default,
262 T: tonic::codegen::Service<
263 http::Request<tonic::body::Body>,
264 Response = http::Response<
265 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
266 >,
267 >,
268 <T as tonic::codegen::Service<
269 http::Request<tonic::body::Body>,
270 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
271 {
272 WallGuardClient::new(InterceptedService::new(inner, interceptor))
273 }
274 #[must_use]
279 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
280 self.inner = self.inner.send_compressed(encoding);
281 self
282 }
283 #[must_use]
285 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
286 self.inner = self.inner.accept_compressed(encoding);
287 self
288 }
289 #[must_use]
293 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
294 self.inner = self.inner.max_decoding_message_size(limit);
295 self
296 }
297 #[must_use]
301 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
302 self.inner = self.inner.max_encoding_message_size(limit);
303 self
304 }
305 pub async fn heartbeat(
306 &mut self,
307 request: impl tonic::IntoRequest<super::HeartbeatRequest>,
308 ) -> std::result::Result<
309 tonic::Response<tonic::codec::Streaming<super::HeartbeatResponse>>,
310 tonic::Status,
311 > {
312 self.inner
313 .ready()
314 .await
315 .map_err(|e| {
316 tonic::Status::unknown(
317 format!("Service was not ready: {}", e.into()),
318 )
319 })?;
320 let codec = tonic::codec::ProstCodec::default();
321 let path = http::uri::PathAndQuery::from_static(
322 "/wallguard.WallGuard/Heartbeat",
323 );
324 let mut req = request.into_request();
325 req.extensions_mut()
326 .insert(GrpcMethod::new("wallguard.WallGuard", "Heartbeat"));
327 self.inner.server_streaming(req, path, codec).await
328 }
329 pub async fn handle_packets(
330 &mut self,
331 request: impl tonic::IntoRequest<super::Packets>,
332 ) -> std::result::Result<tonic::Response<super::CommonResponse>, tonic::Status> {
333 self.inner
334 .ready()
335 .await
336 .map_err(|e| {
337 tonic::Status::unknown(
338 format!("Service was not ready: {}", e.into()),
339 )
340 })?;
341 let codec = tonic::codec::ProstCodec::default();
342 let path = http::uri::PathAndQuery::from_static(
343 "/wallguard.WallGuard/HandlePackets",
344 );
345 let mut req = request.into_request();
346 req.extensions_mut()
347 .insert(GrpcMethod::new("wallguard.WallGuard", "HandlePackets"));
348 self.inner.unary(req, path, codec).await
349 }
350 pub async fn handle_config(
351 &mut self,
352 request: impl tonic::IntoRequest<super::ConfigSnapshot>,
353 ) -> std::result::Result<tonic::Response<super::CommonResponse>, tonic::Status> {
354 self.inner
355 .ready()
356 .await
357 .map_err(|e| {
358 tonic::Status::unknown(
359 format!("Service was not ready: {}", e.into()),
360 )
361 })?;
362 let codec = tonic::codec::ProstCodec::default();
363 let path = http::uri::PathAndQuery::from_static(
364 "/wallguard.WallGuard/HandleConfig",
365 );
366 let mut req = request.into_request();
367 req.extensions_mut()
368 .insert(GrpcMethod::new("wallguard.WallGuard", "HandleConfig"));
369 self.inner.unary(req, path, codec).await
370 }
371 pub async fn handle_logs(
372 &mut self,
373 request: impl tonic::IntoRequest<super::Logs>,
374 ) -> std::result::Result<tonic::Response<super::CommonResponse>, tonic::Status> {
375 self.inner
376 .ready()
377 .await
378 .map_err(|e| {
379 tonic::Status::unknown(
380 format!("Service was not ready: {}", e.into()),
381 )
382 })?;
383 let codec = tonic::codec::ProstCodec::default();
384 let path = http::uri::PathAndQuery::from_static(
385 "/wallguard.WallGuard/HandleLogs",
386 );
387 let mut req = request.into_request();
388 req.extensions_mut()
389 .insert(GrpcMethod::new("wallguard.WallGuard", "HandleLogs"));
390 self.inner.unary(req, path, codec).await
391 }
392 pub async fn handle_system_resources(
393 &mut self,
394 request: impl tonic::IntoRequest<super::SystemResources>,
395 ) -> std::result::Result<tonic::Response<super::CommonResponse>, tonic::Status> {
396 self.inner
397 .ready()
398 .await
399 .map_err(|e| {
400 tonic::Status::unknown(
401 format!("Service was not ready: {}", e.into()),
402 )
403 })?;
404 let codec = tonic::codec::ProstCodec::default();
405 let path = http::uri::PathAndQuery::from_static(
406 "/wallguard.WallGuard/HandleSystemResources",
407 );
408 let mut req = request.into_request();
409 req.extensions_mut()
410 .insert(GrpcMethod::new("wallguard.WallGuard", "HandleSystemResources"));
411 self.inner.unary(req, path, codec).await
412 }
413 pub async fn request_control_channel(
414 &mut self,
415 request: impl tonic::IntoRequest<super::ControlChannelRequest>,
416 ) -> std::result::Result<
417 tonic::Response<super::ControlChannelResponse>,
418 tonic::Status,
419 > {
420 self.inner
421 .ready()
422 .await
423 .map_err(|e| {
424 tonic::Status::unknown(
425 format!("Service was not ready: {}", e.into()),
426 )
427 })?;
428 let codec = tonic::codec::ProstCodec::default();
429 let path = http::uri::PathAndQuery::from_static(
430 "/wallguard.WallGuard/RequestControlChannel",
431 );
432 let mut req = request.into_request();
433 req.extensions_mut()
434 .insert(GrpcMethod::new("wallguard.WallGuard", "RequestControlChannel"));
435 self.inner.unary(req, path, codec).await
436 }
437 }
438}
439pub mod wall_guard_server {
441 #![allow(
442 unused_variables,
443 dead_code,
444 missing_docs,
445 clippy::wildcard_imports,
446 clippy::let_unit_value,
447 )]
448 use tonic::codegen::*;
449 #[async_trait]
451 pub trait WallGuard: std::marker::Send + std::marker::Sync + 'static {
452 type HeartbeatStream: tonic::codegen::tokio_stream::Stream<
454 Item = std::result::Result<super::HeartbeatResponse, tonic::Status>,
455 >
456 + std::marker::Send
457 + 'static;
458 async fn heartbeat(
459 &self,
460 request: tonic::Request<super::HeartbeatRequest>,
461 ) -> std::result::Result<tonic::Response<Self::HeartbeatStream>, tonic::Status>;
462 async fn handle_packets(
463 &self,
464 request: tonic::Request<super::Packets>,
465 ) -> std::result::Result<tonic::Response<super::CommonResponse>, tonic::Status>;
466 async fn handle_config(
467 &self,
468 request: tonic::Request<super::ConfigSnapshot>,
469 ) -> std::result::Result<tonic::Response<super::CommonResponse>, tonic::Status>;
470 async fn handle_logs(
471 &self,
472 request: tonic::Request<super::Logs>,
473 ) -> std::result::Result<tonic::Response<super::CommonResponse>, tonic::Status>;
474 async fn handle_system_resources(
475 &self,
476 request: tonic::Request<super::SystemResources>,
477 ) -> std::result::Result<tonic::Response<super::CommonResponse>, tonic::Status>;
478 async fn request_control_channel(
479 &self,
480 request: tonic::Request<super::ControlChannelRequest>,
481 ) -> std::result::Result<
482 tonic::Response<super::ControlChannelResponse>,
483 tonic::Status,
484 >;
485 }
486 #[derive(Debug)]
487 pub struct WallGuardServer<T> {
488 inner: Arc<T>,
489 accept_compression_encodings: EnabledCompressionEncodings,
490 send_compression_encodings: EnabledCompressionEncodings,
491 max_decoding_message_size: Option<usize>,
492 max_encoding_message_size: Option<usize>,
493 }
494 impl<T> WallGuardServer<T> {
495 pub fn new(inner: T) -> Self {
496 Self::from_arc(Arc::new(inner))
497 }
498 pub fn from_arc(inner: Arc<T>) -> Self {
499 Self {
500 inner,
501 accept_compression_encodings: Default::default(),
502 send_compression_encodings: Default::default(),
503 max_decoding_message_size: None,
504 max_encoding_message_size: None,
505 }
506 }
507 pub fn with_interceptor<F>(
508 inner: T,
509 interceptor: F,
510 ) -> InterceptedService<Self, F>
511 where
512 F: tonic::service::Interceptor,
513 {
514 InterceptedService::new(Self::new(inner), interceptor)
515 }
516 #[must_use]
518 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
519 self.accept_compression_encodings.enable(encoding);
520 self
521 }
522 #[must_use]
524 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
525 self.send_compression_encodings.enable(encoding);
526 self
527 }
528 #[must_use]
532 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
533 self.max_decoding_message_size = Some(limit);
534 self
535 }
536 #[must_use]
540 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
541 self.max_encoding_message_size = Some(limit);
542 self
543 }
544 }
545 impl<T, B> tonic::codegen::Service<http::Request<B>> for WallGuardServer<T>
546 where
547 T: WallGuard,
548 B: Body + std::marker::Send + 'static,
549 B::Error: Into<StdError> + std::marker::Send + 'static,
550 {
551 type Response = http::Response<tonic::body::Body>;
552 type Error = std::convert::Infallible;
553 type Future = BoxFuture<Self::Response, Self::Error>;
554 fn poll_ready(
555 &mut self,
556 _cx: &mut Context<'_>,
557 ) -> Poll<std::result::Result<(), Self::Error>> {
558 Poll::Ready(Ok(()))
559 }
560 fn call(&mut self, req: http::Request<B>) -> Self::Future {
561 match req.uri().path() {
562 "/wallguard.WallGuard/Heartbeat" => {
563 #[allow(non_camel_case_types)]
564 struct HeartbeatSvc<T: WallGuard>(pub Arc<T>);
565 impl<
566 T: WallGuard,
567 > tonic::server::ServerStreamingService<super::HeartbeatRequest>
568 for HeartbeatSvc<T> {
569 type Response = super::HeartbeatResponse;
570 type ResponseStream = T::HeartbeatStream;
571 type Future = BoxFuture<
572 tonic::Response<Self::ResponseStream>,
573 tonic::Status,
574 >;
575 fn call(
576 &mut self,
577 request: tonic::Request<super::HeartbeatRequest>,
578 ) -> Self::Future {
579 let inner = Arc::clone(&self.0);
580 let fut = async move {
581 <T as WallGuard>::heartbeat(&inner, request).await
582 };
583 Box::pin(fut)
584 }
585 }
586 let accept_compression_encodings = self.accept_compression_encodings;
587 let send_compression_encodings = self.send_compression_encodings;
588 let max_decoding_message_size = self.max_decoding_message_size;
589 let max_encoding_message_size = self.max_encoding_message_size;
590 let inner = self.inner.clone();
591 let fut = async move {
592 let method = HeartbeatSvc(inner);
593 let codec = tonic::codec::ProstCodec::default();
594 let mut grpc = tonic::server::Grpc::new(codec)
595 .apply_compression_config(
596 accept_compression_encodings,
597 send_compression_encodings,
598 )
599 .apply_max_message_size_config(
600 max_decoding_message_size,
601 max_encoding_message_size,
602 );
603 let res = grpc.server_streaming(method, req).await;
604 Ok(res)
605 };
606 Box::pin(fut)
607 }
608 "/wallguard.WallGuard/HandlePackets" => {
609 #[allow(non_camel_case_types)]
610 struct HandlePacketsSvc<T: WallGuard>(pub Arc<T>);
611 impl<T: WallGuard> tonic::server::UnaryService<super::Packets>
612 for HandlePacketsSvc<T> {
613 type Response = super::CommonResponse;
614 type Future = BoxFuture<
615 tonic::Response<Self::Response>,
616 tonic::Status,
617 >;
618 fn call(
619 &mut self,
620 request: tonic::Request<super::Packets>,
621 ) -> Self::Future {
622 let inner = Arc::clone(&self.0);
623 let fut = async move {
624 <T as WallGuard>::handle_packets(&inner, request).await
625 };
626 Box::pin(fut)
627 }
628 }
629 let accept_compression_encodings = self.accept_compression_encodings;
630 let send_compression_encodings = self.send_compression_encodings;
631 let max_decoding_message_size = self.max_decoding_message_size;
632 let max_encoding_message_size = self.max_encoding_message_size;
633 let inner = self.inner.clone();
634 let fut = async move {
635 let method = HandlePacketsSvc(inner);
636 let codec = tonic::codec::ProstCodec::default();
637 let mut grpc = tonic::server::Grpc::new(codec)
638 .apply_compression_config(
639 accept_compression_encodings,
640 send_compression_encodings,
641 )
642 .apply_max_message_size_config(
643 max_decoding_message_size,
644 max_encoding_message_size,
645 );
646 let res = grpc.unary(method, req).await;
647 Ok(res)
648 };
649 Box::pin(fut)
650 }
651 "/wallguard.WallGuard/HandleConfig" => {
652 #[allow(non_camel_case_types)]
653 struct HandleConfigSvc<T: WallGuard>(pub Arc<T>);
654 impl<T: WallGuard> tonic::server::UnaryService<super::ConfigSnapshot>
655 for HandleConfigSvc<T> {
656 type Response = super::CommonResponse;
657 type Future = BoxFuture<
658 tonic::Response<Self::Response>,
659 tonic::Status,
660 >;
661 fn call(
662 &mut self,
663 request: tonic::Request<super::ConfigSnapshot>,
664 ) -> Self::Future {
665 let inner = Arc::clone(&self.0);
666 let fut = async move {
667 <T as WallGuard>::handle_config(&inner, request).await
668 };
669 Box::pin(fut)
670 }
671 }
672 let accept_compression_encodings = self.accept_compression_encodings;
673 let send_compression_encodings = self.send_compression_encodings;
674 let max_decoding_message_size = self.max_decoding_message_size;
675 let max_encoding_message_size = self.max_encoding_message_size;
676 let inner = self.inner.clone();
677 let fut = async move {
678 let method = HandleConfigSvc(inner);
679 let codec = tonic::codec::ProstCodec::default();
680 let mut grpc = tonic::server::Grpc::new(codec)
681 .apply_compression_config(
682 accept_compression_encodings,
683 send_compression_encodings,
684 )
685 .apply_max_message_size_config(
686 max_decoding_message_size,
687 max_encoding_message_size,
688 );
689 let res = grpc.unary(method, req).await;
690 Ok(res)
691 };
692 Box::pin(fut)
693 }
694 "/wallguard.WallGuard/HandleLogs" => {
695 #[allow(non_camel_case_types)]
696 struct HandleLogsSvc<T: WallGuard>(pub Arc<T>);
697 impl<T: WallGuard> tonic::server::UnaryService<super::Logs>
698 for HandleLogsSvc<T> {
699 type Response = super::CommonResponse;
700 type Future = BoxFuture<
701 tonic::Response<Self::Response>,
702 tonic::Status,
703 >;
704 fn call(
705 &mut self,
706 request: tonic::Request<super::Logs>,
707 ) -> Self::Future {
708 let inner = Arc::clone(&self.0);
709 let fut = async move {
710 <T as WallGuard>::handle_logs(&inner, request).await
711 };
712 Box::pin(fut)
713 }
714 }
715 let accept_compression_encodings = self.accept_compression_encodings;
716 let send_compression_encodings = self.send_compression_encodings;
717 let max_decoding_message_size = self.max_decoding_message_size;
718 let max_encoding_message_size = self.max_encoding_message_size;
719 let inner = self.inner.clone();
720 let fut = async move {
721 let method = HandleLogsSvc(inner);
722 let codec = tonic::codec::ProstCodec::default();
723 let mut grpc = tonic::server::Grpc::new(codec)
724 .apply_compression_config(
725 accept_compression_encodings,
726 send_compression_encodings,
727 )
728 .apply_max_message_size_config(
729 max_decoding_message_size,
730 max_encoding_message_size,
731 );
732 let res = grpc.unary(method, req).await;
733 Ok(res)
734 };
735 Box::pin(fut)
736 }
737 "/wallguard.WallGuard/HandleSystemResources" => {
738 #[allow(non_camel_case_types)]
739 struct HandleSystemResourcesSvc<T: WallGuard>(pub Arc<T>);
740 impl<
741 T: WallGuard,
742 > tonic::server::UnaryService<super::SystemResources>
743 for HandleSystemResourcesSvc<T> {
744 type Response = super::CommonResponse;
745 type Future = BoxFuture<
746 tonic::Response<Self::Response>,
747 tonic::Status,
748 >;
749 fn call(
750 &mut self,
751 request: tonic::Request<super::SystemResources>,
752 ) -> Self::Future {
753 let inner = Arc::clone(&self.0);
754 let fut = async move {
755 <T as WallGuard>::handle_system_resources(&inner, request)
756 .await
757 };
758 Box::pin(fut)
759 }
760 }
761 let accept_compression_encodings = self.accept_compression_encodings;
762 let send_compression_encodings = self.send_compression_encodings;
763 let max_decoding_message_size = self.max_decoding_message_size;
764 let max_encoding_message_size = self.max_encoding_message_size;
765 let inner = self.inner.clone();
766 let fut = async move {
767 let method = HandleSystemResourcesSvc(inner);
768 let codec = tonic::codec::ProstCodec::default();
769 let mut grpc = tonic::server::Grpc::new(codec)
770 .apply_compression_config(
771 accept_compression_encodings,
772 send_compression_encodings,
773 )
774 .apply_max_message_size_config(
775 max_decoding_message_size,
776 max_encoding_message_size,
777 );
778 let res = grpc.unary(method, req).await;
779 Ok(res)
780 };
781 Box::pin(fut)
782 }
783 "/wallguard.WallGuard/RequestControlChannel" => {
784 #[allow(non_camel_case_types)]
785 struct RequestControlChannelSvc<T: WallGuard>(pub Arc<T>);
786 impl<
787 T: WallGuard,
788 > tonic::server::UnaryService<super::ControlChannelRequest>
789 for RequestControlChannelSvc<T> {
790 type Response = super::ControlChannelResponse;
791 type Future = BoxFuture<
792 tonic::Response<Self::Response>,
793 tonic::Status,
794 >;
795 fn call(
796 &mut self,
797 request: tonic::Request<super::ControlChannelRequest>,
798 ) -> Self::Future {
799 let inner = Arc::clone(&self.0);
800 let fut = async move {
801 <T as WallGuard>::request_control_channel(&inner, request)
802 .await
803 };
804 Box::pin(fut)
805 }
806 }
807 let accept_compression_encodings = self.accept_compression_encodings;
808 let send_compression_encodings = self.send_compression_encodings;
809 let max_decoding_message_size = self.max_decoding_message_size;
810 let max_encoding_message_size = self.max_encoding_message_size;
811 let inner = self.inner.clone();
812 let fut = async move {
813 let method = RequestControlChannelSvc(inner);
814 let codec = tonic::codec::ProstCodec::default();
815 let mut grpc = tonic::server::Grpc::new(codec)
816 .apply_compression_config(
817 accept_compression_encodings,
818 send_compression_encodings,
819 )
820 .apply_max_message_size_config(
821 max_decoding_message_size,
822 max_encoding_message_size,
823 );
824 let res = grpc.unary(method, req).await;
825 Ok(res)
826 };
827 Box::pin(fut)
828 }
829 _ => {
830 Box::pin(async move {
831 let mut response = http::Response::new(
832 tonic::body::Body::default(),
833 );
834 let headers = response.headers_mut();
835 headers
836 .insert(
837 tonic::Status::GRPC_STATUS,
838 (tonic::Code::Unimplemented as i32).into(),
839 );
840 headers
841 .insert(
842 http::header::CONTENT_TYPE,
843 tonic::metadata::GRPC_CONTENT_TYPE,
844 );
845 Ok(response)
846 })
847 }
848 }
849 }
850 }
851 impl<T> Clone for WallGuardServer<T> {
852 fn clone(&self) -> Self {
853 let inner = self.inner.clone();
854 Self {
855 inner,
856 accept_compression_encodings: self.accept_compression_encodings,
857 send_compression_encodings: self.send_compression_encodings,
858 max_decoding_message_size: self.max_decoding_message_size,
859 max_encoding_message_size: self.max_encoding_message_size,
860 }
861 }
862 }
863 pub const SERVICE_NAME: &str = "wallguard.WallGuard";
865 impl<T> tonic::server::NamedService for WallGuardServer<T> {
866 const NAME: &'static str = SERVICE_NAME;
867 }
868}