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