fn endpoint() -> (Endpoint, Incoming) {
    let mut endpoint = Endpoint::builder();

    let mut server_config = ServerConfigBuilder::default();
    let cert = rcgen::generate_simple_self_signed(vec!["localhost".into()]).unwrap();
    let key = crate::PrivateKey::from_der(&cert.serialize_private_key_der()).unwrap();
    let cert = crate::Certificate::from_der(&cert.serialize_der().unwrap()).unwrap();
    let cert_chain = crate::CertificateChain::from_certs(vec![cert.clone()]);
    server_config.certificate(cert_chain, key).unwrap();
    endpoint.listen(server_config.build());

    let mut client_config = ClientConfigBuilder::default();
    client_config.add_certificate_authority(cert).unwrap();
    endpoint.default_client_config(client_config.build());

    let (x, y) = endpoint
        .bind(&SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 0))
        .unwrap();
    (x, y)
}
/// Construct an endpoint suitable for connecting to itself
Construct an endpoint suitable for connecting to itself
Construct an endpoint suitable for connecting to itself
fn endpoint() -> (Endpoint, Incoming) {
    let mut endpoint = Endpoint::builder();
    let mut server_config = ServerConfigBuilder::default();
    let cert = rcgen::generate_simple_self_signed(vec!["localhost".into()]).unwrap();
    let key = crate::PrivateKey::from_der(&cert.serialize_private_key_der()).unwrap();
    let cert = crate::Certificate::from_der(&cert.serialize_der().unwrap()).unwrap();
    let cert_chain = crate::CertificateChain::from_certs(vec![cert.clone()]);
    server_config.certificate(cert_chain, key).unwrap();
    endpoint.listen(server_config.build());
    let mut client_config = ClientConfigBuilder::default();
    client_config.add_certificate_authority(cert).unwrap();
    endpoint.default_client_config(client_config.build());
    let (x, y) = endpoint
        .bind(&SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 0))
        .unwrap();
    (x, y)
}
fn endpoint ( ) -> ( Endpoint , Incoming ) { let mut endpoint = Endpoint :: builder ( ) ; let mut server_config = ServerConfigBuilder :: default ( ) ; let cert = rcgen :: generate_simple_self_signed ( vec ! [ " " into ( ) ] ) . unwrap ( ) ; let key = crate :: PrivateKey :: from_der ( & cert . serialize_private_key_der ( ) ) . unwrap ( ) ; let cert = crate :: Certificate :: from_der ( & cert . serialize_der ( ) . unwrap ( ) ) . unwrap ( ) ; let cert_chain = crate :: CertificateChain :: from_certs ( vec ! [ cert clone ( ) ] ) ; server_config . certificate ( cert_chain , key ) . unwrap ( ) ; endpoint . listen ( server_config . build ( ) ) ; let mut client_config = ClientConfigBuilder :: default ( ) ; client_config . add_certificate_authority ( cert ) . unwrap ( ) ; endpoint . default_client_config ( client_config . build ( ) ) ; let ( x , y ) = endpoint . bind ( & SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: LOCALHOST ) , 0 ) ) . unwrap ( ) ; ( x , y ) }
Construct an endpoint suitable for connecting to itself
Construct an endpoint suitable for connecting to itself