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