From 84fefcda094e571e7b6d818b203736633d448518 Mon Sep 17 00:00:00 2001 From: lemonsh Date: Fri, 12 May 2023 19:39:46 +0200 Subject: [PATCH] change occurences of 'code' to 'password' --- connectbox/examples/port_forwards.rs | 6 +++--- connectbox/src/error.rs | 2 +- connectbox/src/lib.rs | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/connectbox/examples/port_forwards.rs b/connectbox/examples/port_forwards.rs index f170057..3955428 100644 --- a/connectbox/examples/port_forwards.rs +++ b/connectbox/examples/port_forwards.rs @@ -1,5 +1,5 @@ // This example shows you how to add, edit and remove port forwading entries. -// Usage: cargo run --example port_forwards -- +// Usage: cargo run --example port_forwards -- use std::{env, net::Ipv4Addr}; @@ -16,7 +16,7 @@ async fn main() -> Result<()> { let mut args = env::args().skip(1); let ip = args.next().expect("no ip specified"); - let code = args.next().expect("no code specified"); + let password = args.next().expect("no password specified"); let local_ip: Ipv4Addr = args .next() .expect("no local ip specified") @@ -24,7 +24,7 @@ async fn main() -> Result<()> { .expect("local ip is not a valid ipv4 address"); // first, we create a new API client and log in to the router. - let connect_box = ConnectBox::new(ip, code, true)?; + let connect_box = ConnectBox::new(ip, password, true)?; connect_box.login().await?; // then, we remove all port forwarding entries for the local ip diff --git a/connectbox/src/error.rs b/connectbox/src/error.rs index 6dbd253..4832922 100644 --- a/connectbox/src/error.rs +++ b/connectbox/src/error.rs @@ -6,7 +6,7 @@ pub enum Error { #[error("session token not found, are you logged in?")] NoSessionToken, #[error("incorrect password")] - IncorrectCode, + IncorrectPassword, #[error("unexpected response from the server: {0:?}")] UnexpectedResponse(String), #[error("you are not logged in, or perhaps the session has expired")] diff --git a/connectbox/src/lib.rs b/connectbox/src/lib.rs index 6bd2444..99eb6b1 100644 --- a/connectbox/src/lib.rs +++ b/connectbox/src/lib.rs @@ -26,7 +26,7 @@ type Field<'a, 'b> = (Cow<'a, str>, Cow<'b, str>); /// The entry point of the library - the API client pub struct ConnectBox { http: Client, - code: String, + password: String, cookie_store: Arc, base_url: Url, getter_url: Url, @@ -36,9 +36,9 @@ pub struct ConnectBox { impl ConnectBox { /// Create a new client associated with the specified address. You must call [`login`](Self::login()) before use. - /// * `code` - the router password + /// * `password` - the router password /// * `auto_reauth` - whether to automatically re-authenticate when the session expires - pub fn new(address: impl Display, code: String, auto_reauth: bool) -> Result { + pub fn new(address: impl Display, password: String, auto_reauth: bool) -> Result { let cookie_store = Arc::new(Jar::default()); let http = Client::builder() .user_agent("Mozilla/5.0") @@ -50,7 +50,7 @@ impl ConnectBox { let setter_url = base_url.join("xml/setter.xml")?; Ok(ConnectBox { http, - code, + password, cookie_store, base_url, getter_url, @@ -139,7 +139,7 @@ impl ConnectBox { ("token".into(), session_token.into()), ("fun".into(), functions::LOGIN.to_string().into()), ("Username".into(), "NULL".into()), - ("Password".into(), (&self.code).into()), + ("Password".into(), (&self.password).into()), ]; let req = self.http.post(self.setter_url.clone()).form(form); let resp = req.send().await?; @@ -155,7 +155,7 @@ impl ConnectBox { } let resp_text = resp.text().await?; if resp_text == "idloginincorrect" { - return Err(Error::IncorrectCode); + return Err(Error::IncorrectPassword); } let sid = resp_text .strip_prefix("successful;SID=")