1#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct Logs {
5 #[prost(string, tag = "1")]
6 pub token: ::prost::alloc::string::String,
7 #[prost(message, repeated, tag = "3")]
8 pub logs: ::prost::alloc::vec::Vec<Log>,
9}
10#[derive(serde::Serialize, serde::Deserialize)]
11#[derive(Clone, PartialEq, ::prost::Message)]
12pub struct Log {
13 #[prost(string, tag = "1")]
14 pub timestamp: ::prost::alloc::string::String,
15 #[prost(string, tag = "2")]
16 pub level: ::prost::alloc::string::String,
17 #[prost(string, tag = "3")]
18 pub message: ::prost::alloc::string::String,
19}
20#[derive(Clone, PartialEq, ::prost::Message)]
21pub struct AppGuardTcpConnection {
22 #[prost(string, tag = "1")]
23 pub token: ::prost::alloc::string::String,
24 #[prost(string, optional, tag = "2")]
25 pub source_ip: ::core::option::Option<::prost::alloc::string::String>,
26 #[prost(uint32, optional, tag = "3")]
27 pub source_port: ::core::option::Option<u32>,
28 #[prost(string, optional, tag = "4")]
29 pub destination_ip: ::core::option::Option<::prost::alloc::string::String>,
30 #[prost(uint32, optional, tag = "5")]
31 pub destination_port: ::core::option::Option<u32>,
32 #[prost(string, tag = "6")]
33 pub protocol: ::prost::alloc::string::String,
34}
35#[derive(serde::Deserialize)]
36#[derive(Clone, PartialEq, ::prost::Message)]
37pub struct AppGuardIpInfo {
38 #[prost(string, tag = "1")]
39 pub ip: ::prost::alloc::string::String,
40 #[prost(string, optional, tag = "2")]
41 pub country: ::core::option::Option<::prost::alloc::string::String>,
42 #[prost(string, optional, tag = "3")]
43 pub asn: ::core::option::Option<::prost::alloc::string::String>,
44 #[prost(string, optional, tag = "4")]
45 pub org: ::core::option::Option<::prost::alloc::string::String>,
46 #[prost(string, optional, tag = "5")]
47 pub continent_code: ::core::option::Option<::prost::alloc::string::String>,
48 #[prost(string, optional, tag = "6")]
49 pub city: ::core::option::Option<::prost::alloc::string::String>,
50 #[prost(string, optional, tag = "7")]
51 pub region: ::core::option::Option<::prost::alloc::string::String>,
52 #[prost(string, optional, tag = "8")]
53 pub postal: ::core::option::Option<::prost::alloc::string::String>,
54 #[prost(string, optional, tag = "9")]
56 pub timezone: ::core::option::Option<::prost::alloc::string::String>,
57}
58#[derive(Clone, PartialEq, ::prost::Message)]
59pub struct AppGuardTcpInfo {
60 #[prost(message, optional, tag = "1")]
61 pub connection: ::core::option::Option<AppGuardTcpConnection>,
62 #[prost(message, optional, tag = "2")]
63 pub ip_info: ::core::option::Option<AppGuardIpInfo>,
64 #[prost(uint64, tag = "3")]
65 pub tcp_id: u64,
66}
67#[derive(Clone, PartialEq, ::prost::Message)]
68pub struct AppGuardHttpRequest {
69 #[prost(string, tag = "1")]
70 pub token: ::prost::alloc::string::String,
71 #[prost(string, tag = "2")]
72 pub original_url: ::prost::alloc::string::String,
73 #[prost(map = "string, string", tag = "3")]
74 pub headers: ::std::collections::HashMap<
75 ::prost::alloc::string::String,
76 ::prost::alloc::string::String,
77 >,
78 #[prost(string, tag = "4")]
79 pub method: ::prost::alloc::string::String,
80 #[prost(string, optional, tag = "5")]
81 pub body: ::core::option::Option<::prost::alloc::string::String>,
82 #[prost(map = "string, string", tag = "6")]
83 pub query: ::std::collections::HashMap<
84 ::prost::alloc::string::String,
85 ::prost::alloc::string::String,
86 >,
87 #[prost(message, optional, tag = "100")]
88 pub tcp_info: ::core::option::Option<AppGuardTcpInfo>,
89}
90#[derive(Clone, PartialEq, ::prost::Message)]
91pub struct AppGuardHttpResponse {
92 #[prost(string, tag = "1")]
93 pub token: ::prost::alloc::string::String,
94 #[prost(uint32, tag = "2")]
95 pub code: u32,
96 #[prost(map = "string, string", tag = "3")]
97 pub headers: ::std::collections::HashMap<
98 ::prost::alloc::string::String,
99 ::prost::alloc::string::String,
100 >,
101 #[prost(message, optional, tag = "100")]
102 pub tcp_info: ::core::option::Option<AppGuardTcpInfo>,
103}
104#[derive(Clone, PartialEq, ::prost::Message)]
105pub struct AppGuardSmtpRequest {
106 #[prost(string, tag = "1")]
107 pub token: ::prost::alloc::string::String,
108 #[prost(map = "string, string", tag = "2")]
109 pub headers: ::std::collections::HashMap<
110 ::prost::alloc::string::String,
111 ::prost::alloc::string::String,
112 >,
113 #[prost(string, optional, tag = "3")]
114 pub body: ::core::option::Option<::prost::alloc::string::String>,
115 #[prost(message, optional, tag = "100")]
116 pub tcp_info: ::core::option::Option<AppGuardTcpInfo>,
117}
118#[derive(Clone, PartialEq, ::prost::Message)]
119pub struct AppGuardSmtpResponse {
120 #[prost(string, tag = "1")]
121 pub token: ::prost::alloc::string::String,
122 #[prost(uint32, optional, tag = "2")]
123 pub code: ::core::option::Option<u32>,
124 #[prost(message, optional, tag = "100")]
125 pub tcp_info: ::core::option::Option<AppGuardTcpInfo>,
126}
127#[derive(Clone, Copy, PartialEq, ::prost::Message)]
128pub struct AppGuardResponse {
129 #[prost(enumeration = "super::appguard_commands::FirewallPolicy", tag = "2")]
130 pub policy: i32,
131}
132#[derive(Clone, PartialEq, ::prost::Message)]
133pub struct AppGuardTcpResponse {
134 #[prost(message, optional, tag = "1")]
135 pub tcp_info: ::core::option::Option<AppGuardTcpInfo>,
136}
137#[derive(Clone, PartialEq, ::prost::Message)]
138pub struct Token {
139 #[prost(string, tag = "1")]
140 pub token: ::prost::alloc::string::String,
141}
142pub mod app_guard_client {
144 #![allow(
145 unused_variables,
146 dead_code,
147 missing_docs,
148 clippy::wildcard_imports,
149 clippy::let_unit_value,
150 )]
151 use tonic::codegen::*;
152 use tonic::codegen::http::Uri;
153 #[derive(Debug, Clone)]
154 pub struct AppGuardClient<T> {
155 inner: tonic::client::Grpc<T>,
156 }
157 impl AppGuardClient<tonic::transport::Channel> {
158 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
160 where
161 D: TryInto<tonic::transport::Endpoint>,
162 D::Error: Into<StdError>,
163 {
164 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
165 Ok(Self::new(conn))
166 }
167 }
168 impl<T> AppGuardClient<T>
169 where
170 T: tonic::client::GrpcService<tonic::body::Body>,
171 T::Error: Into<StdError>,
172 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
173 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
174 {
175 pub fn new(inner: T) -> Self {
176 let inner = tonic::client::Grpc::new(inner);
177 Self { inner }
178 }
179 pub fn with_origin(inner: T, origin: Uri) -> Self {
180 let inner = tonic::client::Grpc::with_origin(inner, origin);
181 Self { inner }
182 }
183 pub fn with_interceptor<F>(
184 inner: T,
185 interceptor: F,
186 ) -> AppGuardClient<InterceptedService<T, F>>
187 where
188 F: tonic::service::Interceptor,
189 T::ResponseBody: Default,
190 T: tonic::codegen::Service<
191 http::Request<tonic::body::Body>,
192 Response = http::Response<
193 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
194 >,
195 >,
196 <T as tonic::codegen::Service<
197 http::Request<tonic::body::Body>,
198 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
199 {
200 AppGuardClient::new(InterceptedService::new(inner, interceptor))
201 }
202 #[must_use]
207 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
208 self.inner = self.inner.send_compressed(encoding);
209 self
210 }
211 #[must_use]
213 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
214 self.inner = self.inner.accept_compressed(encoding);
215 self
216 }
217 #[must_use]
221 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
222 self.inner = self.inner.max_decoding_message_size(limit);
223 self
224 }
225 #[must_use]
229 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
230 self.inner = self.inner.max_encoding_message_size(limit);
231 self
232 }
233 pub async fn control_channel(
235 &mut self,
236 request: impl tonic::IntoStreamingRequest<
237 Message = super::super::appguard_commands::ClientMessage,
238 >,
239 ) -> std::result::Result<
240 tonic::Response<
241 tonic::codec::Streaming<super::super::appguard_commands::ServerMessage>,
242 >,
243 tonic::Status,
244 > {
245 self.inner
246 .ready()
247 .await
248 .map_err(|e| {
249 tonic::Status::unknown(
250 format!("Service was not ready: {}", e.into()),
251 )
252 })?;
253 let codec = tonic::codec::ProstCodec::default();
254 let path = http::uri::PathAndQuery::from_static(
255 "/appguard.AppGuard/ControlChannel",
256 );
257 let mut req = request.into_streaming_request();
258 req.extensions_mut()
259 .insert(GrpcMethod::new("appguard.AppGuard", "ControlChannel"));
260 self.inner.streaming(req, path, codec).await
261 }
262 pub async fn handle_logs(
264 &mut self,
265 request: impl tonic::IntoRequest<super::Logs>,
266 ) -> std::result::Result<tonic::Response<()>, 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 "/appguard.AppGuard/HandleLogs",
278 );
279 let mut req = request.into_request();
280 req.extensions_mut()
281 .insert(GrpcMethod::new("appguard.AppGuard", "HandleLogs"));
282 self.inner.unary(req, path, codec).await
283 }
284 pub async fn handle_tcp_connection(
286 &mut self,
287 request: impl tonic::IntoRequest<super::AppGuardTcpConnection>,
288 ) -> std::result::Result<
289 tonic::Response<super::AppGuardTcpResponse>,
290 tonic::Status,
291 > {
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 "/appguard.AppGuard/HandleTcpConnection",
303 );
304 let mut req = request.into_request();
305 req.extensions_mut()
306 .insert(GrpcMethod::new("appguard.AppGuard", "HandleTcpConnection"));
307 self.inner.unary(req, path, codec).await
308 }
309 pub async fn handle_http_request(
311 &mut self,
312 request: impl tonic::IntoRequest<super::AppGuardHttpRequest>,
313 ) -> std::result::Result<
314 tonic::Response<super::AppGuardResponse>,
315 tonic::Status,
316 > {
317 self.inner
318 .ready()
319 .await
320 .map_err(|e| {
321 tonic::Status::unknown(
322 format!("Service was not ready: {}", e.into()),
323 )
324 })?;
325 let codec = tonic::codec::ProstCodec::default();
326 let path = http::uri::PathAndQuery::from_static(
327 "/appguard.AppGuard/HandleHttpRequest",
328 );
329 let mut req = request.into_request();
330 req.extensions_mut()
331 .insert(GrpcMethod::new("appguard.AppGuard", "HandleHttpRequest"));
332 self.inner.unary(req, path, codec).await
333 }
334 pub async fn handle_http_response(
335 &mut self,
336 request: impl tonic::IntoRequest<super::AppGuardHttpResponse>,
337 ) -> std::result::Result<
338 tonic::Response<super::AppGuardResponse>,
339 tonic::Status,
340 > {
341 self.inner
342 .ready()
343 .await
344 .map_err(|e| {
345 tonic::Status::unknown(
346 format!("Service was not ready: {}", e.into()),
347 )
348 })?;
349 let codec = tonic::codec::ProstCodec::default();
350 let path = http::uri::PathAndQuery::from_static(
351 "/appguard.AppGuard/HandleHttpResponse",
352 );
353 let mut req = request.into_request();
354 req.extensions_mut()
355 .insert(GrpcMethod::new("appguard.AppGuard", "HandleHttpResponse"));
356 self.inner.unary(req, path, codec).await
357 }
358 pub async fn handle_smtp_request(
360 &mut self,
361 request: impl tonic::IntoRequest<super::AppGuardSmtpRequest>,
362 ) -> std::result::Result<
363 tonic::Response<super::AppGuardResponse>,
364 tonic::Status,
365 > {
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 "/appguard.AppGuard/HandleSmtpRequest",
377 );
378 let mut req = request.into_request();
379 req.extensions_mut()
380 .insert(GrpcMethod::new("appguard.AppGuard", "HandleSmtpRequest"));
381 self.inner.unary(req, path, codec).await
382 }
383 pub async fn handle_smtp_response(
384 &mut self,
385 request: impl tonic::IntoRequest<super::AppGuardSmtpResponse>,
386 ) -> std::result::Result<
387 tonic::Response<super::AppGuardResponse>,
388 tonic::Status,
389 > {
390 self.inner
391 .ready()
392 .await
393 .map_err(|e| {
394 tonic::Status::unknown(
395 format!("Service was not ready: {}", e.into()),
396 )
397 })?;
398 let codec = tonic::codec::ProstCodec::default();
399 let path = http::uri::PathAndQuery::from_static(
400 "/appguard.AppGuard/HandleSmtpResponse",
401 );
402 let mut req = request.into_request();
403 req.extensions_mut()
404 .insert(GrpcMethod::new("appguard.AppGuard", "HandleSmtpResponse"));
405 self.inner.unary(req, path, codec).await
406 }
407 pub async fn firewall_defaults_request(
409 &mut self,
410 request: impl tonic::IntoRequest<super::Token>,
411 ) -> std::result::Result<
412 tonic::Response<super::super::appguard_commands::FirewallDefaults>,
413 tonic::Status,
414 > {
415 self.inner
416 .ready()
417 .await
418 .map_err(|e| {
419 tonic::Status::unknown(
420 format!("Service was not ready: {}", e.into()),
421 )
422 })?;
423 let codec = tonic::codec::ProstCodec::default();
424 let path = http::uri::PathAndQuery::from_static(
425 "/appguard.AppGuard/FirewallDefaultsRequest",
426 );
427 let mut req = request.into_request();
428 req.extensions_mut()
429 .insert(GrpcMethod::new("appguard.AppGuard", "FirewallDefaultsRequest"));
430 self.inner.unary(req, path, codec).await
431 }
432 }
433}
434pub mod app_guard_server {
436 #![allow(
437 unused_variables,
438 dead_code,
439 missing_docs,
440 clippy::wildcard_imports,
441 clippy::let_unit_value,
442 )]
443 use tonic::codegen::*;
444 #[async_trait]
446 pub trait AppGuard: std::marker::Send + std::marker::Sync + 'static {
447 type ControlChannelStream: tonic::codegen::tokio_stream::Stream<
449 Item = std::result::Result<
450 super::super::appguard_commands::ServerMessage,
451 tonic::Status,
452 >,
453 >
454 + std::marker::Send
455 + 'static;
456 async fn control_channel(
458 &self,
459 request: tonic::Request<
460 tonic::Streaming<super::super::appguard_commands::ClientMessage>,
461 >,
462 ) -> std::result::Result<
463 tonic::Response<Self::ControlChannelStream>,
464 tonic::Status,
465 >;
466 async fn handle_logs(
468 &self,
469 request: tonic::Request<super::Logs>,
470 ) -> std::result::Result<tonic::Response<()>, tonic::Status>;
471 async fn handle_tcp_connection(
473 &self,
474 request: tonic::Request<super::AppGuardTcpConnection>,
475 ) -> std::result::Result<
476 tonic::Response<super::AppGuardTcpResponse>,
477 tonic::Status,
478 >;
479 async fn handle_http_request(
481 &self,
482 request: tonic::Request<super::AppGuardHttpRequest>,
483 ) -> std::result::Result<
484 tonic::Response<super::AppGuardResponse>,
485 tonic::Status,
486 >;
487 async fn handle_http_response(
488 &self,
489 request: tonic::Request<super::AppGuardHttpResponse>,
490 ) -> std::result::Result<
491 tonic::Response<super::AppGuardResponse>,
492 tonic::Status,
493 >;
494 async fn handle_smtp_request(
496 &self,
497 request: tonic::Request<super::AppGuardSmtpRequest>,
498 ) -> std::result::Result<
499 tonic::Response<super::AppGuardResponse>,
500 tonic::Status,
501 >;
502 async fn handle_smtp_response(
503 &self,
504 request: tonic::Request<super::AppGuardSmtpResponse>,
505 ) -> std::result::Result<
506 tonic::Response<super::AppGuardResponse>,
507 tonic::Status,
508 >;
509 async fn firewall_defaults_request(
511 &self,
512 request: tonic::Request<super::Token>,
513 ) -> std::result::Result<
514 tonic::Response<super::super::appguard_commands::FirewallDefaults>,
515 tonic::Status,
516 >;
517 }
518 #[derive(Debug)]
519 pub struct AppGuardServer<T> {
520 inner: Arc<T>,
521 accept_compression_encodings: EnabledCompressionEncodings,
522 send_compression_encodings: EnabledCompressionEncodings,
523 max_decoding_message_size: Option<usize>,
524 max_encoding_message_size: Option<usize>,
525 }
526 impl<T> AppGuardServer<T> {
527 pub fn new(inner: T) -> Self {
528 Self::from_arc(Arc::new(inner))
529 }
530 pub fn from_arc(inner: Arc<T>) -> Self {
531 Self {
532 inner,
533 accept_compression_encodings: Default::default(),
534 send_compression_encodings: Default::default(),
535 max_decoding_message_size: None,
536 max_encoding_message_size: None,
537 }
538 }
539 pub fn with_interceptor<F>(
540 inner: T,
541 interceptor: F,
542 ) -> InterceptedService<Self, F>
543 where
544 F: tonic::service::Interceptor,
545 {
546 InterceptedService::new(Self::new(inner), interceptor)
547 }
548 #[must_use]
550 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
551 self.accept_compression_encodings.enable(encoding);
552 self
553 }
554 #[must_use]
556 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
557 self.send_compression_encodings.enable(encoding);
558 self
559 }
560 #[must_use]
564 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
565 self.max_decoding_message_size = Some(limit);
566 self
567 }
568 #[must_use]
572 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
573 self.max_encoding_message_size = Some(limit);
574 self
575 }
576 }
577 impl<T, B> tonic::codegen::Service<http::Request<B>> for AppGuardServer<T>
578 where
579 T: AppGuard,
580 B: Body + std::marker::Send + 'static,
581 B::Error: Into<StdError> + std::marker::Send + 'static,
582 {
583 type Response = http::Response<tonic::body::Body>;
584 type Error = std::convert::Infallible;
585 type Future = BoxFuture<Self::Response, Self::Error>;
586 fn poll_ready(
587 &mut self,
588 _cx: &mut Context<'_>,
589 ) -> Poll<std::result::Result<(), Self::Error>> {
590 Poll::Ready(Ok(()))
591 }
592 fn call(&mut self, req: http::Request<B>) -> Self::Future {
593 match req.uri().path() {
594 "/appguard.AppGuard/ControlChannel" => {
595 #[allow(non_camel_case_types)]
596 struct ControlChannelSvc<T: AppGuard>(pub Arc<T>);
597 impl<
598 T: AppGuard,
599 > tonic::server::StreamingService<
600 super::super::appguard_commands::ClientMessage,
601 > for ControlChannelSvc<T> {
602 type Response = super::super::appguard_commands::ServerMessage;
603 type ResponseStream = T::ControlChannelStream;
604 type Future = BoxFuture<
605 tonic::Response<Self::ResponseStream>,
606 tonic::Status,
607 >;
608 fn call(
609 &mut self,
610 request: tonic::Request<
611 tonic::Streaming<
612 super::super::appguard_commands::ClientMessage,
613 >,
614 >,
615 ) -> Self::Future {
616 let inner = Arc::clone(&self.0);
617 let fut = async move {
618 <T as AppGuard>::control_channel(&inner, request).await
619 };
620 Box::pin(fut)
621 }
622 }
623 let accept_compression_encodings = self.accept_compression_encodings;
624 let send_compression_encodings = self.send_compression_encodings;
625 let max_decoding_message_size = self.max_decoding_message_size;
626 let max_encoding_message_size = self.max_encoding_message_size;
627 let inner = self.inner.clone();
628 let fut = async move {
629 let method = ControlChannelSvc(inner);
630 let codec = tonic::codec::ProstCodec::default();
631 let mut grpc = tonic::server::Grpc::new(codec)
632 .apply_compression_config(
633 accept_compression_encodings,
634 send_compression_encodings,
635 )
636 .apply_max_message_size_config(
637 max_decoding_message_size,
638 max_encoding_message_size,
639 );
640 let res = grpc.streaming(method, req).await;
641 Ok(res)
642 };
643 Box::pin(fut)
644 }
645 "/appguard.AppGuard/HandleLogs" => {
646 #[allow(non_camel_case_types)]
647 struct HandleLogsSvc<T: AppGuard>(pub Arc<T>);
648 impl<T: AppGuard> tonic::server::UnaryService<super::Logs>
649 for HandleLogsSvc<T> {
650 type Response = ();
651 type Future = BoxFuture<
652 tonic::Response<Self::Response>,
653 tonic::Status,
654 >;
655 fn call(
656 &mut self,
657 request: tonic::Request<super::Logs>,
658 ) -> Self::Future {
659 let inner = Arc::clone(&self.0);
660 let fut = async move {
661 <T as AppGuard>::handle_logs(&inner, request).await
662 };
663 Box::pin(fut)
664 }
665 }
666 let accept_compression_encodings = self.accept_compression_encodings;
667 let send_compression_encodings = self.send_compression_encodings;
668 let max_decoding_message_size = self.max_decoding_message_size;
669 let max_encoding_message_size = self.max_encoding_message_size;
670 let inner = self.inner.clone();
671 let fut = async move {
672 let method = HandleLogsSvc(inner);
673 let codec = tonic::codec::ProstCodec::default();
674 let mut grpc = tonic::server::Grpc::new(codec)
675 .apply_compression_config(
676 accept_compression_encodings,
677 send_compression_encodings,
678 )
679 .apply_max_message_size_config(
680 max_decoding_message_size,
681 max_encoding_message_size,
682 );
683 let res = grpc.unary(method, req).await;
684 Ok(res)
685 };
686 Box::pin(fut)
687 }
688 "/appguard.AppGuard/HandleTcpConnection" => {
689 #[allow(non_camel_case_types)]
690 struct HandleTcpConnectionSvc<T: AppGuard>(pub Arc<T>);
691 impl<
692 T: AppGuard,
693 > tonic::server::UnaryService<super::AppGuardTcpConnection>
694 for HandleTcpConnectionSvc<T> {
695 type Response = super::AppGuardTcpResponse;
696 type Future = BoxFuture<
697 tonic::Response<Self::Response>,
698 tonic::Status,
699 >;
700 fn call(
701 &mut self,
702 request: tonic::Request<super::AppGuardTcpConnection>,
703 ) -> Self::Future {
704 let inner = Arc::clone(&self.0);
705 let fut = async move {
706 <T as AppGuard>::handle_tcp_connection(&inner, request)
707 .await
708 };
709 Box::pin(fut)
710 }
711 }
712 let accept_compression_encodings = self.accept_compression_encodings;
713 let send_compression_encodings = self.send_compression_encodings;
714 let max_decoding_message_size = self.max_decoding_message_size;
715 let max_encoding_message_size = self.max_encoding_message_size;
716 let inner = self.inner.clone();
717 let fut = async move {
718 let method = HandleTcpConnectionSvc(inner);
719 let codec = tonic::codec::ProstCodec::default();
720 let mut grpc = tonic::server::Grpc::new(codec)
721 .apply_compression_config(
722 accept_compression_encodings,
723 send_compression_encodings,
724 )
725 .apply_max_message_size_config(
726 max_decoding_message_size,
727 max_encoding_message_size,
728 );
729 let res = grpc.unary(method, req).await;
730 Ok(res)
731 };
732 Box::pin(fut)
733 }
734 "/appguard.AppGuard/HandleHttpRequest" => {
735 #[allow(non_camel_case_types)]
736 struct HandleHttpRequestSvc<T: AppGuard>(pub Arc<T>);
737 impl<
738 T: AppGuard,
739 > tonic::server::UnaryService<super::AppGuardHttpRequest>
740 for HandleHttpRequestSvc<T> {
741 type Response = super::AppGuardResponse;
742 type Future = BoxFuture<
743 tonic::Response<Self::Response>,
744 tonic::Status,
745 >;
746 fn call(
747 &mut self,
748 request: tonic::Request<super::AppGuardHttpRequest>,
749 ) -> Self::Future {
750 let inner = Arc::clone(&self.0);
751 let fut = async move {
752 <T as AppGuard>::handle_http_request(&inner, request).await
753 };
754 Box::pin(fut)
755 }
756 }
757 let accept_compression_encodings = self.accept_compression_encodings;
758 let send_compression_encodings = self.send_compression_encodings;
759 let max_decoding_message_size = self.max_decoding_message_size;
760 let max_encoding_message_size = self.max_encoding_message_size;
761 let inner = self.inner.clone();
762 let fut = async move {
763 let method = HandleHttpRequestSvc(inner);
764 let codec = tonic::codec::ProstCodec::default();
765 let mut grpc = tonic::server::Grpc::new(codec)
766 .apply_compression_config(
767 accept_compression_encodings,
768 send_compression_encodings,
769 )
770 .apply_max_message_size_config(
771 max_decoding_message_size,
772 max_encoding_message_size,
773 );
774 let res = grpc.unary(method, req).await;
775 Ok(res)
776 };
777 Box::pin(fut)
778 }
779 "/appguard.AppGuard/HandleHttpResponse" => {
780 #[allow(non_camel_case_types)]
781 struct HandleHttpResponseSvc<T: AppGuard>(pub Arc<T>);
782 impl<
783 T: AppGuard,
784 > tonic::server::UnaryService<super::AppGuardHttpResponse>
785 for HandleHttpResponseSvc<T> {
786 type Response = super::AppGuardResponse;
787 type Future = BoxFuture<
788 tonic::Response<Self::Response>,
789 tonic::Status,
790 >;
791 fn call(
792 &mut self,
793 request: tonic::Request<super::AppGuardHttpResponse>,
794 ) -> Self::Future {
795 let inner = Arc::clone(&self.0);
796 let fut = async move {
797 <T as AppGuard>::handle_http_response(&inner, request).await
798 };
799 Box::pin(fut)
800 }
801 }
802 let accept_compression_encodings = self.accept_compression_encodings;
803 let send_compression_encodings = self.send_compression_encodings;
804 let max_decoding_message_size = self.max_decoding_message_size;
805 let max_encoding_message_size = self.max_encoding_message_size;
806 let inner = self.inner.clone();
807 let fut = async move {
808 let method = HandleHttpResponseSvc(inner);
809 let codec = tonic::codec::ProstCodec::default();
810 let mut grpc = tonic::server::Grpc::new(codec)
811 .apply_compression_config(
812 accept_compression_encodings,
813 send_compression_encodings,
814 )
815 .apply_max_message_size_config(
816 max_decoding_message_size,
817 max_encoding_message_size,
818 );
819 let res = grpc.unary(method, req).await;
820 Ok(res)
821 };
822 Box::pin(fut)
823 }
824 "/appguard.AppGuard/HandleSmtpRequest" => {
825 #[allow(non_camel_case_types)]
826 struct HandleSmtpRequestSvc<T: AppGuard>(pub Arc<T>);
827 impl<
828 T: AppGuard,
829 > tonic::server::UnaryService<super::AppGuardSmtpRequest>
830 for HandleSmtpRequestSvc<T> {
831 type Response = super::AppGuardResponse;
832 type Future = BoxFuture<
833 tonic::Response<Self::Response>,
834 tonic::Status,
835 >;
836 fn call(
837 &mut self,
838 request: tonic::Request<super::AppGuardSmtpRequest>,
839 ) -> Self::Future {
840 let inner = Arc::clone(&self.0);
841 let fut = async move {
842 <T as AppGuard>::handle_smtp_request(&inner, request).await
843 };
844 Box::pin(fut)
845 }
846 }
847 let accept_compression_encodings = self.accept_compression_encodings;
848 let send_compression_encodings = self.send_compression_encodings;
849 let max_decoding_message_size = self.max_decoding_message_size;
850 let max_encoding_message_size = self.max_encoding_message_size;
851 let inner = self.inner.clone();
852 let fut = async move {
853 let method = HandleSmtpRequestSvc(inner);
854 let codec = tonic::codec::ProstCodec::default();
855 let mut grpc = tonic::server::Grpc::new(codec)
856 .apply_compression_config(
857 accept_compression_encodings,
858 send_compression_encodings,
859 )
860 .apply_max_message_size_config(
861 max_decoding_message_size,
862 max_encoding_message_size,
863 );
864 let res = grpc.unary(method, req).await;
865 Ok(res)
866 };
867 Box::pin(fut)
868 }
869 "/appguard.AppGuard/HandleSmtpResponse" => {
870 #[allow(non_camel_case_types)]
871 struct HandleSmtpResponseSvc<T: AppGuard>(pub Arc<T>);
872 impl<
873 T: AppGuard,
874 > tonic::server::UnaryService<super::AppGuardSmtpResponse>
875 for HandleSmtpResponseSvc<T> {
876 type Response = super::AppGuardResponse;
877 type Future = BoxFuture<
878 tonic::Response<Self::Response>,
879 tonic::Status,
880 >;
881 fn call(
882 &mut self,
883 request: tonic::Request<super::AppGuardSmtpResponse>,
884 ) -> Self::Future {
885 let inner = Arc::clone(&self.0);
886 let fut = async move {
887 <T as AppGuard>::handle_smtp_response(&inner, request).await
888 };
889 Box::pin(fut)
890 }
891 }
892 let accept_compression_encodings = self.accept_compression_encodings;
893 let send_compression_encodings = self.send_compression_encodings;
894 let max_decoding_message_size = self.max_decoding_message_size;
895 let max_encoding_message_size = self.max_encoding_message_size;
896 let inner = self.inner.clone();
897 let fut = async move {
898 let method = HandleSmtpResponseSvc(inner);
899 let codec = tonic::codec::ProstCodec::default();
900 let mut grpc = tonic::server::Grpc::new(codec)
901 .apply_compression_config(
902 accept_compression_encodings,
903 send_compression_encodings,
904 )
905 .apply_max_message_size_config(
906 max_decoding_message_size,
907 max_encoding_message_size,
908 );
909 let res = grpc.unary(method, req).await;
910 Ok(res)
911 };
912 Box::pin(fut)
913 }
914 "/appguard.AppGuard/FirewallDefaultsRequest" => {
915 #[allow(non_camel_case_types)]
916 struct FirewallDefaultsRequestSvc<T: AppGuard>(pub Arc<T>);
917 impl<T: AppGuard> tonic::server::UnaryService<super::Token>
918 for FirewallDefaultsRequestSvc<T> {
919 type Response = super::super::appguard_commands::FirewallDefaults;
920 type Future = BoxFuture<
921 tonic::Response<Self::Response>,
922 tonic::Status,
923 >;
924 fn call(
925 &mut self,
926 request: tonic::Request<super::Token>,
927 ) -> Self::Future {
928 let inner = Arc::clone(&self.0);
929 let fut = async move {
930 <T as AppGuard>::firewall_defaults_request(&inner, request)
931 .await
932 };
933 Box::pin(fut)
934 }
935 }
936 let accept_compression_encodings = self.accept_compression_encodings;
937 let send_compression_encodings = self.send_compression_encodings;
938 let max_decoding_message_size = self.max_decoding_message_size;
939 let max_encoding_message_size = self.max_encoding_message_size;
940 let inner = self.inner.clone();
941 let fut = async move {
942 let method = FirewallDefaultsRequestSvc(inner);
943 let codec = tonic::codec::ProstCodec::default();
944 let mut grpc = tonic::server::Grpc::new(codec)
945 .apply_compression_config(
946 accept_compression_encodings,
947 send_compression_encodings,
948 )
949 .apply_max_message_size_config(
950 max_decoding_message_size,
951 max_encoding_message_size,
952 );
953 let res = grpc.unary(method, req).await;
954 Ok(res)
955 };
956 Box::pin(fut)
957 }
958 _ => {
959 Box::pin(async move {
960 let mut response = http::Response::new(
961 tonic::body::Body::default(),
962 );
963 let headers = response.headers_mut();
964 headers
965 .insert(
966 tonic::Status::GRPC_STATUS,
967 (tonic::Code::Unimplemented as i32).into(),
968 );
969 headers
970 .insert(
971 http::header::CONTENT_TYPE,
972 tonic::metadata::GRPC_CONTENT_TYPE,
973 );
974 Ok(response)
975 })
976 }
977 }
978 }
979 }
980 impl<T> Clone for AppGuardServer<T> {
981 fn clone(&self) -> Self {
982 let inner = self.inner.clone();
983 Self {
984 inner,
985 accept_compression_encodings: self.accept_compression_encodings,
986 send_compression_encodings: self.send_compression_encodings,
987 max_decoding_message_size: self.max_decoding_message_size,
988 max_encoding_message_size: self.max_encoding_message_size,
989 }
990 }
991 }
992 pub const SERVICE_NAME: &str = "appguard.AppGuard";
994 impl<T> tonic::server::NamedService for AppGuardServer<T> {
995 const NAME: &'static str = SERVICE_NAME;
996 }
997}