From c5e467b0230c40e2e4876b4542a06fe5a52e0fc7 Mon Sep 17 00:00:00 2001 From: Ritesh Chitlangi Date: Fri, 12 Nov 2021 00:48:07 +0800 Subject: [PATCH] coupled socket shutdown with epp logout --- README.md | 2 +- epp-client/Cargo.toml | 1 - epp-client/src/connection/client.rs | 8 +++----- epp-client/src/connection/registry.rs | 4 ++-- epp-client/src/epp/request/contact/check.rs | 2 +- epp-client/src/epp/request/contact/create.rs | 2 +- epp-client/src/epp/request/contact/delete.rs | 2 +- epp-client/src/epp/request/contact/info.rs | 2 +- epp-client/src/epp/request/contact/update.rs | 2 +- epp-client/src/epp/request/domain/check.rs | 2 +- epp-client/src/epp/request/domain/create.rs | 2 +- epp-client/src/epp/request/domain/delete.rs | 2 +- epp-client/src/epp/request/domain/info.rs | 2 +- epp-client/src/epp/request/domain/renew.rs | 2 +- epp-client/src/epp/request/domain/rgp/report.rs | 2 +- epp-client/src/epp/request/domain/rgp/request.rs | 2 +- epp-client/src/epp/request/domain/transfer.rs | 10 +++++----- epp-client/src/epp/request/domain/update.rs | 2 +- epp-client/src/epp/request/host/check.rs | 2 +- epp-client/src/epp/request/host/create.rs | 2 +- epp-client/src/epp/request/host/delete.rs | 2 +- epp-client/src/epp/request/host/info.rs | 2 +- epp-client/src/epp/request/host/update.rs | 2 +- epp-client/src/epp/request/message/ack.rs | 2 +- epp-client/src/epp/request/message/poll.rs | 2 +- 25 files changed, 31 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 1435399..94325f7 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ async fn main() { .iter() .for_each(|chk| println!("Domain: {}, Available: {}", chk.domain.name, chk.domain.available)); - client.close().await.unwrap(); + client.logout().await.unwrap(); } ``` diff --git a/epp-client/Cargo.toml b/epp-client/Cargo.toml index ef674e4..59ba041 100644 --- a/epp-client/Cargo.toml +++ b/epp-client/Cargo.toml @@ -13,7 +13,6 @@ repository = "https://github.com/masalachai/epp-client" epp-client-macros = "0.1" # { path = "../epp-client-macros" } bytes = "1" chrono = "0.4" -futures = "0.3" env_logger = "0.9" log = "0.4" quick-xml = { version = "0.22", features = [ "serialize" ] } diff --git a/epp-client/src/connection/client.rs b/epp-client/src/connection/client.rs index f9b4eb6..8cf3bb9 100644 --- a/epp-client/src/connection/client.rs +++ b/epp-client/src/connection/client.rs @@ -184,12 +184,10 @@ impl EppClient { let client_tr_id = generate_client_tr_id(&self.credentials.0).unwrap(); let epp_logout = EppLogout::new(client_tr_id.as_str()); - self.transact::<_, EppLogoutResponse>(&epp_logout).await - } + let response = self.transact::<_, EppLogoutResponse>(&epp_logout).await?; - pub async fn close(&mut self) -> Result<(), error::Error> { - self.logout().await?; + self.connection.shutdown().await?; - Ok(self.connection.close().await?) + Ok(response) } } diff --git a/epp-client/src/connection/registry.rs b/epp-client/src/connection/registry.rs index beea771..f876bcd 100644 --- a/epp-client/src/connection/registry.rs +++ b/epp-client/src/connection/registry.rs @@ -127,8 +127,8 @@ impl EppConnection { Ok(response) } - /// Closes the socket - pub async fn close(&mut self) -> Result<(), Box> { + /// Closes the socket and shuts the connection + pub async fn shutdown(&mut self) -> Result<(), Box> { info!("{}: Closing connection", self.registry); self.stream.writer.shutdown().await?; diff --git a/epp-client/src/epp/request/contact/check.rs b/epp-client/src/epp/request/contact/check.rs index 4a35f23..7990248 100644 --- a/epp-client/src/epp/request/contact/check.rs +++ b/epp-client/src/epp/request/contact/check.rs @@ -52,7 +52,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppContactCheck = EppObject>; diff --git a/epp-client/src/epp/request/contact/create.rs b/epp-client/src/epp/request/contact/create.rs index 5297ec3..69709c8 100644 --- a/epp-client/src/epp/request/contact/create.rs +++ b/epp-client/src/epp/request/contact/create.rs @@ -69,7 +69,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppContactCreate = EppObject>; diff --git a/epp-client/src/epp/request/contact/delete.rs b/epp-client/src/epp/request/contact/delete.rs index 9e5ce94..d4bfbdf 100644 --- a/epp-client/src/epp/request/contact/delete.rs +++ b/epp-client/src/epp/request/contact/delete.rs @@ -53,7 +53,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppContactDelete = EppObject>; diff --git a/epp-client/src/epp/request/contact/info.rs b/epp-client/src/epp/request/contact/info.rs index 50a9da5..ea5ba75 100644 --- a/epp-client/src/epp/request/contact/info.rs +++ b/epp-client/src/epp/request/contact/info.rs @@ -55,7 +55,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppContactInfo = EppObject>; diff --git a/epp-client/src/epp/request/contact/update.rs b/epp-client/src/epp/request/contact/update.rs index 791b5b4..31fada9 100644 --- a/epp-client/src/epp/request/contact/update.rs +++ b/epp-client/src/epp/request/contact/update.rs @@ -65,7 +65,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppContactUpdate = EppObject>; diff --git a/epp-client/src/epp/request/domain/check.rs b/epp-client/src/epp/request/domain/check.rs index 8cdcfc0..5b02220 100644 --- a/epp-client/src/epp/request/domain/check.rs +++ b/epp-client/src/epp/request/domain/check.rs @@ -53,7 +53,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppDomainCheck = EppObject>; diff --git a/epp-client/src/epp/request/domain/create.rs b/epp-client/src/epp/request/domain/create.rs index 30cb38c..35034e2 100644 --- a/epp-client/src/epp/request/domain/create.rs +++ b/epp-client/src/epp/request/domain/create.rs @@ -73,7 +73,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppDomainCreate = EppObject>; diff --git a/epp-client/src/epp/request/domain/delete.rs b/epp-client/src/epp/request/domain/delete.rs index 7b47717..4af9730 100644 --- a/epp-client/src/epp/request/domain/delete.rs +++ b/epp-client/src/epp/request/domain/delete.rs @@ -50,7 +50,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppDomainDelete = EppObject>; diff --git a/epp-client/src/epp/request/domain/info.rs b/epp-client/src/epp/request/domain/info.rs index 986dff2..4249aed 100644 --- a/epp-client/src/epp/request/domain/info.rs +++ b/epp-client/src/epp/request/domain/info.rs @@ -50,7 +50,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppDomainInfo = EppObject>; diff --git a/epp-client/src/epp/request/domain/renew.rs b/epp-client/src/epp/request/domain/renew.rs index ab93915..efcf25f 100644 --- a/epp-client/src/epp/request/domain/renew.rs +++ b/epp-client/src/epp/request/domain/renew.rs @@ -57,7 +57,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppDomainRenew = EppObject>; diff --git a/epp-client/src/epp/request/domain/rgp/report.rs b/epp-client/src/epp/request/domain/rgp/report.rs index a1ac3b2..90e0a0e 100644 --- a/epp-client/src/epp/request/domain/rgp/report.rs +++ b/epp-client/src/epp/request/domain/rgp/report.rs @@ -80,7 +80,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppDomainRgpRestoreReport = diff --git a/epp-client/src/epp/request/domain/rgp/request.rs b/epp-client/src/epp/request/domain/rgp/request.rs index e4c89b0..e0f34d5 100644 --- a/epp-client/src/epp/request/domain/rgp/request.rs +++ b/epp-client/src/epp/request/domain/rgp/request.rs @@ -57,7 +57,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppDomainRgpRestoreRequest = diff --git a/epp-client/src/epp/request/domain/transfer.rs b/epp-client/src/epp/request/domain/transfer.rs index 3be1e2f..e4e0eeb 100644 --- a/epp-client/src/epp/request/domain/transfer.rs +++ b/epp-client/src/epp/request/domain/transfer.rs @@ -53,7 +53,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppDomainTransferRequest = EppObject>; @@ -103,7 +103,7 @@ pub type EppDomainTransferRequest = EppObject>; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppDomainTransferApprove = EppObject>; @@ -153,7 +153,7 @@ pub type EppDomainTransferApprove = EppObject>; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppDomainTransferReject = EppObject>; @@ -203,7 +203,7 @@ pub type EppDomainTransferReject = EppObject>; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppDomainTransferCancel = EppObject>; @@ -253,7 +253,7 @@ pub type EppDomainTransferCancel = EppObject>; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppDomainTransferQuery = EppObject>; diff --git a/epp-client/src/epp/request/domain/update.rs b/epp-client/src/epp/request/domain/update.rs index 52224c8..b3bb4ab 100644 --- a/epp-client/src/epp/request/domain/update.rs +++ b/epp-client/src/epp/request/domain/update.rs @@ -77,7 +77,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppDomainUpdate = EppObject>>; diff --git a/epp-client/src/epp/request/host/check.rs b/epp-client/src/epp/request/host/check.rs index 56ddafe..043b8e0 100644 --- a/epp-client/src/epp/request/host/check.rs +++ b/epp-client/src/epp/request/host/check.rs @@ -53,7 +53,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppHostCheck = EppObject>; diff --git a/epp-client/src/epp/request/host/create.rs b/epp-client/src/epp/request/host/create.rs index 7f868a5..6e08d9e 100644 --- a/epp-client/src/epp/request/host/create.rs +++ b/epp-client/src/epp/request/host/create.rs @@ -58,7 +58,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppHostCreate = EppObject>; diff --git a/epp-client/src/epp/request/host/delete.rs b/epp-client/src/epp/request/host/delete.rs index 8a85de3..228c898 100644 --- a/epp-client/src/epp/request/host/delete.rs +++ b/epp-client/src/epp/request/host/delete.rs @@ -50,7 +50,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppHostDelete = EppObject>; diff --git a/epp-client/src/epp/request/host/info.rs b/epp-client/src/epp/request/host/info.rs index bcfcfed..8633cff 100644 --- a/epp-client/src/epp/request/host/info.rs +++ b/epp-client/src/epp/request/host/info.rs @@ -50,7 +50,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppHostInfo = EppObject>; diff --git a/epp-client/src/epp/request/host/update.rs b/epp-client/src/epp/request/host/update.rs index d67445e..78478ad 100644 --- a/epp-client/src/epp/request/host/update.rs +++ b/epp-client/src/epp/request/host/update.rs @@ -74,7 +74,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppHostUpdate = EppObject>; diff --git a/epp-client/src/epp/request/message/ack.rs b/epp-client/src/epp/request/message/ack.rs index 46cfda8..63f22ee 100644 --- a/epp-client/src/epp/request/message/ack.rs +++ b/epp-client/src/epp/request/message/ack.rs @@ -48,7 +48,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppMessageAck = EppObject>; diff --git a/epp-client/src/epp/request/message/poll.rs b/epp-client/src/epp/request/message/poll.rs index 71d39a3..16f884a 100644 --- a/epp-client/src/epp/request/message/poll.rs +++ b/epp-client/src/epp/request/message/poll.rs @@ -49,7 +49,7 @@ use serde::{Deserialize, Serialize}; /// /// println!("{:?}", response); /// -/// client.close().await.unwrap(); +/// client.logout().await.unwrap(); /// } /// ``` pub type EppMessagePoll = EppObject>;