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, Eq, Hash, ::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, Eq, Hash, ::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, Eq, Hash, ::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, Eq, Hash, ::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, Eq, Hash, ::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, Eq, Hash, ::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, Eq, Hash, ::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, Eq, Hash, ::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, Eq, Hash, ::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, Eq, Hash, ::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, Eq, Hash, ::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, Eq, Hash, ::prost::Message)]
141 pub struct Headers {}
142 #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Oneof)]
143 pub enum Extract {
144 #[prost(message, tag = "1")]
145 Headers(Headers),
146 }
147 }
148 #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Oneof)]
149 pub enum Extract {
150 #[prost(message, tag = "1")]
151 Http(Http),
152 }
153 }
154}
155#[derive(Clone, Copy, PartialEq, Eq, Hash, ::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, Eq, Hash, ::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, Eq, Hash, ::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 TapClient<tonic::transport::Channel> {
342 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
344 where
345 D: TryInto<tonic::transport::Endpoint>,
346 D::Error: Into<StdError>,
347 {
348 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
349 Ok(Self::new(conn))
350 }
351 }
352 impl<T> TapClient<T>
353 where
354 T: tonic::client::GrpcService<tonic::body::Body>,
355 T::Error: Into<StdError>,
356 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
357 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
358 {
359 pub fn new(inner: T) -> Self {
360 let inner = tonic::client::Grpc::new(inner);
361 Self { inner }
362 }
363 pub fn with_origin(inner: T, origin: Uri) -> Self {
364 let inner = tonic::client::Grpc::with_origin(inner, origin);
365 Self { inner }
366 }
367 pub fn with_interceptor<F>(
368 inner: T,
369 interceptor: F,
370 ) -> TapClient<InterceptedService<T, F>>
371 where
372 F: tonic::service::Interceptor,
373 T::ResponseBody: Default,
374 T: tonic::codegen::Service<
375 http::Request<tonic::body::Body>,
376 Response = http::Response<
377 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
378 >,
379 >,
380 <T as tonic::codegen::Service<
381 http::Request<tonic::body::Body>,
382 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
383 {
384 TapClient::new(InterceptedService::new(inner, interceptor))
385 }
386 #[must_use]
391 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
392 self.inner = self.inner.send_compressed(encoding);
393 self
394 }
395 #[must_use]
397 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
398 self.inner = self.inner.accept_compressed(encoding);
399 self
400 }
401 #[must_use]
405 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
406 self.inner = self.inner.max_decoding_message_size(limit);
407 self
408 }
409 #[must_use]
413 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
414 self.inner = self.inner.max_encoding_message_size(limit);
415 self
416 }
417 pub async fn observe(
418 &mut self,
419 request: impl tonic::IntoRequest<super::ObserveRequest>,
420 ) -> std::result::Result<
421 tonic::Response<tonic::codec::Streaming<super::TapEvent>>,
422 tonic::Status,
423 > {
424 self.inner
425 .ready()
426 .await
427 .map_err(|e| {
428 tonic::Status::unknown(
429 format!("Service was not ready: {}", e.into()),
430 )
431 })?;
432 let codec = tonic_prost::ProstCodec::default();
433 let path = http::uri::PathAndQuery::from_static(
434 "/io.linkerd.proxy.tap.Tap/Observe",
435 );
436 let mut req = request.into_request();
437 req.extensions_mut()
438 .insert(GrpcMethod::new("io.linkerd.proxy.tap.Tap", "Observe"));
439 self.inner.server_streaming(req, path, codec).await
440 }
441 }
442}
443pub mod tap_server {
445 #![allow(
446 unused_variables,
447 dead_code,
448 missing_docs,
449 clippy::wildcard_imports,
450 clippy::let_unit_value,
451 )]
452 use tonic::codegen::*;
453 #[async_trait]
455 pub trait Tap: std::marker::Send + std::marker::Sync + 'static {
456 type ObserveStream: tonic::codegen::tokio_stream::Stream<
458 Item = std::result::Result<super::TapEvent, tonic::Status>,
459 >
460 + std::marker::Send
461 + 'static;
462 async fn observe(
463 &self,
464 request: tonic::Request<super::ObserveRequest>,
465 ) -> std::result::Result<tonic::Response<Self::ObserveStream>, tonic::Status>;
466 }
467 #[derive(Debug)]
469 pub struct TapServer<T> {
470 inner: Arc<T>,
471 accept_compression_encodings: EnabledCompressionEncodings,
472 send_compression_encodings: EnabledCompressionEncodings,
473 max_decoding_message_size: Option<usize>,
474 max_encoding_message_size: Option<usize>,
475 }
476 impl<T> TapServer<T> {
477 pub fn new(inner: T) -> Self {
478 Self::from_arc(Arc::new(inner))
479 }
480 pub fn from_arc(inner: Arc<T>) -> Self {
481 Self {
482 inner,
483 accept_compression_encodings: Default::default(),
484 send_compression_encodings: Default::default(),
485 max_decoding_message_size: None,
486 max_encoding_message_size: None,
487 }
488 }
489 pub fn with_interceptor<F>(
490 inner: T,
491 interceptor: F,
492 ) -> InterceptedService<Self, F>
493 where
494 F: tonic::service::Interceptor,
495 {
496 InterceptedService::new(Self::new(inner), interceptor)
497 }
498 #[must_use]
500 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
501 self.accept_compression_encodings.enable(encoding);
502 self
503 }
504 #[must_use]
506 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
507 self.send_compression_encodings.enable(encoding);
508 self
509 }
510 #[must_use]
514 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
515 self.max_decoding_message_size = Some(limit);
516 self
517 }
518 #[must_use]
522 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
523 self.max_encoding_message_size = Some(limit);
524 self
525 }
526 }
527 impl<T, B> tonic::codegen::Service<http::Request<B>> for TapServer<T>
528 where
529 T: Tap,
530 B: Body + std::marker::Send + 'static,
531 B::Error: Into<StdError> + std::marker::Send + 'static,
532 {
533 type Response = http::Response<tonic::body::Body>;
534 type Error = std::convert::Infallible;
535 type Future = BoxFuture<Self::Response, Self::Error>;
536 fn poll_ready(
537 &mut self,
538 _cx: &mut Context<'_>,
539 ) -> Poll<std::result::Result<(), Self::Error>> {
540 Poll::Ready(Ok(()))
541 }
542 fn call(&mut self, req: http::Request<B>) -> Self::Future {
543 match req.uri().path() {
544 "/io.linkerd.proxy.tap.Tap/Observe" => {
545 #[allow(non_camel_case_types)]
546 struct ObserveSvc<T: Tap>(pub Arc<T>);
547 impl<
548 T: Tap,
549 > tonic::server::ServerStreamingService<super::ObserveRequest>
550 for ObserveSvc<T> {
551 type Response = super::TapEvent;
552 type ResponseStream = T::ObserveStream;
553 type Future = BoxFuture<
554 tonic::Response<Self::ResponseStream>,
555 tonic::Status,
556 >;
557 fn call(
558 &mut self,
559 request: tonic::Request<super::ObserveRequest>,
560 ) -> Self::Future {
561 let inner = Arc::clone(&self.0);
562 let fut = async move {
563 <T as Tap>::observe(&inner, request).await
564 };
565 Box::pin(fut)
566 }
567 }
568 let accept_compression_encodings = self.accept_compression_encodings;
569 let send_compression_encodings = self.send_compression_encodings;
570 let max_decoding_message_size = self.max_decoding_message_size;
571 let max_encoding_message_size = self.max_encoding_message_size;
572 let inner = self.inner.clone();
573 let fut = async move {
574 let method = ObserveSvc(inner);
575 let codec = tonic_prost::ProstCodec::default();
576 let mut grpc = tonic::server::Grpc::new(codec)
577 .apply_compression_config(
578 accept_compression_encodings,
579 send_compression_encodings,
580 )
581 .apply_max_message_size_config(
582 max_decoding_message_size,
583 max_encoding_message_size,
584 );
585 let res = grpc.server_streaming(method, req).await;
586 Ok(res)
587 };
588 Box::pin(fut)
589 }
590 _ => {
591 Box::pin(async move {
592 let mut response = http::Response::new(
593 tonic::body::Body::default(),
594 );
595 let headers = response.headers_mut();
596 headers
597 .insert(
598 tonic::Status::GRPC_STATUS,
599 (tonic::Code::Unimplemented as i32).into(),
600 );
601 headers
602 .insert(
603 http::header::CONTENT_TYPE,
604 tonic::metadata::GRPC_CONTENT_TYPE,
605 );
606 Ok(response)
607 })
608 }
609 }
610 }
611 }
612 impl<T> Clone for TapServer<T> {
613 fn clone(&self) -> Self {
614 let inner = self.inner.clone();
615 Self {
616 inner,
617 accept_compression_encodings: self.accept_compression_encodings,
618 send_compression_encodings: self.send_compression_encodings,
619 max_decoding_message_size: self.max_decoding_message_size,
620 max_encoding_message_size: self.max_encoding_message_size,
621 }
622 }
623 }
624 pub const SERVICE_NAME: &str = "io.linkerd.proxy.tap.Tap";
626 impl<T> tonic::server::NamedService for TapServer<T> {
627 const NAME: &'static str = SERVICE_NAME;
628 }
629}