Skip to content

Commit

Permalink
Merge pull request #93 from who-biz/enc-data-parse-bugfix
Browse files Browse the repository at this point in the history
Revert ebox port changes, fixes encrypted data parsing error
  • Loading branch information
who-biz authored Aug 31, 2023
2 parents b2c3777 + 199bde6 commit b0678b9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
37 changes: 28 additions & 9 deletions impls/src/adapters/epicbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ use crate::libwallet::message::EncryptedMessage;
use crate::util::secp::key::PublicKey;

use crate::libwallet::wallet_lock;
use crate::libwallet::{address, Address, EpicboxAddress, TxProof};
use crate::libwallet::{
address, Address, EpicboxAddress, TxProof, DEFAULT_EPICBOX_PORT_443, DEFAULT_EPICBOX_PORT_80,
};
use crate::libwallet::{NodeClient, WalletInst, WalletLCProvider};

use crate::Error;
Expand Down Expand Up @@ -152,8 +154,16 @@ impl EpicboxListenChannel {
let url = {
let cloned_address = address.clone();
match epicbox_config.epicbox_protocol_unsecure.unwrap_or(false) {
true => format!("ws://{}:{}", cloned_address.domain, cloned_address.port),
false => format!("wss://{}:{}", cloned_address.domain, cloned_address.port),
true => format!(
"ws://{}:{}",
cloned_address.domain,
cloned_address.port.unwrap_or(DEFAULT_EPICBOX_PORT_80)
),
false => format!(
"wss://{}:{}",
cloned_address.domain,
cloned_address.port.unwrap_or(DEFAULT_EPICBOX_PORT_443)
),
}
};
let (tx, _rx): (Sender<bool>, Receiver<bool>) = channel();
Expand Down Expand Up @@ -238,10 +248,11 @@ impl EpicboxChannel {
.lock()
.listener(ListenerInterface::Epicbox)
.unwrap()
.publish(&vslate, &self.dest) {
Ok(_) => (),
Err(e) => return Err(e)
};
.publish(&vslate, &self.dest)
{
Ok(_) => (),
Err(e) => return Err(e),
};

let slate: Slate = VersionedSlate::into_version(slate.clone(), SlateVersion::V2).into();
Ok(slate)
Expand Down Expand Up @@ -282,8 +293,16 @@ where
let url = {
let cloned_address = address.clone();
match config.epicbox_protocol_unsecure.unwrap_or(false) {
true => format!("ws://{}:{}", cloned_address.domain, cloned_address.port),
false => format!("wss://{}:{}", cloned_address.domain, cloned_address.port),
true => format!(
"ws://{}:{}",
cloned_address.domain,
cloned_address.port.unwrap_or(DEFAULT_EPICBOX_PORT_80)
),
false => format!(
"wss://{}:{}",
cloned_address.domain,
cloned_address.port.unwrap_or(DEFAULT_EPICBOX_PORT_443)
),
}
};
debug!("Connecting to the epicbox server at {} ..", url.clone());
Expand Down
9 changes: 5 additions & 4 deletions libwallet/src/epicbox_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub enum AddressType {
pub struct EpicboxAddress {
pub public_key: String,
pub domain: String,
pub port: u16,
pub port: Option<u16>,
}

pub trait Address: Debug + Display {
Expand All @@ -58,7 +58,7 @@ impl EpicboxAddress {
Self {
public_key: public_key.to_base58_check(version_bytes()),
domain: domain.unwrap_or(DEFAULT_EPICBOX_DOMAIN.to_string()),
port: port.unwrap_or(DEFAULT_EPICBOX_PORT_443),
port: port,
}
}

Expand Down Expand Up @@ -101,9 +101,10 @@ impl Display for EpicboxAddress {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.public_key)?;
write!(f, "@{}", self.domain)?;
if self.port != DEFAULT_EPICBOX_PORT_443 {
write!(f, ":{}", self.port)?;
if self.port.is_some() && self.port.unwrap() != DEFAULT_EPICBOX_PORT_443 {
write!(f, ":{}", self.port.unwrap())?;
}

Ok(())
}
}
Expand Down

0 comments on commit b0678b9

Please sign in to comment.