// This file is @generated by prost-build.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EphemeralPeerRequestV1 {
    #[prost(bytes = "vec", tag = "1")]
    pub wg_parent_pubkey: ::prost::alloc::vec::Vec<u8>,
    #[prost(bytes = "vec", tag = "2")]
    pub wg_ephemeral_peer_pubkey: ::prost::alloc::vec::Vec<u8>,
    #[prost(message, optional, tag = "3")]
    pub post_quantum: ::core::option::Option<PostQuantumRequestV1>,
    #[prost(message, optional, tag = "4")]
    pub daita: ::core::option::Option<DaitaRequestV1>,
    #[prost(message, optional, tag = "5")]
    pub daita_v2: ::core::option::Option<DaitaRequestV2>,
}
/// The v1 request supports these four algorithms.
/// The algorithms can appear soletary or mixed. Kyber1024 and ML-KEM-1024 cannot be used in the
/// same request as they are just different versions of the same kem.
/// - "Classic-McEliece-460896f", but explicitly identified as "Classic-McEliece-460896f-round3"
/// - "Kyber1024", this is round3 of the Kyber KEM
/// - "ML-KEM-1024". This is the standardized version of ML-KEM (FIPS 203) at the highest strength
/// - "HQC-256". This is the standardized version of HQC at the highest strength
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PostQuantumRequestV1 {
    #[prost(message, repeated, tag = "1")]
    pub kem_pubkeys: ::prost::alloc::vec::Vec<KemPubkeyV1>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct KemPubkeyV1 {
    #[prost(string, tag = "1")]
    pub algorithm_name: ::prost::alloc::string::String,
    #[prost(bytes = "vec", tag = "2")]
    pub key_data: ::prost::alloc::vec::Vec<u8>,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct DaitaRequestV1 {
    #[prost(bool, tag = "1")]
    pub activate_daita: bool,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct DaitaRequestV2 {
    #[prost(uint32, tag = "1")]
    pub version: u32,
    #[prost(enumeration = "DaitaPlatform", tag = "2")]
    pub platform: i32,
    #[prost(enumeration = "DaitaLevel", tag = "3")]
    pub level: i32,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DaitaResponseV2 {
    #[prost(string, repeated, tag = "1")]
    pub client_machines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    #[prost(double, tag = "2")]
    pub max_padding_frac: f64,
    #[prost(double, tag = "3")]
    pub max_blocking_frac: f64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EphemeralPeerResponseV1 {
    /// The response from the VPN server contains:
    ///    * `ciphertexts` - A list of the ciphertexts (the encapsulated shared secrets) for all
    ///      public keys in `kem_pubkeys` in the request, in the same order as in the request.
    ///
    /// # Deriving the WireGuard PSK
    ///
    /// The PSK to be used in WireGuard's preshared-key field is computed by XORing the resulting
    /// shared secrets of all the KEM algorithms. All currently supported and planned to be
    /// supported algorithms output 32 bytes, so this is trivial.
    ///
    /// Since the PSK provided to WireGuard is directly fed into a HKDF, it is not important that
    /// the entropy in the PSK is uniformly distributed. The actual keys used for encrypting the
    /// data channel will have uniformly distributed entropy anyway, thanks to the HKDF.
    ///
    /// KEMs that produce shared secrets of other lengths than 32 bytes, should hash the shared
    /// secret with sha256 to generate the 32 bytes used in the XOR step.
    ///
    /// Mixing with XOR (A = B ^ C) is fine since nothing about A is revealed even if one of B or C
    /// is known. Both B *and* C must be known to compute any bit in A. This means all involved
    /// KEM algorithms must be broken before the PSK can be computed by an attacker.
    #[prost(message, optional, tag = "1")]
    pub post_quantum: ::core::option::Option<PostQuantumResponseV1>,
    #[prost(message, optional, tag = "2")]
    pub daita: ::core::option::Option<DaitaResponseV2>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct PostQuantumResponseV1 {
    #[prost(bytes = "vec", repeated, tag = "1")]
    pub ciphertexts: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum DaitaPlatform {
    Undefined = 0,
    WindowsNative = 1,
    LinuxWgGo = 2,
    MacosWgGo = 3,
    IosWgGo = 4,
    AndroidWgGo = 5,
    WindowsWgGo = 6,
}
impl DaitaPlatform {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Undefined => "undefined",
            Self::WindowsNative => "windows_native",
            Self::LinuxWgGo => "linux_wg_go",
            Self::MacosWgGo => "macos_wg_go",
            Self::IosWgGo => "ios_wg_go",
            Self::AndroidWgGo => "android_wg_go",
            Self::WindowsWgGo => "windows_wg_go",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "undefined" => Some(Self::Undefined),
            "windows_native" => Some(Self::WindowsNative),
            "linux_wg_go" => Some(Self::LinuxWgGo),
            "macos_wg_go" => Some(Self::MacosWgGo),
            "ios_wg_go" => Some(Self::IosWgGo),
            "android_wg_go" => Some(Self::AndroidWgGo),
            "windows_wg_go" => Some(Self::WindowsWgGo),
            _ => None,
        }
    }
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum DaitaLevel {
    LevelDefault = 0,
    Level1 = 1,
    Level2 = 2,
    Level3 = 3,
    Level4 = 4,
    Level5 = 5,
    Level6 = 6,
    Level7 = 7,
    Level8 = 8,
    Level9 = 9,
    Level10 = 10,
}
impl DaitaLevel {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::LevelDefault => "level_default",
            Self::Level1 => "level_1",
            Self::Level2 => "level_2",
            Self::Level3 => "level_3",
            Self::Level4 => "level_4",
            Self::Level5 => "level_5",
            Self::Level6 => "level_6",
            Self::Level7 => "level_7",
            Self::Level8 => "level_8",
            Self::Level9 => "level_9",
            Self::Level10 => "level_10",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "level_default" => Some(Self::LevelDefault),
            "level_1" => Some(Self::Level1),
            "level_2" => Some(Self::Level2),
            "level_3" => Some(Self::Level3),
            "level_4" => Some(Self::Level4),
            "level_5" => Some(Self::Level5),
            "level_6" => Some(Self::Level6),
            "level_7" => Some(Self::Level7),
            "level_8" => Some(Self::Level8),
            "level_9" => Some(Self::Level9),
            "level_10" => Some(Self::Level10),
            _ => None,
        }
    }
}
/// Generated client implementations.
pub mod ephemeral_peer_client {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    use tonic::codegen::http::Uri;
    #[derive(Debug, Clone)]
    pub struct EphemeralPeerClient<T> {
        inner: tonic::client::Grpc<T>,
    }
    impl EphemeralPeerClient<tonic::transport::Channel> {
        /// Attempt to create a new client by connecting to a given endpoint.
        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
        where
            D: TryInto<tonic::transport::Endpoint>,
            D::Error: Into<StdError>,
        {
            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
            Ok(Self::new(conn))
        }
    }
    impl<T> EphemeralPeerClient<T>
    where
        T: tonic::client::GrpcService<tonic::body::Body>,
        T::Error: Into<StdError>,
        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
    {
        pub fn new(inner: T) -> Self {
            let inner = tonic::client::Grpc::new(inner);
            Self { inner }
        }
        pub fn with_origin(inner: T, origin: Uri) -> Self {
            let inner = tonic::client::Grpc::with_origin(inner, origin);
            Self { inner }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> EphemeralPeerClient<InterceptedService<T, F>>
        where
            F: tonic::service::Interceptor,
            T::ResponseBody: Default,
            T: tonic::codegen::Service<
                http::Request<tonic::body::Body>,
                Response = http::Response<
                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
                >,
            >,
            <T as tonic::codegen::Service<
                http::Request<tonic::body::Body>,
            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
        {
            EphemeralPeerClient::new(InterceptedService::new(inner, interceptor))
        }
        /// Compress requests with the given encoding.
        ///
        /// This requires the server to support it otherwise it might respond with an
        /// error.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.send_compressed(encoding);
            self
        }
        /// Enable decompressing responses.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.accept_compressed(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_decoding_message_size(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_encoding_message_size(limit);
            self
        }
        /// Derive an ephemeral peer with one or several options enabled, such as PQ or DAITA.
        ///
        /// The VPN server associates the ephemeral peer with the peer who performed the exchange. Any
        /// already existing ephemeral peer for the normal peer is replaced. Each normal peer can have
        /// at most one ephemeral peer.
        ///
        /// The ephemeral peer is mutually exclusive to the normal peer. The server keeps both peers in
        /// memory, but only one of them is loaded into WireGuard at any point in time. A handshake from
        /// the normal peer unloads the corresponding ephemeral peer from WireGuard and vice versa.
        ///
        /// A new peer is negotiated to avoid a premature break of the tunnel used for negotiation.
        /// A tunnel would break prematurely if configuration such as preshared key were applied before the
        /// normal peer received the server's response. This cannot occur now because the client decides
        /// when to switch to the ephemeral tunnel. This design also allows the client to switch back to
        /// using a non-ephemeral tunnel at any point.
        ///
        /// The server gives no guarantees how long the ephemeral peer will be valid and working when it's
        /// no longer in use. The client should negotiate a new ephemeral peer every time it establishes a
        /// new tunnel to the server.
        ///
        /// The request from the VPN client should contain:
        ///   * `wg_parent_pubkey` - The public key used by the current tunnel (that the request travels
        ///     inside).
        ///   * `wg_ephemeral_peer_pubkey` - A newly generated ephemeral WireGuard public key for the
        ///     ephemeral peer. The server will associate the new configuration with this key.
        ///   * One or more requests for different types of options. See the individual messages for more
        ///     information. If a request is provided, a corresponding response may be returned in the
        ///     server's response.
        pub async fn register_peer_v1(
            &mut self,
            request: impl tonic::IntoRequest<super::EphemeralPeerRequestV1>,
        ) -> std::result::Result<
            tonic::Response<super::EphemeralPeerResponseV1>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/ephemeralpeer.EphemeralPeer/RegisterPeerV1",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new("ephemeralpeer.EphemeralPeer", "RegisterPeerV1"),
                );
            self.inner.unary(req, path, codec).await
        }
    }
}
/// Generated server implementations.
pub mod ephemeral_peer_server {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    /// Generated trait containing gRPC methods that should be implemented for use with EphemeralPeerServer.
    #[async_trait]
    pub trait EphemeralPeer: std::marker::Send + std::marker::Sync + 'static {
        /// Derive an ephemeral peer with one or several options enabled, such as PQ or DAITA.
        ///
        /// The VPN server associates the ephemeral peer with the peer who performed the exchange. Any
        /// already existing ephemeral peer for the normal peer is replaced. Each normal peer can have
        /// at most one ephemeral peer.
        ///
        /// The ephemeral peer is mutually exclusive to the normal peer. The server keeps both peers in
        /// memory, but only one of them is loaded into WireGuard at any point in time. A handshake from
        /// the normal peer unloads the corresponding ephemeral peer from WireGuard and vice versa.
        ///
        /// A new peer is negotiated to avoid a premature break of the tunnel used for negotiation.
        /// A tunnel would break prematurely if configuration such as preshared key were applied before the
        /// normal peer received the server's response. This cannot occur now because the client decides
        /// when to switch to the ephemeral tunnel. This design also allows the client to switch back to
        /// using a non-ephemeral tunnel at any point.
        ///
        /// The server gives no guarantees how long the ephemeral peer will be valid and working when it's
        /// no longer in use. The client should negotiate a new ephemeral peer every time it establishes a
        /// new tunnel to the server.
        ///
        /// The request from the VPN client should contain:
        ///   * `wg_parent_pubkey` - The public key used by the current tunnel (that the request travels
        ///     inside).
        ///   * `wg_ephemeral_peer_pubkey` - A newly generated ephemeral WireGuard public key for the
        ///     ephemeral peer. The server will associate the new configuration with this key.
        ///   * One or more requests for different types of options. See the individual messages for more
        ///     information. If a request is provided, a corresponding response may be returned in the
        ///     server's response.
        async fn register_peer_v1(
            &self,
            request: tonic::Request<super::EphemeralPeerRequestV1>,
        ) -> std::result::Result<
            tonic::Response<super::EphemeralPeerResponseV1>,
            tonic::Status,
        >;
    }
    #[derive(Debug)]
    pub struct EphemeralPeerServer<T> {
        inner: Arc<T>,
        accept_compression_encodings: EnabledCompressionEncodings,
        send_compression_encodings: EnabledCompressionEncodings,
        max_decoding_message_size: Option<usize>,
        max_encoding_message_size: Option<usize>,
    }
    impl<T> EphemeralPeerServer<T> {
        pub fn new(inner: T) -> Self {
            Self::from_arc(Arc::new(inner))
        }
        pub fn from_arc(inner: Arc<T>) -> Self {
            Self {
                inner,
                accept_compression_encodings: Default::default(),
                send_compression_encodings: Default::default(),
                max_decoding_message_size: None,
                max_encoding_message_size: None,
            }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> InterceptedService<Self, F>
        where
            F: tonic::service::Interceptor,
        {
            InterceptedService::new(Self::new(inner), interceptor)
        }
        /// Enable decompressing requests with the given encoding.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.accept_compression_encodings.enable(encoding);
            self
        }
        /// Compress responses with the given encoding, if the client supports it.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.send_compression_encodings.enable(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.max_decoding_message_size = Some(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.max_encoding_message_size = Some(limit);
            self
        }
    }
    impl<T, B> tonic::codegen::Service<http::Request<B>> for EphemeralPeerServer<T>
    where
        T: EphemeralPeer,
        B: Body + std::marker::Send + 'static,
        B::Error: Into<StdError> + std::marker::Send + 'static,
    {
        type Response = http::Response<tonic::body::Body>;
        type Error = std::convert::Infallible;
        type Future = BoxFuture<Self::Response, Self::Error>;
        fn poll_ready(
            &mut self,
            _cx: &mut Context<'_>,
        ) -> Poll<std::result::Result<(), Self::Error>> {
            Poll::Ready(Ok(()))
        }
        fn call(&mut self, req: http::Request<B>) -> Self::Future {
            match req.uri().path() {
                "/ephemeralpeer.EphemeralPeer/RegisterPeerV1" => {
                    #[allow(non_camel_case_types)]
                    struct RegisterPeerV1Svc<T: EphemeralPeer>(pub Arc<T>);
                    impl<
                        T: EphemeralPeer,
                    > tonic::server::UnaryService<super::EphemeralPeerRequestV1>
                    for RegisterPeerV1Svc<T> {
                        type Response = super::EphemeralPeerResponseV1;
                        type Future = BoxFuture<
                            tonic::Response<Self::Response>,
                            tonic::Status,
                        >;
                        fn call(
                            &mut self,
                            request: tonic::Request<super::EphemeralPeerRequestV1>,
                        ) -> Self::Future {
                            let inner = Arc::clone(&self.0);
                            let fut = async move {
                                <T as EphemeralPeer>::register_peer_v1(&inner, request)
                                    .await
                            };
                            Box::pin(fut)
                        }
                    }
                    let accept_compression_encodings = self.accept_compression_encodings;
                    let send_compression_encodings = self.send_compression_encodings;
                    let max_decoding_message_size = self.max_decoding_message_size;
                    let max_encoding_message_size = self.max_encoding_message_size;
                    let inner = self.inner.clone();
                    let fut = async move {
                        let method = RegisterPeerV1Svc(inner);
                        let codec = tonic_prost::ProstCodec::default();
                        let mut grpc = tonic::server::Grpc::new(codec)
                            .apply_compression_config(
                                accept_compression_encodings,
                                send_compression_encodings,
                            )
                            .apply_max_message_size_config(
                                max_decoding_message_size,
                                max_encoding_message_size,
                            );
                        let res = grpc.unary(method, req).await;
                        Ok(res)
                    };
                    Box::pin(fut)
                }
                _ => {
                    Box::pin(async move {
                        let mut response = http::Response::new(
                            tonic::body::Body::default(),
                        );
                        let headers = response.headers_mut();
                        headers
                            .insert(
                                tonic::Status::GRPC_STATUS,
                                (tonic::Code::Unimplemented as i32).into(),
                            );
                        headers
                            .insert(
                                http::header::CONTENT_TYPE,
                                tonic::metadata::GRPC_CONTENT_TYPE,
                            );
                        Ok(response)
                    })
                }
            }
        }
    }
    impl<T> Clone for EphemeralPeerServer<T> {
        fn clone(&self) -> Self {
            let inner = self.inner.clone();
            Self {
                inner,
                accept_compression_encodings: self.accept_compression_encodings,
                send_compression_encodings: self.send_compression_encodings,
                max_decoding_message_size: self.max_decoding_message_size,
                max_encoding_message_size: self.max_encoding_message_size,
            }
        }
    }
    /// Generated gRPC service name
    pub const SERVICE_NAME: &str = "ephemeralpeer.EphemeralPeer";
    impl<T> tonic::server::NamedService for EphemeralPeerServer<T> {
        const NAME: &'static str = SERVICE_NAME;
    }
}
