call to epp logout made explicit and Drop impl removed
This commit is contained in:
parent
d0c553cebb
commit
e07eba2de2
|
@ -95,6 +95,8 @@ async fn main() {
|
||||||
response.data.res_data.unwrap().check_data.domain_list
|
response.data.res_data.unwrap().check_data.domain_list
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|chk| println!("Domain: {}, Available: {}", chk.domain.name, chk.domain.available));
|
.for_each(|chk| println!("Domain: {}, Available: {}", chk.domain.name, chk.domain.available));
|
||||||
|
|
||||||
|
client.close().await.unwrap();
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,8 @@ use std::{fs, io};
|
||||||
/// Paths to the client certificate and client key PEM files
|
/// Paths to the client certificate and client key PEM files
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct EppClientTlsFiles {
|
pub struct EppClientTlsFiles {
|
||||||
cert_chain: String,
|
pub cert_chain: String,
|
||||||
key: String,
|
pub key: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Connection details to connect to and authenticate with a registry
|
/// Connection details to connect to and authenticate with a registry
|
||||||
|
|
|
@ -46,7 +46,6 @@
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use futures::executor::block_on;
|
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
use std::{error::Error, fmt::Debug};
|
use std::{error::Error, fmt::Debug};
|
||||||
|
|
||||||
|
@ -187,10 +186,10 @@ impl EppClient {
|
||||||
|
|
||||||
self.transact::<_, EppLogoutResponse>(&epp_logout).await
|
self.transact::<_, EppLogoutResponse>(&epp_logout).await
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl Drop for EppClient {
|
pub async fn close(&mut self) -> Result<(), error::Error> {
|
||||||
fn drop(&mut self) {
|
self.logout().await?;
|
||||||
let _ = block_on(self.logout());
|
|
||||||
|
Ok(self.connection.close().await?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
//! Manages registry connections and reading/writing to them
|
//! Manages registry connections and reading/writing to them
|
||||||
|
|
||||||
use bytes::BytesMut;
|
use bytes::BytesMut;
|
||||||
use futures::executor::block_on;
|
|
||||||
use rustls::{OwnedTrustAnchor, RootCertStore};
|
use rustls::{OwnedTrustAnchor, RootCertStore};
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
@ -129,7 +128,7 @@ impl EppConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Closes the socket
|
/// Closes the socket
|
||||||
async fn close(&mut self) -> Result<(), Box<dyn Error>> {
|
pub async fn close(&mut self) -> Result<(), Box<dyn Error>> {
|
||||||
info!("{}: Closing connection", self.registry);
|
info!("{}: Closing connection", self.registry);
|
||||||
|
|
||||||
self.stream.writer.shutdown().await?;
|
self.stream.writer.shutdown().await?;
|
||||||
|
@ -137,12 +136,6 @@ impl EppConnection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for EppConnection {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
let _ = block_on(self.close());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Establishes a TLS connection to a registry and returns a ConnectionStream instance containing the
|
/// Establishes a TLS connection to a registry and returns a ConnectionStream instance containing the
|
||||||
/// socket stream to read/write to the connection
|
/// socket stream to read/write to the connection
|
||||||
pub async fn epp_connect(
|
pub async fn epp_connect(
|
||||||
|
|
|
@ -51,6 +51,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppContactCheckResponse>(&contact_check).await.unwrap();
|
/// let response = client.transact::<_, EppContactCheckResponse>(&contact_check).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppContactCheck = EppObject<Command<ContactCheck>>;
|
pub type EppContactCheck = EppObject<Command<ContactCheck>>;
|
||||||
|
|
|
@ -68,6 +68,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppContactCreateResponse>(&contact_create).await.unwrap();
|
/// let response = client.transact::<_, EppContactCreateResponse>(&contact_create).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppContactCreate = EppObject<Command<ContactCreate>>;
|
pub type EppContactCreate = EppObject<Command<ContactCreate>>;
|
||||||
|
|
|
@ -52,6 +52,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppContactDeleteResponse>(&contact_delete).await.unwrap();
|
/// let response = client.transact::<_, EppContactDeleteResponse>(&contact_delete).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppContactDelete = EppObject<Command<ContactDelete>>;
|
pub type EppContactDelete = EppObject<Command<ContactDelete>>;
|
||||||
|
|
|
@ -54,6 +54,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppContactInfoResponse>(&contact_info).await.unwrap();
|
/// let response = client.transact::<_, EppContactInfoResponse>(&contact_info).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppContactInfo = EppObject<Command<ContactInfo>>;
|
pub type EppContactInfo = EppObject<Command<ContactInfo>>;
|
||||||
|
|
|
@ -64,6 +64,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppContactUpdateResponse>(&contact_update).await.unwrap();
|
/// let response = client.transact::<_, EppContactUpdateResponse>(&contact_update).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppContactUpdate = EppObject<Command<ContactUpdate>>;
|
pub type EppContactUpdate = EppObject<Command<ContactUpdate>>;
|
||||||
|
|
|
@ -52,6 +52,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppDomainCheckResponse>(&domain_check).await.unwrap();
|
/// let response = client.transact::<_, EppDomainCheckResponse>(&domain_check).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppDomainCheck = EppObject<Command<DomainCheck>>;
|
pub type EppDomainCheck = EppObject<Command<DomainCheck>>;
|
||||||
|
|
|
@ -72,6 +72,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppDomainCreateResponse>(&domain_create).await.unwrap();
|
/// let response = client.transact::<_, EppDomainCreateResponse>(&domain_create).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppDomainCreate = EppObject<Command<DomainCreate>>;
|
pub type EppDomainCreate = EppObject<Command<DomainCreate>>;
|
||||||
|
|
|
@ -49,6 +49,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppDomainDeleteResponse>(&domain_delete).await.unwrap();
|
/// let response = client.transact::<_, EppDomainDeleteResponse>(&domain_delete).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppDomainDelete = EppObject<Command<DomainDelete>>;
|
pub type EppDomainDelete = EppObject<Command<DomainDelete>>;
|
||||||
|
|
|
@ -49,6 +49,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppDomainInfoResponse>(&domain_info).await.unwrap();
|
/// let response = client.transact::<_, EppDomainInfoResponse>(&domain_info).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppDomainInfo = EppObject<Command<DomainInfo>>;
|
pub type EppDomainInfo = EppObject<Command<DomainInfo>>;
|
||||||
|
|
|
@ -56,6 +56,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppDomainRenewResponse>(&domain_renew).await.unwrap();
|
/// let response = client.transact::<_, EppDomainRenewResponse>(&domain_renew).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppDomainRenew = EppObject<Command<DomainRenew>>;
|
pub type EppDomainRenew = EppObject<Command<DomainRenew>>;
|
||||||
|
|
|
@ -79,6 +79,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppDomainRgpRestoreReportResponse>(&domain_restore_report).await.unwrap();
|
/// let response = client.transact::<_, EppDomainRgpRestoreReportResponse>(&domain_restore_report).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppDomainRgpRestoreReport =
|
pub type EppDomainRgpRestoreReport =
|
||||||
|
|
|
@ -56,6 +56,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppDomainRgpRestoreRequestResponse>(&domain_restore_req).await.unwrap();
|
/// let response = client.transact::<_, EppDomainRgpRestoreRequestResponse>(&domain_restore_req).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppDomainRgpRestoreRequest =
|
pub type EppDomainRgpRestoreRequest =
|
||||||
|
|
|
@ -52,6 +52,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppDomainTransferRequestResponse>(&domain_transfer_request).await.unwrap();
|
/// let response = client.transact::<_, EppDomainTransferRequestResponse>(&domain_transfer_request).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppDomainTransferRequest = EppObject<Command<DomainTransfer>>;
|
pub type EppDomainTransferRequest = EppObject<Command<DomainTransfer>>;
|
||||||
|
@ -100,6 +102,8 @@ pub type EppDomainTransferRequest = EppObject<Command<DomainTransfer>>;
|
||||||
/// let response = client.transact::<_, EppDomainTransferApproveResponse>(&domain_transfer_approve).await.unwrap();
|
/// let response = client.transact::<_, EppDomainTransferApproveResponse>(&domain_transfer_approve).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppDomainTransferApprove = EppObject<Command<DomainTransfer>>;
|
pub type EppDomainTransferApprove = EppObject<Command<DomainTransfer>>;
|
||||||
|
@ -148,6 +152,8 @@ pub type EppDomainTransferApprove = EppObject<Command<DomainTransfer>>;
|
||||||
/// let response = client.transact::<_, EppDomainTransferRejectResponse>(&domain_transfer_reject).await.unwrap();
|
/// let response = client.transact::<_, EppDomainTransferRejectResponse>(&domain_transfer_reject).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppDomainTransferReject = EppObject<Command<DomainTransfer>>;
|
pub type EppDomainTransferReject = EppObject<Command<DomainTransfer>>;
|
||||||
|
@ -196,6 +202,8 @@ pub type EppDomainTransferReject = EppObject<Command<DomainTransfer>>;
|
||||||
/// let response = client.transact::<_, EppDomainTransferCancelResponse>(&domain_transfer_cancel).await.unwrap();
|
/// let response = client.transact::<_, EppDomainTransferCancelResponse>(&domain_transfer_cancel).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppDomainTransferCancel = EppObject<Command<DomainTransfer>>;
|
pub type EppDomainTransferCancel = EppObject<Command<DomainTransfer>>;
|
||||||
|
@ -244,6 +252,8 @@ pub type EppDomainTransferCancel = EppObject<Command<DomainTransfer>>;
|
||||||
/// let response = client.transact::<_, EppDomainTransferQueryResponse>(&domain_transfer_query).await.unwrap();
|
/// let response = client.transact::<_, EppDomainTransferQueryResponse>(&domain_transfer_query).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppDomainTransferQuery = EppObject<Command<DomainTransfer>>;
|
pub type EppDomainTransferQuery = EppObject<Command<DomainTransfer>>;
|
||||||
|
|
|
@ -76,6 +76,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppDomainUpdateResponse>(&domain_update).await.unwrap();
|
/// let response = client.transact::<_, EppDomainUpdateResponse>(&domain_update).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppDomainUpdate = EppObject<Command<DomainUpdate<HostObjList>>>;
|
pub type EppDomainUpdate = EppObject<Command<DomainUpdate<HostObjList>>>;
|
||||||
|
|
|
@ -52,6 +52,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppHostCheckResponse>(&host_check).await.unwrap();
|
/// let response = client.transact::<_, EppHostCheckResponse>(&host_check).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppHostCheck = EppObject<Command<HostCheck>>;
|
pub type EppHostCheck = EppObject<Command<HostCheck>>;
|
||||||
|
|
|
@ -57,6 +57,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppHostCreateResponse>(&host_create).await.unwrap();
|
/// let response = client.transact::<_, EppHostCreateResponse>(&host_create).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppHostCreate = EppObject<Command<HostCreate>>;
|
pub type EppHostCreate = EppObject<Command<HostCreate>>;
|
||||||
|
|
|
@ -49,6 +49,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppHostDeleteResponse>(&host_delete).await.unwrap();
|
/// let response = client.transact::<_, EppHostDeleteResponse>(&host_delete).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppHostDelete = EppObject<Command<HostDelete>>;
|
pub type EppHostDelete = EppObject<Command<HostDelete>>;
|
||||||
|
|
|
@ -49,6 +49,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppHostInfoResponse>(&host_info).await.unwrap();
|
/// let response = client.transact::<_, EppHostInfoResponse>(&host_info).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppHostInfo = EppObject<Command<HostInfo>>;
|
pub type EppHostInfo = EppObject<Command<HostInfo>>;
|
||||||
|
|
|
@ -73,6 +73,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppHostUpdateResponse>(&host_update).await.unwrap();
|
/// let response = client.transact::<_, EppHostUpdateResponse>(&host_update).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppHostUpdate = EppObject<Command<HostUpdate>>;
|
pub type EppHostUpdate = EppObject<Command<HostUpdate>>;
|
||||||
|
|
|
@ -47,6 +47,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppMessageAckResponse>(&message_ack).await.unwrap();
|
/// let response = client.transact::<_, EppMessageAckResponse>(&message_ack).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppMessageAck = EppObject<Command<MessageAck>>;
|
pub type EppMessageAck = EppObject<Command<MessageAck>>;
|
||||||
|
|
|
@ -48,6 +48,8 @@ use serde::{Deserialize, Serialize};
|
||||||
/// let response = client.transact::<_, EppMessagePollResponse>(&message_poll).await.unwrap();
|
/// let response = client.transact::<_, EppMessagePollResponse>(&message_poll).await.unwrap();
|
||||||
///
|
///
|
||||||
/// println!("{:?}", response);
|
/// println!("{:?}", response);
|
||||||
|
///
|
||||||
|
/// client.close().await.unwrap();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub type EppMessagePoll = EppObject<Command<MessagePoll>>;
|
pub type EppMessagePoll = EppObject<Command<MessagePoll>>;
|
||||||
|
|
Loading…
Reference in New Issue