feat(main): relay override by environment variable

This commit is contained in:
xeruf 2024-07-27 22:40:52 +03:00
parent 93718aaf1e
commit 1b361355b0
1 changed files with 26 additions and 19 deletions

View File

@ -1,4 +1,4 @@
use std::env::args; use std::env::{args, var};
use std::fmt::Display; use std::fmt::Display;
use std::fs; use std::fs;
use std::fs::File; use std::fs::File;
@ -84,6 +84,11 @@ async fn main() {
let client = Client::new(&keys); let client = Client::new(&keys);
println!("My public key: {}", keys.public_key()); println!("My public key: {}", keys.public_key());
match var("MOSTR_RELAY") {
Ok(relay) => {
or_print(client.add_relay(relay).await);
}
_ => {
match File::open(&relayfile).map(|f| BufReader::new(f).lines().flatten()) { match File::open(&relayfile).map(|f| BufReader::new(f).lines().flatten()) {
Ok(lines) => { Ok(lines) => {
for line in lines { for line in lines {
@ -106,6 +111,8 @@ async fn main() {
}; };
} }
} }
}
}
//let proxy = Some(SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 9050))); //let proxy = Some(SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 9050)));
//client //client