Skip to content

Commit

Permalink
Farcasterd: Use socket addr for tor control address
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCharlatan committed Dec 27, 2022
1 parent 2334e14 commit 8419754
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
use crate::{AccordantBlockchain, ArbitratingBlockchain, Error};
use farcaster_core::blockchain::Network;
use internet2::addr::InetSocketAddr;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
use std::str::FromStr;
use std::{fs::File, net::SocketAddr};

use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -141,15 +141,15 @@ impl Config {

/// Returns the addr of the tor control socket if it is set, or the default
/// socket at localhost:9051 if not.
pub fn get_tor_control_socket(&self) -> Result<InetSocketAddr, Error> {
pub fn get_tor_control_socket(&self) -> Result<SocketAddr, Error> {
if let Some(FarcasterdConfig {
tor_control_socket: Some(addr),
..
}) = &self.farcasterd
{
Ok(InetSocketAddr::from_str(addr)?)
Ok(SocketAddr::from_str(addr)?)
} else {
Ok(InetSocketAddr::from_str("127.0.0.1:9051")?)
Ok(SocketAddr::from_str("127.0.0.1:9051")?)
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ pub enum Error {
#[from]
Inet2AddrParseError(internet2::addr::AddrParseError),

/// Net socket address parsing errors
#[display(inner)]
#[from]
SocketAddrError(std::net::AddrParseError),

/// Tonic gRPC deamon transport errors
#[display(inner)]
#[from]
Expand Down
2 changes: 1 addition & 1 deletion src/farcasterd/tor_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::bus::HiddenServiceInfo;
pub fn create_v3_onion_service(
bind_addr: InetSocketAddr,
public_port: u16,
control_addr: InetSocketAddr,
control_addr: SocketAddr,
existing_hidden_services: &Vec<HiddenServiceInfo>,
) -> Result<OnionAddressV3, ConnError> {
use tokio::runtime::Builder;
Expand Down

0 comments on commit 8419754

Please sign in to comment.