Skip to content

Commit

Permalink
Fix openssl + support ~ (home) dir
Browse files Browse the repository at this point in the history
  • Loading branch information
pycanis committed Sep 21, 2024
1 parent 3509a4d commit c83335d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ clap = { version = "4.5.16", features = ["derive"] }
cron = "0.12.1"
env_logger = "0.11.5"
log = "0.4.22"
openssl = { version = "0.10", features = ["vendored"] }
reqwest = { version = "0.12.7", features = ["json"] }
serde = { version = "1.0.209", features = ["derive"] }
serde_json = "1.0.128"
Expand Down
1 change: 1 addition & 0 deletions Dockerfile-build
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM rust:1.81-slim-bullseye AS build

RUN apt-get update && apt-get install -y \
build-essential \
pkg-config \
libssl-dev

Expand Down
25 changes: 13 additions & 12 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::job::Job;
use log::error;
use serde::Deserialize;
use std::{fs, path::Path, process};
use std::{env, fs, path::Path, process};

const DEFAULT_CONFIG_PATH: &str = "config.yaml";

Expand Down Expand Up @@ -38,7 +38,7 @@ impl ValidConfig {
if !Path::new(path).exists() {
let default_config = r#"macaroon_path: "~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon"
cert_path: "~/.lnd/tls.cert"
server_url: "https://127.0.0.1:10009"
server_url: "https://localhost:10009"
jobs:
# - name: "My first job"
# schedule: "0 30 9,12,15 1,15 May-Aug Mon,Wed,Fri 2018/2"
Expand Down Expand Up @@ -81,18 +81,19 @@ jobs:
Some(jobs) => jobs.iter().map(|job| Job::new(job.to_owned())).collect(),
};

tonic_lnd::connect(
config.server_url.to_owned(),
config.cert_path.to_owned(),
config.macaroon_path.to_owned(),
)
.await
.expect("Failed to verify connection to LND node.");
let home_dir = env::var("HOME").unwrap_or("~".to_string());

let cert_path = config.cert_path.replacen("~", &home_dir, 1);
let macaroon_path = config.macaroon_path.replacen("~", &home_dir, 1);

tonic_lnd::connect(config.server_url.to_owned(), &cert_path, &macaroon_path)
.await
.expect("Failed to verify connection to LND node.");

Self {
cert_path: config.cert_path.to_owned(),
macaroon_path: config.macaroon_path.to_owned(),
server_url: config.server_url.to_owned(),
cert_path,
macaroon_path,
server_url: config.server_url,
jobs,
}
}
Expand Down

0 comments on commit c83335d

Please sign in to comment.