From 46d588dcaed45a537fca28150d0803b5e4d76e66 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 19 Jun 2016 12:28:24 +0200 Subject: [PATCH 1/2] CLI option and colour. --- parity/cli.rs | 3 +++ parity/main.rs | 7 +++++++ parity/signer.rs | 5 +++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/parity/cli.rs b/parity/cli.rs index 6fe38224a..94eaaed13 100644 --- a/parity/cli.rs +++ b/parity/cli.rs @@ -109,6 +109,8 @@ API and Console Options: [default: 8180]. --signer-path PATH Specify directory where Signer UIs tokens should be stored. [default: $HOME/.parity/signer] + --no-token By default a new system UI security token will be + output on start up. This will prevent it. Sealing/Mining Options: --force-sealing Force the node to author new blocks as if it were @@ -255,6 +257,7 @@ pub struct Args { pub flag_signer: bool, pub flag_signer_port: u16, pub flag_signer_path: String, + pub flag_no_token: bool, pub flag_force_sealing: bool, pub flag_author: String, pub flag_usd_per_tx: String, diff --git a/parity/main.rs b/parity/main.rs index 973b1174f..6ac07741c 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -186,6 +186,13 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig) let net_settings = conf.net_settings(&spec); let sync_config = conf.sync_config(&spec); + // Create and display a new token for UIs. + if conf.args.flag_signer && !conf.args.flag_no_token { + new_token(conf.directories().signer).unwrap_or_else(|e| { + die!("Error generating token: {:?}", e) + }); + } + // Secret Store let account_service = Arc::new(conf.account_service()); diff --git a/parity/signer.rs b/parity/signer.rs index 3c8dceb6b..e280b0441 100644 --- a/parity/signer.rs +++ b/parity/signer.rs @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +extern crate ansi_term; +use self::ansi_term::Colour::Red; use std::io; use std::path::PathBuf; use std::sync::Arc; @@ -65,8 +67,7 @@ pub fn new_token(path: String) -> io::Result<()> { let mut codes = try!(signer::AuthCodes::from_file(&path)); let code = try!(codes.generate_new()); try!(codes.to_file(&path)); - println!("New token has been generated. Copy the code below to your Signer UI:"); - println!("{}", code); + println!("This key code will authorise your System Signer UI: {}", White.bold().paint(code)); Ok(()) } From 7430cf72e27deca1eed047527475398e57e16c61 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 19 Jun 2016 12:29:39 +0200 Subject: [PATCH 2/2] Minor typo. --- parity/signer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parity/signer.rs b/parity/signer.rs index e280b0441..f15d8c97b 100644 --- a/parity/signer.rs +++ b/parity/signer.rs @@ -15,7 +15,7 @@ // along with Parity. If not, see . extern crate ansi_term; -use self::ansi_term::Colour::Red; +use self::ansi_term::Colour::White; use std::io; use std::path::PathBuf; use std::sync::Arc;