1#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct ObserveRequest {
4 #[prost(uint32, tag = "1")]
6 pub limit: u32,
7 #[prost(message, optional, tag = "2")]
9 pub r#match: ::core::option::Option<observe_request::Match>,
10 #[prost(message, optional, tag = "3")]
13 pub extract: ::core::option::Option<observe_request::Extract>,
14}
15pub mod observe_request {
17 #[derive(Clone, PartialEq, ::prost::Message)]
18 pub struct Match {
19 #[prost(oneof = "r#match::Match", tags = "1, 2, 3, 4, 5, 6, 7, 8")]
20 pub r#match: ::core::option::Option<r#match::Match>,
21 }
22 pub mod r#match {
24 #[derive(Clone, PartialEq, ::prost::Message)]
25 pub struct Seq {
26 #[prost(message, repeated, tag = "1")]
27 pub matches: ::prost::alloc::vec::Vec<super::Match>,
28 }
29 #[derive(Clone, PartialEq, ::prost::Message)]
30 pub struct Label {
31 #[prost(string, tag = "1")]
32 pub key: ::prost::alloc::string::String,
33 #[prost(string, tag = "2")]
34 pub value: ::prost::alloc::string::String,
35 }
36 #[derive(Clone, Copy, PartialEq, ::prost::Message)]
37 pub struct Tcp {
38 #[prost(oneof = "tcp::Match", tags = "1, 3")]
39 pub r#match: ::core::option::Option<tcp::Match>,
40 }
41 pub mod tcp {
43 #[derive(Clone, Copy, PartialEq, ::prost::Message)]
44 pub struct Netmask {
45 #[prost(message, optional, tag = "1")]
46 pub ip: ::core::option::Option<
47 super::super::super::super::net::IpAddress,
48 >,
49 #[prost(uint32, tag = "2")]
50 pub mask: u32,
51 }
52 #[derive(Clone, Copy, PartialEq, ::prost::Message)]
55 pub struct PortRange {
56 #[prost(uint32, tag = "1")]
58 pub min: u32,
59 #[prost(uint32, tag = "2")]
61 pub max: u32,
62 }
63 #[derive(Clone, Copy, PartialEq, ::prost::Oneof)]
64 pub enum Match {
65 #[prost(message, tag = "1")]
66 Netmask(Netmask),
67 #[prost(message, tag = "3")]
68 Ports(PortRange),
69 }
70 }
71 #[derive(Clone, PartialEq, ::prost::Message)]
72 pub struct Http {
73 #[prost(oneof = "http::Match", tags = "1, 3, 2, 4")]
74 pub r#match: ::core::option::Option<http::Match>,
75 }
76 pub mod http {
78 #[derive(Clone, PartialEq, ::prost::Message)]
79 pub struct StringMatch {
80 #[prost(oneof = "string_match::Match", tags = "1, 2")]
81 pub r#match: ::core::option::Option<string_match::Match>,
82 }
83 pub mod string_match {
85 #[derive(Clone, PartialEq, ::prost::Oneof)]
86 pub enum Match {
87 #[prost(string, tag = "1")]
88 Exact(::prost::alloc::string::String),
89 #[prost(string, tag = "2")]
90 Prefix(::prost::alloc::string::String),
91 }
92 }
93 #[derive(Clone, PartialEq, ::prost::Oneof)]
94 pub enum Match {
95 #[prost(message, tag = "1")]
96 Scheme(super::super::super::super::http_types::Scheme),
97 #[prost(message, tag = "3")]
98 Method(super::super::super::super::http_types::HttpMethod),
99 #[prost(message, tag = "2")]
100 Authority(StringMatch),
101 #[prost(message, tag = "4")]
103 Path(StringMatch),
104 }
105 }
106 #[derive(Clone, PartialEq, ::prost::Oneof)]
107 pub enum Match {
108 #[prost(message, tag = "1")]
109 All(Seq),
110 #[prost(message, tag = "2")]
111 Any(Seq),
112 #[prost(message, tag = "3")]
113 Not(::prost::alloc::boxed::Box<super::Match>),
114 #[prost(message, tag = "4")]
115 Source(Tcp),
116 #[prost(message, tag = "5")]
117 Destination(Tcp),
118 #[prost(message, tag = "6")]
119 Http(Http),
120 #[prost(message, tag = "7")]
121 DestinationLabel(Label),
122 #[prost(message, tag = "8")]
123 RouteLabel(Label),
124 }
125 }
126 #[derive(Clone, Copy, PartialEq, ::prost::Message)]
127 pub struct Extract {
128 #[prost(oneof = "extract::Extract", tags = "1")]
129 pub extract: ::core::option::Option<extract::Extract>,
130 }
131 pub mod extract {
133 #[derive(Clone, Copy, PartialEq, ::prost::Message)]
134 pub struct Http {
135 #[prost(oneof = "http::Extract", tags = "1")]
136 pub extract: ::core::option::Option<http::Extract>,
137 }
138 pub mod http {
140 #[derive(Clone, Copy, PartialEq, ::prost::Message)]
141 pub struct Headers {}
142 #[derive(Clone, Copy, PartialEq, ::prost::Oneof)]
143 pub enum Extract {
144 #[prost(message, tag = "1")]
145 Headers(Headers),
146 }
147 }
148 #[derive(Clone, Copy, PartialEq, ::prost::Oneof)]
149 pub enum Extract {
150 #[prost(message, tag = "1")]
151 Http(Http),
152 }
153 }
154}
155#[derive(Clone, Copy, PartialEq, ::prost::Message)]
156pub struct Eos {
157 #[prost(oneof = "eos::End", tags = "1, 2")]
158 pub end: ::core::option::Option<eos::End>,
159}
160pub mod eos {
162 #[derive(Clone, Copy, PartialEq, ::prost::Oneof)]
163 pub enum End {
164 #[prost(uint32, tag = "1")]
165 GrpcStatusCode(u32),
166 #[prost(uint32, tag = "2")]
167 ResetErrorCode(u32),
168 }
169}
170#[derive(Clone, PartialEq, ::prost::Message)]
171pub struct TapEvent {
172 #[prost(message, optional, tag = "1")]
173 pub source: ::core::option::Option<super::net::TcpAddress>,
174 #[prost(message, optional, tag = "5")]
175 pub source_meta: ::core::option::Option<tap_event::EndpointMeta>,
176 #[prost(message, optional, tag = "7")]
177 pub route_meta: ::core::option::Option<tap_event::RouteMeta>,
178 #[prost(message, optional, tag = "2")]
179 pub destination: ::core::option::Option<super::net::TcpAddress>,
180 #[prost(message, optional, tag = "4")]
181 pub destination_meta: ::core::option::Option<tap_event::EndpointMeta>,
182 #[prost(enumeration = "tap_event::ProxyDirection", tag = "6")]
183 pub proxy_direction: i32,
184 #[prost(oneof = "tap_event::Event", tags = "3")]
185 pub event: ::core::option::Option<tap_event::Event>,
186}
187pub mod tap_event {
189 #[derive(Clone, PartialEq, ::prost::Message)]
190 pub struct EndpointMeta {
191 #[prost(map = "string, string", tag = "1")]
192 pub labels: ::std::collections::HashMap<
193 ::prost::alloc::string::String,
194 ::prost::alloc::string::String,
195 >,
196 }
197 #[derive(Clone, PartialEq, ::prost::Message)]
198 pub struct RouteMeta {
199 #[prost(map = "string, string", tag = "1")]
200 pub labels: ::std::collections::HashMap<
201 ::prost::alloc::string::String,
202 ::prost::alloc::string::String,
203 >,
204 }
205 #[derive(Clone, PartialEq, ::prost::Message)]
206 pub struct Http {
207 #[prost(oneof = "http::Event", tags = "1, 2, 3")]
208 pub event: ::core::option::Option<http::Event>,
209 }
210 pub mod http {
212 #[derive(Clone, Copy, PartialEq, ::prost::Message)]
213 pub struct StreamId {
214 #[prost(uint32, tag = "1")]
216 pub base: u32,
217 #[prost(uint64, tag = "2")]
219 pub stream: u64,
220 }
221 #[derive(Clone, PartialEq, ::prost::Message)]
222 pub struct RequestInit {
223 #[prost(message, optional, tag = "1")]
224 pub id: ::core::option::Option<StreamId>,
225 #[prost(message, optional, tag = "2")]
226 pub method: ::core::option::Option<
227 super::super::super::http_types::HttpMethod,
228 >,
229 #[prost(message, optional, tag = "3")]
230 pub scheme: ::core::option::Option<super::super::super::http_types::Scheme>,
231 #[prost(string, tag = "4")]
232 pub authority: ::prost::alloc::string::String,
233 #[prost(string, tag = "5")]
234 pub path: ::prost::alloc::string::String,
235 #[prost(message, optional, tag = "6")]
236 pub headers: ::core::option::Option<
237 super::super::super::http_types::Headers,
238 >,
239 }
240 #[derive(Clone, PartialEq, ::prost::Message)]
241 pub struct ResponseInit {
242 #[prost(message, optional, tag = "1")]
243 pub id: ::core::option::Option<StreamId>,
244 #[prost(message, optional, tag = "2")]
245 pub since_request_init: ::core::option::Option<::prost_types::Duration>,
246 #[prost(uint32, tag = "3")]
247 pub http_status: u32,
248 #[prost(message, optional, tag = "4")]
249 pub headers: ::core::option::Option<
250 super::super::super::http_types::Headers,
251 >,
252 }
253 #[derive(Clone, PartialEq, ::prost::Message)]
254 pub struct ResponseEnd {
255 #[prost(message, optional, tag = "1")]
256 pub id: ::core::option::Option<StreamId>,
257 #[prost(message, optional, tag = "2")]
258 pub since_request_init: ::core::option::Option<::prost_types::Duration>,
259 #[prost(message, optional, tag = "3")]
260 pub since_response_init: ::core::option::Option<::prost_types::Duration>,
261 #[prost(uint64, tag = "4")]
262 pub response_bytes: u64,
263 #[prost(message, optional, tag = "5")]
264 pub eos: ::core::option::Option<super::super::Eos>,
265 #[prost(message, optional, tag = "6")]
266 pub trailers: ::core::option::Option<
267 super::super::super::http_types::Headers,
268 >,
269 }
270 #[derive(Clone, PartialEq, ::prost::Oneof)]
271 pub enum Event {
272 #[prost(message, tag = "1")]
273 RequestInit(RequestInit),
274 #[prost(message, tag = "2")]
275 ResponseInit(ResponseInit),
276 #[prost(message, tag = "3")]
277 ResponseEnd(ResponseEnd),
278 }
279 }
280 #[derive(
281 Clone,
282 Copy,
283 Debug,
284 PartialEq,
285 Eq,
286 Hash,
287 PartialOrd,
288 Ord,
289 ::prost::Enumeration
290 )]
291 #[repr(i32)]
292 pub enum ProxyDirection {
293 Unknown = 0,
294 Inbound = 1,
295 Outbound = 2,
296 }
297 impl ProxyDirection {
298 pub fn as_str_name(&self) -> &'static str {
303 match self {
304 Self::Unknown => "UNKNOWN",
305 Self::Inbound => "INBOUND",
306 Self::Outbound => "OUTBOUND",
307 }
308 }
309 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
311 match value {
312 "UNKNOWN" => Some(Self::Unknown),
313 "INBOUND" => Some(Self::Inbound),
314 "OUTBOUND" => Some(Self::Outbound),
315 _ => None,
316 }
317 }
318 }
319 #[derive(Clone, PartialEq, ::prost::Oneof)]
320 pub enum Event {
321 #[prost(message, tag = "3")]
322 Http(Http),
323 }
324}
325pub mod tap_client {
327 #![allow(
328 unused_variables,
329 dead_code,
330 missing_docs,
331 clippy::wildcard_imports,
332 clippy::let_unit_value,
333 )]
334 use tonic::codegen::*;
335 use tonic::codegen::http::Uri;
336 #[derive(Debug, Clone)]
338 pub struct TapClient<T> {
339 inner: tonic::client::Grpc<T>,
340 }
341 impl<T> TapClient<T>
342 where
343 T: tonic::client::GrpcService<tonic::body::Body>,
344 T::Error: Into<StdError>,
345 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
346 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
347 {
348 pub fn new(inner: T) -> Self {
349 let inner = tonic::client::Grpc::new(inner);
350 Self { inner }
351 }
352 pub fn with_origin(inner: T, origin: Uri) -> Self {
353 let inner = tonic::client::Grpc::with_origin(inner, origin);
354 Self { inner }
355 }
356 pub fn with_interceptor<F>(
357 inner: T,
358 interceptor: F,
359 ) -> TapClient<InterceptedService<T, F>>
360 where
361 F: tonic::service::Interceptor,
362 T::ResponseBody: Default,
363 T: tonic::codegen::Service<
364 http::Request<tonic::body::Body>,
365 Response = http::Response<
366 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
367 >,
368 >,
369 <T as tonic::codegen::Service<
370 http::Request<tonic::body::Body>,
371 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
372 {
373 TapClient::new(InterceptedService::new(inner, interceptor))
374 }
375 #[must_use]
380 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
381 self.inner = self.inner.send_compressed(encoding);
382 self
383 }
384 #[must_use]
386 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
387 self.inner = self.inner.accept_compressed(encoding);
388 self
389 }
390 #[must_use]
394 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
395 self.inner = self.inner.max_decoding_message_size(limit);
396 self
397 }
398 #[must_use]
402 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
403 self.inner = self.inner.max_encoding_message_size(limit);
404 self
405 }
406 pub async fn observe(
407 &mut self,
408 request: impl tonic::IntoRequest<super::ObserveRequest>,
409 ) -> std::result::Result<
410 tonic::Response<tonic::codec::Streaming<super::TapEvent>>,
411 tonic::Status,
412 > {
413 self.inner
414 .ready()
415 .await
416 .map_err(|e| {
417 tonic::Status::unknown(
418 format!("Service was not ready: {}", e.into()),
419 )
420 })?;
421 let codec = tonic::codec::ProstCodec::default();
422 let path = http::uri::PathAndQuery::from_static(
423 "/io.linkerd.proxy.tap.Tap/Observe",
424 );
425 let mut req = request.into_request();
426 req.extensions_mut()
427 .insert(GrpcMethod::new("io.linkerd.proxy.tap.Tap", "Observe"));
428 self.inner.server_streaming(req, path, codec).await
429 }
430 }
431}
432pub mod tap_server {
434 #![allow(
435 unused_variables,
436 dead_code,
437 missing_docs,
438 clippy::wildcard_imports,
439 clippy::let_unit_value,
440 )]
441 use tonic::codegen::*;
442 #[async_trait]
444 pub trait Tap: std::marker::Send + std::marker::Sync + 'static {
445 type ObserveStream: tonic::codegen::tokio_stream::Stream<
447 Item = std::result::Result<super::TapEvent, tonic::Status>,
448 >
449 + std::marker::Send
450 + 'static;
451 async fn observe(
452 &self,
453 request: tonic::Request<super::ObserveRequest>,
454 ) -> std::result::Result<tonic::Response<Self::ObserveStream>, tonic::Status>;
455 }
456 #[derive(Debug)]
458 pub struct TapServer<T> {
459 inner: Arc<T>,
460 accept_compression_encodings: EnabledCompressionEncodings,
461 send_compression_encodings: EnabledCompressionEncodings,
462 max_decoding_message_size: Option<usize>,
463 max_encoding_message_size: Option<usize>,
464 }
465 impl<T> TapServer<T> {
466 pub fn new(inner: T) -> Self {
467 Self::from_arc(Arc::new(inner))
468 }
469 pub fn from_arc(inner: Arc<T>) -> Self {
470 Self {
471 inner,
472 accept_compression_encodings: Default::default(),
473 send_compression_encodings: Default::default(),
474 max_decoding_message_size: None,
475 max_encoding_message_size: None,
476 }
477 }
478 pub fn with_interceptor<F>(
479 inner: T,
480 interceptor: F,
481 ) -> InterceptedService<Self, F>
482 where
483 F: tonic::service::Interceptor,
484 {
485 InterceptedService::new(Self::new(inner), interceptor)
486 }
487 #[must_use]
489 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
490 self.accept_compression_encodings.enable(encoding);
491 self
492 }
493 #[must_use]
495 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
496 self.send_compression_encodings.enable(encoding);
497 self
498 }
499 #[must_use]
503 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
504 self.max_decoding_message_size = Some(limit);
505 self
506 }
507 #[must_use]
511 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
512 self.max_encoding_message_size = Some(limit);
513 self
514 }
515 }
516 impl<T, B> tonic::codegen::Service<http::Request<B>> for TapServer<T>
517 where
518 T: Tap,
519 B: Body + std::marker::Send + 'static,
520 B::Error: Into<StdError> + std::marker::Send + 'static,
521 {
522 type Response = http::Response<tonic::body::Body>;
523 type Error = std::convert::Infallible;
524 type Future = BoxFuture<Self::Response, Self::Error>;
525 fn poll_ready(
526 &mut self,
527 _cx: &mut Context<'_>,
528 ) -> Poll<std::result::Result<(), Self::Error>> {
529 Poll::Ready(Ok(()))
530 }
531 fn call(&mut self, req: http::Request<B>) -> Self::Future {
532 match req.uri().path() {
533 "/io.linkerd.proxy.tap.Tap/Observe" => {
534 #[allow(non_camel_case_types)]
535 struct ObserveSvc<T: Tap>(pub Arc<T>);
536 impl<
537 T: Tap,
538 > tonic::server::ServerStreamingService<super::ObserveRequest>
539 for ObserveSvc<T> {
540 type Response = super::TapEvent;
541 type ResponseStream = T::ObserveStream;
542 type Future = BoxFuture<
543 tonic::Response<Self::ResponseStream>,
544 tonic::Status,
545 >;
546 fn call(
547 &mut self,
548 request: tonic::Request<super::ObserveRequest>,
549 ) -> Self::Future {
550 let inner = Arc::clone(&self.0);
551 let fut = async move {
552 <T as Tap>::observe(&inner, request).await
553 };
554 Box::pin(fut)
555 }
556 }
557 let accept_compression_encodings = self.accept_compression_encodings;
558 let send_compression_encodings = self.send_compression_encodings;
559 let max_decoding_message_size = self.max_decoding_message_size;
560 let max_encoding_message_size = self.max_encoding_message_size;
561 let inner = self.inner.clone();
562 let fut = async move {
563 let method = ObserveSvc(inner);
564 let codec = tonic::codec::ProstCodec::default();
565 let mut grpc = tonic::server::Grpc::new(codec)
566 .apply_compression_config(
567 accept_compression_encodings,
568 send_compression_encodings,
569 )
570 .apply_max_message_size_config(
571 max_decoding_message_size,
572 max_encoding_message_size,
573 );
574 let res = grpc.server_streaming(method, req).await;
575 Ok(res)
576 };
577 Box::pin(fut)
578 }
579 _ => {
580 Box::pin(async move {
581 let mut response = http::Response::new(
582 tonic::body::Body::default(),
583 );
584 let headers = response.headers_mut();
585 headers
586 .insert(
587 tonic::Status::GRPC_STATUS,
588 (tonic::Code::Unimplemented as i32).into(),
589 );
590 headers
591 .insert(
592 http::header::CONTENT_TYPE,
593 tonic::metadata::GRPC_CONTENT_TYPE,
594 );
595 Ok(response)
596 })
597 }
598 }
599 }
600 }
601 impl<T> Clone for TapServer<T> {
602 fn clone(&self) -> Self {
603 let inner = self.inner.clone();
604 Self {
605 inner,
606 accept_compression_encodings: self.accept_compression_encodings,
607 send_compression_encodings: self.send_compression_encodings,
608 max_decoding_message_size: self.max_decoding_message_size,
609 max_encoding_message_size: self.max_encoding_message_size,
610 }
611 }
612 }
613 pub const SERVICE_NAME: &str = "io.linkerd.proxy.tap.Tap";
615 impl<T> tonic::server::NamedService for TapServer<T> {
616 const NAME: &'static str = SERVICE_NAME;
617 }
618}