add config path env variable
This commit is contained in:
1 parent
d8618261d2
commit
090b6cb7e5
3 files changed
+14
-9
No files matched your search
@@ -1,7 +1,7 @@
|
||||
with import <nixpkgs> {};
|
||||
let
|
||||
unstable = import
|
||||
(fetchTarball https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz) {};
|
||||
(fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz") {};
|
||||
in
|
||||
mkShell {
|
||||
buildInputs = [
|
||||
|
||||
+6
-6
@@ -68,6 +68,12 @@ impl Client {
|
||||
}
|
||||
|
||||
pub async fn run(&self, mut transport: Transport, id: PrivateIdentity) {
|
||||
// create in destination
|
||||
let in_destination = transport
|
||||
.add_destination(id, DestinationName::new("rns_vpn", "client")).await;
|
||||
let in_destination_hash = in_destination.lock().await.desc.address_hash;
|
||||
log::info!("created destination: {}",
|
||||
format!("{}", in_destination_hash).trim_matches('/'));
|
||||
// set up peer map
|
||||
let peer_map = {
|
||||
let mut peer_map = BTreeMap::<IpAddr, Peer>::new();
|
||||
@@ -84,12 +90,6 @@ impl Client {
|
||||
}
|
||||
tokio::sync::Mutex::new(peer_map)
|
||||
};
|
||||
// create in destination
|
||||
let in_destination = transport
|
||||
.add_destination(id, DestinationName::new("rns_vpn", "client")).await;
|
||||
let in_destination_hash = in_destination.lock().await.desc.address_hash;
|
||||
log::info!("created destination: {}",
|
||||
format!("{}", in_destination_hash).trim_matches('/'));
|
||||
// send announces
|
||||
let announce_loop = async || loop {
|
||||
transport.send_announce(&in_destination, None).await;
|
||||
|
||||
+7
-2
@@ -15,7 +15,7 @@ use x25519_dalek;
|
||||
|
||||
use rns_vpn;
|
||||
|
||||
const CONFIG_PATH: &str = "Config.toml";
|
||||
const DEFAULT_CONFIG_PATH: &str = "Config.toml";
|
||||
|
||||
/// Command line arguments
|
||||
#[derive(Parser)]
|
||||
@@ -38,7 +38,12 @@ async fn main() -> Result<(), process::ExitCode> {
|
||||
let cmd = Command::parse();
|
||||
// load config
|
||||
let config: rns_vpn::Config = {
|
||||
let s = fs::read_to_string(CONFIG_PATH).unwrap();
|
||||
let path = if let Ok(path) = std::env::var("RNS_VPN_CONFIG_PATH") {
|
||||
path
|
||||
} else {
|
||||
DEFAULT_CONFIG_PATH.to_string()
|
||||
};
|
||||
let s = fs::read_to_string(path).unwrap();
|
||||
toml::from_str(&s).unwrap()
|
||||
};
|
||||
// init logging
|
||||
|
||||
Reference in new issue
Block a user