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