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