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