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, PartialEq, ::prost::Message)]
109pub struct ControlChannelRequest {
110 #[prost(message, optional, tag = "1")]
111 pub auth: ::core::option::Option<Authentication>,
112}
113#[derive(Clone, PartialEq, ::prost::Message)]
114pub struct ControlChannelResponse {
115 #[prost(string, tag = "1")]
116 pub id: ::prost::alloc::string::String,
117 #[prost(string, tag = "2")]
118 pub r#type: ::prost::alloc::string::String,
119 #[prost(string, optional, tag = "3")]
120 pub protocol: ::core::option::Option<::prost::alloc::string::String>,
121}
122#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
123#[repr(i32)]
124pub enum DeviceStatus {
125 DsDraft = 0,
126 DsActive = 1,
127 DsArchived = 2,
128 DsDeleted = 3,
129 DsUnknown = 4,
130}
131impl DeviceStatus {
132 pub fn as_str_name(&self) -> &'static str {
137 match self {
138 Self::DsDraft => "DS_DRAFT",
139 Self::DsActive => "DS_ACTIVE",
140 Self::DsArchived => "DS_ARCHIVED",
141 Self::DsDeleted => "DS_DELETED",
142 Self::DsUnknown => "DS_UNKNOWN",
143 }
144 }
145 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
147 match value {
148 "DS_DRAFT" => Some(Self::DsDraft),
149 "DS_ACTIVE" => Some(Self::DsActive),
150 "DS_ARCHIVED" => Some(Self::DsArchived),
151 "DS_DELETED" => Some(Self::DsDeleted),
152 "DS_UNKNOWN" => Some(Self::DsUnknown),
153 _ => None,
154 }
155 }
156}
157#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
158#[repr(i32)]
159pub enum ConfigStatus {
160 CsDraft = 0,
161 CsApplied = 1,
162 CsUndefined = 2,
163}
164impl ConfigStatus {
165 pub fn as_str_name(&self) -> &'static str {
170 match self {
171 Self::CsDraft => "CS_DRAFT",
172 Self::CsApplied => "CS_APPLIED",
173 Self::CsUndefined => "CS_UNDEFINED",
174 }
175 }
176 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
178 match value {
179 "CS_DRAFT" => Some(Self::CsDraft),
180 "CS_APPLIED" => Some(Self::CsApplied),
181 "CS_UNDEFINED" => Some(Self::CsUndefined),
182 _ => None,
183 }
184 }
185}
186pub mod wall_guard_client {
188 #![allow(
189 unused_variables,
190 dead_code,
191 missing_docs,
192 clippy::wildcard_imports,
193 clippy::let_unit_value,
194 )]
195 use tonic::codegen::*;
196 use tonic::codegen::http::Uri;
197 #[derive(Debug, Clone)]
198 pub struct WallGuardClient<T> {
199 inner: tonic::client::Grpc<T>,
200 }
201 impl WallGuardClient<tonic::transport::Channel> {
202 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
204 where
205 D: TryInto<tonic::transport::Endpoint>,
206 D::Error: Into<StdError>,
207 {
208 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
209 Ok(Self::new(conn))
210 }
211 }
212 impl<T> WallGuardClient<T>
213 where
214 T: tonic::client::GrpcService<tonic::body::BoxBody>,
215 T::Error: Into<StdError>,
216 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
217 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
218 {
219 pub fn new(inner: T) -> Self {
220 let inner = tonic::client::Grpc::new(inner);
221 Self { inner }
222 }
223 pub fn with_origin(inner: T, origin: Uri) -> Self {
224 let inner = tonic::client::Grpc::with_origin(inner, origin);
225 Self { inner }
226 }
227 pub fn with_interceptor<F>(
228 inner: T,
229 interceptor: F,
230 ) -> WallGuardClient<InterceptedService<T, F>>
231 where
232 F: tonic::service::Interceptor,
233 T::ResponseBody: Default,
234 T: tonic::codegen::Service<
235 http::Request<tonic::body::BoxBody>,
236 Response = http::Response<
237 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
238 >,
239 >,
240 <T as tonic::codegen::Service<
241 http::Request<tonic::body::BoxBody>,
242 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
243 {
244 WallGuardClient::new(InterceptedService::new(inner, interceptor))
245 }
246 #[must_use]
251 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
252 self.inner = self.inner.send_compressed(encoding);
253 self
254 }
255 #[must_use]
257 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
258 self.inner = self.inner.accept_compressed(encoding);
259 self
260 }
261 #[must_use]
265 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
266 self.inner = self.inner.max_decoding_message_size(limit);
267 self
268 }
269 #[must_use]
273 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
274 self.inner = self.inner.max_encoding_message_size(limit);
275 self
276 }
277 pub async fn login(
278 &mut self,
279 request: impl tonic::IntoRequest<super::LoginRequest>,
280 ) -> std::result::Result<tonic::Response<super::Authentication>, tonic::Status> {
281 self.inner
282 .ready()
283 .await
284 .map_err(|e| {
285 tonic::Status::unknown(
286 format!("Service was not ready: {}", e.into()),
287 )
288 })?;
289 let codec = tonic::codec::ProstCodec::default();
290 let path = http::uri::PathAndQuery::from_static(
291 "/wallguard.WallGuard/Login",
292 );
293 let mut req = request.into_request();
294 req.extensions_mut().insert(GrpcMethod::new("wallguard.WallGuard", "Login"));
295 self.inner.unary(req, path, codec).await
296 }
297 pub async fn status(
298 &mut self,
299 request: impl tonic::IntoRequest<super::StatusRequest>,
300 ) -> std::result::Result<tonic::Response<super::StatusResponse>, tonic::Status> {
301 self.inner
302 .ready()
303 .await
304 .map_err(|e| {
305 tonic::Status::unknown(
306 format!("Service was not ready: {}", e.into()),
307 )
308 })?;
309 let codec = tonic::codec::ProstCodec::default();
310 let path = http::uri::PathAndQuery::from_static(
311 "/wallguard.WallGuard/Status",
312 );
313 let mut req = request.into_request();
314 req.extensions_mut()
315 .insert(GrpcMethod::new("wallguard.WallGuard", "Status"));
316 self.inner.unary(req, path, codec).await
317 }
318 pub async fn setup(
319 &mut self,
320 request: impl tonic::IntoRequest<super::SetupRequest>,
321 ) -> std::result::Result<tonic::Response<super::CommonResponse>, tonic::Status> {
322 self.inner
323 .ready()
324 .await
325 .map_err(|e| {
326 tonic::Status::unknown(
327 format!("Service was not ready: {}", e.into()),
328 )
329 })?;
330 let codec = tonic::codec::ProstCodec::default();
331 let path = http::uri::PathAndQuery::from_static(
332 "/wallguard.WallGuard/Setup",
333 );
334 let mut req = request.into_request();
335 req.extensions_mut().insert(GrpcMethod::new("wallguard.WallGuard", "Setup"));
336 self.inner.unary(req, path, codec).await
337 }
338 pub async fn heartbeat(
339 &mut self,
340 request: impl tonic::IntoRequest<super::HeartbeatRequest>,
341 ) -> std::result::Result<
342 tonic::Response<super::HeartbeatResponse>,
343 tonic::Status,
344 > {
345 self.inner
346 .ready()
347 .await
348 .map_err(|e| {
349 tonic::Status::unknown(
350 format!("Service was not ready: {}", e.into()),
351 )
352 })?;
353 let codec = tonic::codec::ProstCodec::default();
354 let path = http::uri::PathAndQuery::from_static(
355 "/wallguard.WallGuard/Heartbeat",
356 );
357 let mut req = request.into_request();
358 req.extensions_mut()
359 .insert(GrpcMethod::new("wallguard.WallGuard", "Heartbeat"));
360 self.inner.unary(req, path, codec).await
361 }
362 pub async fn handle_packets(
363 &mut self,
364 request: impl tonic::IntoRequest<super::Packets>,
365 ) -> std::result::Result<tonic::Response<super::CommonResponse>, tonic::Status> {
366 self.inner
367 .ready()
368 .await
369 .map_err(|e| {
370 tonic::Status::unknown(
371 format!("Service was not ready: {}", e.into()),
372 )
373 })?;
374 let codec = tonic::codec::ProstCodec::default();
375 let path = http::uri::PathAndQuery::from_static(
376 "/wallguard.WallGuard/HandlePackets",
377 );
378 let mut req = request.into_request();
379 req.extensions_mut()
380 .insert(GrpcMethod::new("wallguard.WallGuard", "HandlePackets"));
381 self.inner.unary(req, path, codec).await
382 }
383 pub async fn handle_config(
384 &mut self,
385 request: impl tonic::IntoRequest<super::ConfigSnapshot>,
386 ) -> std::result::Result<tonic::Response<super::CommonResponse>, tonic::Status> {
387 self.inner
388 .ready()
389 .await
390 .map_err(|e| {
391 tonic::Status::unknown(
392 format!("Service was not ready: {}", e.into()),
393 )
394 })?;
395 let codec = tonic::codec::ProstCodec::default();
396 let path = http::uri::PathAndQuery::from_static(
397 "/wallguard.WallGuard/HandleConfig",
398 );
399 let mut req = request.into_request();
400 req.extensions_mut()
401 .insert(GrpcMethod::new("wallguard.WallGuard", "HandleConfig"));
402 self.inner.unary(req, path, codec).await
403 }
404 pub async fn handle_logs(
405 &mut self,
406 request: impl tonic::IntoRequest<super::Logs>,
407 ) -> std::result::Result<tonic::Response<super::CommonResponse>, tonic::Status> {
408 self.inner
409 .ready()
410 .await
411 .map_err(|e| {
412 tonic::Status::unknown(
413 format!("Service was not ready: {}", e.into()),
414 )
415 })?;
416 let codec = tonic::codec::ProstCodec::default();
417 let path = http::uri::PathAndQuery::from_static(
418 "/wallguard.WallGuard/HandleLogs",
419 );
420 let mut req = request.into_request();
421 req.extensions_mut()
422 .insert(GrpcMethod::new("wallguard.WallGuard", "HandleLogs"));
423 self.inner.unary(req, path, codec).await
424 }
425 pub async fn request_control_channel(
426 &mut self,
427 request: impl tonic::IntoRequest<super::ControlChannelRequest>,
428 ) -> std::result::Result<
429 tonic::Response<super::ControlChannelResponse>,
430 tonic::Status,
431 > {
432 self.inner
433 .ready()
434 .await
435 .map_err(|e| {
436 tonic::Status::unknown(
437 format!("Service was not ready: {}", e.into()),
438 )
439 })?;
440 let codec = tonic::codec::ProstCodec::default();
441 let path = http::uri::PathAndQuery::from_static(
442 "/wallguard.WallGuard/RequestControlChannel",
443 );
444 let mut req = request.into_request();
445 req.extensions_mut()
446 .insert(GrpcMethod::new("wallguard.WallGuard", "RequestControlChannel"));
447 self.inner.unary(req, path, codec).await
448 }
449 }
450}
451pub mod wall_guard_server {
453 #![allow(
454 unused_variables,
455 dead_code,
456 missing_docs,
457 clippy::wildcard_imports,
458 clippy::let_unit_value,
459 )]
460 use tonic::codegen::*;
461 #[async_trait]
463 pub trait WallGuard: std::marker::Send + std::marker::Sync + 'static {
464 async fn login(
465 &self,
466 request: tonic::Request<super::LoginRequest>,
467 ) -> std::result::Result<tonic::Response<super::Authentication>, tonic::Status>;
468 async fn status(
469 &self,
470 request: tonic::Request<super::StatusRequest>,
471 ) -> std::result::Result<tonic::Response<super::StatusResponse>, tonic::Status>;
472 async fn setup(
473 &self,
474 request: tonic::Request<super::SetupRequest>,
475 ) -> std::result::Result<tonic::Response<super::CommonResponse>, tonic::Status>;
476 async fn heartbeat(
477 &self,
478 request: tonic::Request<super::HeartbeatRequest>,
479 ) -> std::result::Result<
480 tonic::Response<super::HeartbeatResponse>,
481 tonic::Status,
482 >;
483 async fn handle_packets(
484 &self,
485 request: tonic::Request<super::Packets>,
486 ) -> std::result::Result<tonic::Response<super::CommonResponse>, tonic::Status>;
487 async fn handle_config(
488 &self,
489 request: tonic::Request<super::ConfigSnapshot>,
490 ) -> std::result::Result<tonic::Response<super::CommonResponse>, tonic::Status>;
491 async fn handle_logs(
492 &self,
493 request: tonic::Request<super::Logs>,
494 ) -> std::result::Result<tonic::Response<super::CommonResponse>, tonic::Status>;
495 async fn request_control_channel(
496 &self,
497 request: tonic::Request<super::ControlChannelRequest>,
498 ) -> std::result::Result<
499 tonic::Response<super::ControlChannelResponse>,
500 tonic::Status,
501 >;
502 }
503 #[derive(Debug)]
504 pub struct WallGuardServer<T> {
505 inner: Arc<T>,
506 accept_compression_encodings: EnabledCompressionEncodings,
507 send_compression_encodings: EnabledCompressionEncodings,
508 max_decoding_message_size: Option<usize>,
509 max_encoding_message_size: Option<usize>,
510 }
511 impl<T> WallGuardServer<T> {
512 pub fn new(inner: T) -> Self {
513 Self::from_arc(Arc::new(inner))
514 }
515 pub fn from_arc(inner: Arc<T>) -> Self {
516 Self {
517 inner,
518 accept_compression_encodings: Default::default(),
519 send_compression_encodings: Default::default(),
520 max_decoding_message_size: None,
521 max_encoding_message_size: None,
522 }
523 }
524 pub fn with_interceptor<F>(
525 inner: T,
526 interceptor: F,
527 ) -> InterceptedService<Self, F>
528 where
529 F: tonic::service::Interceptor,
530 {
531 InterceptedService::new(Self::new(inner), interceptor)
532 }
533 #[must_use]
535 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
536 self.accept_compression_encodings.enable(encoding);
537 self
538 }
539 #[must_use]
541 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
542 self.send_compression_encodings.enable(encoding);
543 self
544 }
545 #[must_use]
549 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
550 self.max_decoding_message_size = Some(limit);
551 self
552 }
553 #[must_use]
557 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
558 self.max_encoding_message_size = Some(limit);
559 self
560 }
561 }
562 impl<T, B> tonic::codegen::Service<http::Request<B>> for WallGuardServer<T>
563 where
564 T: WallGuard,
565 B: Body + std::marker::Send + 'static,
566 B::Error: Into<StdError> + std::marker::Send + 'static,
567 {
568 type Response = http::Response<tonic::body::BoxBody>;
569 type Error = std::convert::Infallible;
570 type Future = BoxFuture<Self::Response, Self::Error>;
571 fn poll_ready(
572 &mut self,
573 _cx: &mut Context<'_>,
574 ) -> Poll<std::result::Result<(), Self::Error>> {
575 Poll::Ready(Ok(()))
576 }
577 fn call(&mut self, req: http::Request<B>) -> Self::Future {
578 match req.uri().path() {
579 "/wallguard.WallGuard/Login" => {
580 #[allow(non_camel_case_types)]
581 struct LoginSvc<T: WallGuard>(pub Arc<T>);
582 impl<T: WallGuard> tonic::server::UnaryService<super::LoginRequest>
583 for LoginSvc<T> {
584 type Response = super::Authentication;
585 type Future = BoxFuture<
586 tonic::Response<Self::Response>,
587 tonic::Status,
588 >;
589 fn call(
590 &mut self,
591 request: tonic::Request<super::LoginRequest>,
592 ) -> Self::Future {
593 let inner = Arc::clone(&self.0);
594 let fut = async move {
595 <T as WallGuard>::login(&inner, request).await
596 };
597 Box::pin(fut)
598 }
599 }
600 let accept_compression_encodings = self.accept_compression_encodings;
601 let send_compression_encodings = self.send_compression_encodings;
602 let max_decoding_message_size = self.max_decoding_message_size;
603 let max_encoding_message_size = self.max_encoding_message_size;
604 let inner = self.inner.clone();
605 let fut = async move {
606 let method = LoginSvc(inner);
607 let codec = tonic::codec::ProstCodec::default();
608 let mut grpc = tonic::server::Grpc::new(codec)
609 .apply_compression_config(
610 accept_compression_encodings,
611 send_compression_encodings,
612 )
613 .apply_max_message_size_config(
614 max_decoding_message_size,
615 max_encoding_message_size,
616 );
617 let res = grpc.unary(method, req).await;
618 Ok(res)
619 };
620 Box::pin(fut)
621 }
622 "/wallguard.WallGuard/Status" => {
623 #[allow(non_camel_case_types)]
624 struct StatusSvc<T: WallGuard>(pub Arc<T>);
625 impl<T: WallGuard> tonic::server::UnaryService<super::StatusRequest>
626 for StatusSvc<T> {
627 type Response = super::StatusResponse;
628 type Future = BoxFuture<
629 tonic::Response<Self::Response>,
630 tonic::Status,
631 >;
632 fn call(
633 &mut self,
634 request: tonic::Request<super::StatusRequest>,
635 ) -> Self::Future {
636 let inner = Arc::clone(&self.0);
637 let fut = async move {
638 <T as WallGuard>::status(&inner, request).await
639 };
640 Box::pin(fut)
641 }
642 }
643 let accept_compression_encodings = self.accept_compression_encodings;
644 let send_compression_encodings = self.send_compression_encodings;
645 let max_decoding_message_size = self.max_decoding_message_size;
646 let max_encoding_message_size = self.max_encoding_message_size;
647 let inner = self.inner.clone();
648 let fut = async move {
649 let method = StatusSvc(inner);
650 let codec = tonic::codec::ProstCodec::default();
651 let mut grpc = tonic::server::Grpc::new(codec)
652 .apply_compression_config(
653 accept_compression_encodings,
654 send_compression_encodings,
655 )
656 .apply_max_message_size_config(
657 max_decoding_message_size,
658 max_encoding_message_size,
659 );
660 let res = grpc.unary(method, req).await;
661 Ok(res)
662 };
663 Box::pin(fut)
664 }
665 "/wallguard.WallGuard/Setup" => {
666 #[allow(non_camel_case_types)]
667 struct SetupSvc<T: WallGuard>(pub Arc<T>);
668 impl<T: WallGuard> tonic::server::UnaryService<super::SetupRequest>
669 for SetupSvc<T> {
670 type Response = super::CommonResponse;
671 type Future = BoxFuture<
672 tonic::Response<Self::Response>,
673 tonic::Status,
674 >;
675 fn call(
676 &mut self,
677 request: tonic::Request<super::SetupRequest>,
678 ) -> Self::Future {
679 let inner = Arc::clone(&self.0);
680 let fut = async move {
681 <T as WallGuard>::setup(&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 = SetupSvc(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/Heartbeat" => {
709 #[allow(non_camel_case_types)]
710 struct HeartbeatSvc<T: WallGuard>(pub Arc<T>);
711 impl<
712 T: WallGuard,
713 > tonic::server::UnaryService<super::HeartbeatRequest>
714 for HeartbeatSvc<T> {
715 type Response = super::HeartbeatResponse;
716 type Future = BoxFuture<
717 tonic::Response<Self::Response>,
718 tonic::Status,
719 >;
720 fn call(
721 &mut self,
722 request: tonic::Request<super::HeartbeatRequest>,
723 ) -> Self::Future {
724 let inner = Arc::clone(&self.0);
725 let fut = async move {
726 <T as WallGuard>::heartbeat(&inner, request).await
727 };
728 Box::pin(fut)
729 }
730 }
731 let accept_compression_encodings = self.accept_compression_encodings;
732 let send_compression_encodings = self.send_compression_encodings;
733 let max_decoding_message_size = self.max_decoding_message_size;
734 let max_encoding_message_size = self.max_encoding_message_size;
735 let inner = self.inner.clone();
736 let fut = async move {
737 let method = HeartbeatSvc(inner);
738 let codec = tonic::codec::ProstCodec::default();
739 let mut grpc = tonic::server::Grpc::new(codec)
740 .apply_compression_config(
741 accept_compression_encodings,
742 send_compression_encodings,
743 )
744 .apply_max_message_size_config(
745 max_decoding_message_size,
746 max_encoding_message_size,
747 );
748 let res = grpc.unary(method, req).await;
749 Ok(res)
750 };
751 Box::pin(fut)
752 }
753 "/wallguard.WallGuard/HandlePackets" => {
754 #[allow(non_camel_case_types)]
755 struct HandlePacketsSvc<T: WallGuard>(pub Arc<T>);
756 impl<T: WallGuard> tonic::server::UnaryService<super::Packets>
757 for HandlePacketsSvc<T> {
758 type Response = super::CommonResponse;
759 type Future = BoxFuture<
760 tonic::Response<Self::Response>,
761 tonic::Status,
762 >;
763 fn call(
764 &mut self,
765 request: tonic::Request<super::Packets>,
766 ) -> Self::Future {
767 let inner = Arc::clone(&self.0);
768 let fut = async move {
769 <T as WallGuard>::handle_packets(&inner, request).await
770 };
771 Box::pin(fut)
772 }
773 }
774 let accept_compression_encodings = self.accept_compression_encodings;
775 let send_compression_encodings = self.send_compression_encodings;
776 let max_decoding_message_size = self.max_decoding_message_size;
777 let max_encoding_message_size = self.max_encoding_message_size;
778 let inner = self.inner.clone();
779 let fut = async move {
780 let method = HandlePacketsSvc(inner);
781 let codec = tonic::codec::ProstCodec::default();
782 let mut grpc = tonic::server::Grpc::new(codec)
783 .apply_compression_config(
784 accept_compression_encodings,
785 send_compression_encodings,
786 )
787 .apply_max_message_size_config(
788 max_decoding_message_size,
789 max_encoding_message_size,
790 );
791 let res = grpc.unary(method, req).await;
792 Ok(res)
793 };
794 Box::pin(fut)
795 }
796 "/wallguard.WallGuard/HandleConfig" => {
797 #[allow(non_camel_case_types)]
798 struct HandleConfigSvc<T: WallGuard>(pub Arc<T>);
799 impl<T: WallGuard> tonic::server::UnaryService<super::ConfigSnapshot>
800 for HandleConfigSvc<T> {
801 type Response = super::CommonResponse;
802 type Future = BoxFuture<
803 tonic::Response<Self::Response>,
804 tonic::Status,
805 >;
806 fn call(
807 &mut self,
808 request: tonic::Request<super::ConfigSnapshot>,
809 ) -> Self::Future {
810 let inner = Arc::clone(&self.0);
811 let fut = async move {
812 <T as WallGuard>::handle_config(&inner, request).await
813 };
814 Box::pin(fut)
815 }
816 }
817 let accept_compression_encodings = self.accept_compression_encodings;
818 let send_compression_encodings = self.send_compression_encodings;
819 let max_decoding_message_size = self.max_decoding_message_size;
820 let max_encoding_message_size = self.max_encoding_message_size;
821 let inner = self.inner.clone();
822 let fut = async move {
823 let method = HandleConfigSvc(inner);
824 let codec = tonic::codec::ProstCodec::default();
825 let mut grpc = tonic::server::Grpc::new(codec)
826 .apply_compression_config(
827 accept_compression_encodings,
828 send_compression_encodings,
829 )
830 .apply_max_message_size_config(
831 max_decoding_message_size,
832 max_encoding_message_size,
833 );
834 let res = grpc.unary(method, req).await;
835 Ok(res)
836 };
837 Box::pin(fut)
838 }
839 "/wallguard.WallGuard/HandleLogs" => {
840 #[allow(non_camel_case_types)]
841 struct HandleLogsSvc<T: WallGuard>(pub Arc<T>);
842 impl<T: WallGuard> tonic::server::UnaryService<super::Logs>
843 for HandleLogsSvc<T> {
844 type Response = super::CommonResponse;
845 type Future = BoxFuture<
846 tonic::Response<Self::Response>,
847 tonic::Status,
848 >;
849 fn call(
850 &mut self,
851 request: tonic::Request<super::Logs>,
852 ) -> Self::Future {
853 let inner = Arc::clone(&self.0);
854 let fut = async move {
855 <T as WallGuard>::handle_logs(&inner, request).await
856 };
857 Box::pin(fut)
858 }
859 }
860 let accept_compression_encodings = self.accept_compression_encodings;
861 let send_compression_encodings = self.send_compression_encodings;
862 let max_decoding_message_size = self.max_decoding_message_size;
863 let max_encoding_message_size = self.max_encoding_message_size;
864 let inner = self.inner.clone();
865 let fut = async move {
866 let method = HandleLogsSvc(inner);
867 let codec = tonic::codec::ProstCodec::default();
868 let mut grpc = tonic::server::Grpc::new(codec)
869 .apply_compression_config(
870 accept_compression_encodings,
871 send_compression_encodings,
872 )
873 .apply_max_message_size_config(
874 max_decoding_message_size,
875 max_encoding_message_size,
876 );
877 let res = grpc.unary(method, req).await;
878 Ok(res)
879 };
880 Box::pin(fut)
881 }
882 "/wallguard.WallGuard/RequestControlChannel" => {
883 #[allow(non_camel_case_types)]
884 struct RequestControlChannelSvc<T: WallGuard>(pub Arc<T>);
885 impl<
886 T: WallGuard,
887 > tonic::server::UnaryService<super::ControlChannelRequest>
888 for RequestControlChannelSvc<T> {
889 type Response = super::ControlChannelResponse;
890 type Future = BoxFuture<
891 tonic::Response<Self::Response>,
892 tonic::Status,
893 >;
894 fn call(
895 &mut self,
896 request: tonic::Request<super::ControlChannelRequest>,
897 ) -> Self::Future {
898 let inner = Arc::clone(&self.0);
899 let fut = async move {
900 <T as WallGuard>::request_control_channel(&inner, request)
901 .await
902 };
903 Box::pin(fut)
904 }
905 }
906 let accept_compression_encodings = self.accept_compression_encodings;
907 let send_compression_encodings = self.send_compression_encodings;
908 let max_decoding_message_size = self.max_decoding_message_size;
909 let max_encoding_message_size = self.max_encoding_message_size;
910 let inner = self.inner.clone();
911 let fut = async move {
912 let method = RequestControlChannelSvc(inner);
913 let codec = tonic::codec::ProstCodec::default();
914 let mut grpc = tonic::server::Grpc::new(codec)
915 .apply_compression_config(
916 accept_compression_encodings,
917 send_compression_encodings,
918 )
919 .apply_max_message_size_config(
920 max_decoding_message_size,
921 max_encoding_message_size,
922 );
923 let res = grpc.unary(method, req).await;
924 Ok(res)
925 };
926 Box::pin(fut)
927 }
928 _ => {
929 Box::pin(async move {
930 let mut response = http::Response::new(empty_body());
931 let headers = response.headers_mut();
932 headers
933 .insert(
934 tonic::Status::GRPC_STATUS,
935 (tonic::Code::Unimplemented as i32).into(),
936 );
937 headers
938 .insert(
939 http::header::CONTENT_TYPE,
940 tonic::metadata::GRPC_CONTENT_TYPE,
941 );
942 Ok(response)
943 })
944 }
945 }
946 }
947 }
948 impl<T> Clone for WallGuardServer<T> {
949 fn clone(&self) -> Self {
950 let inner = self.inner.clone();
951 Self {
952 inner,
953 accept_compression_encodings: self.accept_compression_encodings,
954 send_compression_encodings: self.send_compression_encodings,
955 max_decoding_message_size: self.max_decoding_message_size,
956 max_encoding_message_size: self.max_encoding_message_size,
957 }
958 }
959 }
960 pub const SERVICE_NAME: &str = "wallguard.WallGuard";
962 impl<T> tonic::server::NamedService for WallGuardServer<T> {
963 const NAME: &'static str = SERVICE_NAME;
964 }
965}