⭐ new: add subcommand in ptth_relay to hash API keys from the terminal
							parent
							
								
									9ac44cfeb7
								
							
						
					
					
						commit
						1e160ec55b
					
				| 
						 | 
					@ -1228,6 +1228,7 @@ dependencies = [
 | 
				
			||||||
 "base64 0.12.3",
 | 
					 "base64 0.12.3",
 | 
				
			||||||
 "blake3",
 | 
					 "blake3",
 | 
				
			||||||
 "chrono",
 | 
					 "chrono",
 | 
				
			||||||
 | 
					 "clap",
 | 
				
			||||||
 "dashmap",
 | 
					 "dashmap",
 | 
				
			||||||
 "futures",
 | 
					 "futures",
 | 
				
			||||||
 "handlebars",
 | 
					 "handlebars",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,6 +11,7 @@ license = "AGPL-3.0"
 | 
				
			||||||
base64 = "0.12.3"
 | 
					base64 = "0.12.3"
 | 
				
			||||||
blake3 = "0.3.7"
 | 
					blake3 = "0.3.7"
 | 
				
			||||||
chrono = {version = "0.4.19", features = ["serde"]}
 | 
					chrono = {version = "0.4.19", features = ["serde"]}
 | 
				
			||||||
 | 
					clap = "2.33.3"
 | 
				
			||||||
dashmap = "3.11.10"
 | 
					dashmap = "3.11.10"
 | 
				
			||||||
futures = "0.3.7"
 | 
					futures = "0.3.7"
 | 
				
			||||||
handlebars = "3.5.1"
 | 
					handlebars = "3.5.1"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ use std::{
 | 
				
			||||||
	sync::Arc,
 | 
						sync::Arc,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use clap::{App, SubCommand};
 | 
				
			||||||
use tracing::{info};
 | 
					use tracing::{info};
 | 
				
			||||||
use tracing_subscriber::{
 | 
					use tracing_subscriber::{
 | 
				
			||||||
	fmt, 
 | 
						fmt, 
 | 
				
			||||||
| 
						 | 
					@ -29,12 +30,33 @@ async fn main () -> Result <(), Box <dyn Error>> {
 | 
				
			||||||
		.init ()
 | 
							.init ()
 | 
				
			||||||
	;
 | 
						;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
						let matches = App::new ("ptth_relay")
 | 
				
			||||||
 | 
							.author ("Trish")
 | 
				
			||||||
 | 
							.about ("Relay server for the PTTH backwards HTTP server")
 | 
				
			||||||
 | 
							.subcommand (SubCommand::with_name ("hash-api-key"))
 | 
				
			||||||
 | 
							.get_matches ();
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						if matches.subcommand_matches ("hash-api-key").is_some () {
 | 
				
			||||||
 | 
							use std::io;
 | 
				
			||||||
 | 
							use ptth_relay::key_validity::BlakeHashWrapper;
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							println! ("Enter key (it will be visible in the terminal)");
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							let mut key = String::new ();
 | 
				
			||||||
 | 
							io::stdin ().read_line (&mut key)?;
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							println! ("{}", BlakeHashWrapper::from_key (key.trim_end ().as_bytes ()).encode_base64 ());
 | 
				
			||||||
 | 
							return Ok (());
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	let config_path = PathBuf::from ("config/ptth_relay.toml");
 | 
						let config_path = PathBuf::from ("config/ptth_relay.toml");
 | 
				
			||||||
	let config = Config::from_file (&config_path).await?;
 | 
						let config = Config::from_file (&config_path).await?;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	match read_git_version ().await {
 | 
						if let Some (x) = read_git_version ().await {
 | 
				
			||||||
		Some (x) => info! ("ptth_relay Git version: {:?}", x),
 | 
							info! ("ptth_relay Git version: {:?}", x);
 | 
				
			||||||
		None => info! ("ptth_relay not built from Git"),
 | 
						}
 | 
				
			||||||
 | 
						else {
 | 
				
			||||||
 | 
							info! ("ptth_relay not built from Git");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	let (shutdown_rx, forced_shutdown) = ptth_core::graceful_shutdown::init_with_force ();
 | 
						let (shutdown_rx, forced_shutdown) = ptth_core::graceful_shutdown::init_with_force ();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue