continue integrating with parity
This commit is contained in:
parent
fb68b0924a
commit
9e30d85fdc
@ -41,7 +41,7 @@ use ethcore_logger::Config as LogConfig;
|
|||||||
use dir::{self, Directories, default_hypervisor_path, default_local_path, default_data_path};
|
use dir::{self, Directories, default_hypervisor_path, default_local_path, default_data_path};
|
||||||
use dapps::Configuration as DappsConfiguration;
|
use dapps::Configuration as DappsConfiguration;
|
||||||
use ipfs::Configuration as IpfsConfiguration;
|
use ipfs::Configuration as IpfsConfiguration;
|
||||||
use secretstore::Configuration as SecretStoreConfiguration;
|
use secretstore::{Configuration as SecretStoreConfiguration, NodeSecretKey};
|
||||||
use updater::{UpdatePolicy, UpdateFilter, ReleaseTrack};
|
use updater::{UpdatePolicy, UpdateFilter, ReleaseTrack};
|
||||||
use run::RunCmd;
|
use run::RunCmd;
|
||||||
use blockchain::{BlockchainCmd, ImportBlockchain, ExportBlockchain, KillBlockchain, ExportState, DataFormat};
|
use blockchain::{BlockchainCmd, ImportBlockchain, ExportBlockchain, KillBlockchain, ExportState, DataFormat};
|
||||||
@ -995,10 +995,10 @@ impl Configuration {
|
|||||||
self.interface(&self.args.flag_secretstore_http_interface)
|
self.interface(&self.args.flag_secretstore_http_interface)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn secretstore_self_secret(&self) -> Result<Option<Secret>, String> {
|
fn secretstore_self_secret(&self) -> Result<Option<NodeSecretKey>, String> {
|
||||||
match self.args.flag_secretstore_secret {
|
match self.args.flag_secretstore_secret {
|
||||||
Some(ref s) => Ok(Some(s.parse()
|
Some(ref s) => Ok(Some(NodeSecretKey::Plain(s.parse()
|
||||||
.map_err(|e| format!("Invalid secret store secret: {}. Error: {:?}", s, e))?)),
|
.map_err(|e| format!("Invalid secret store secret: {}. Error: {:?}", s, e))?))),
|
||||||
None => Ok(None),
|
None => Ok(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,20 @@ use ethcore::client::Client;
|
|||||||
use ethkey::{Secret, Public};
|
use ethkey::{Secret, Public};
|
||||||
use helpers::replace_home;
|
use helpers::replace_home;
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
|
/// This node secret key.
|
||||||
|
pub enum NodeSecretKey {
|
||||||
|
/// Stored as plain text in configuration file.
|
||||||
|
Plain(Secret),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
/// Secret store configuration
|
/// Secret store configuration
|
||||||
pub struct Configuration {
|
pub struct Configuration {
|
||||||
/// Is secret store functionality enabled?
|
/// Is secret store functionality enabled?
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
/// This node secret.
|
/// This node secret.
|
||||||
pub self_secret: Option<Secret>,
|
pub self_secret: Option<NodeSecretKey>,
|
||||||
/// Other nodes IDs + addresses.
|
/// Other nodes IDs + addresses.
|
||||||
pub nodes: BTreeMap<Public, (String, u16)>,
|
pub nodes: BTreeMap<Public, (String, u16)>,
|
||||||
/// Interface to listen to
|
/// Interface to listen to
|
||||||
@ -66,9 +73,9 @@ mod server {
|
|||||||
#[cfg(feature="secretstore")]
|
#[cfg(feature="secretstore")]
|
||||||
mod server {
|
mod server {
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use ethcore_secretstore;
|
use ethcore_secretstore::{self, NodeKeyPair};
|
||||||
use ethkey::KeyPair;
|
use ethkey::KeyPair;
|
||||||
use super::{Configuration, Dependencies};
|
use super::{Configuration, Dependencies, NodeSecretKey};
|
||||||
|
|
||||||
/// Key server
|
/// Key server
|
||||||
pub struct KeyServer {
|
pub struct KeyServer {
|
||||||
@ -77,8 +84,13 @@ mod server {
|
|||||||
|
|
||||||
impl KeyServer {
|
impl KeyServer {
|
||||||
/// Create new key server
|
/// Create new key server
|
||||||
pub fn new(conf: Configuration, deps: Dependencies) -> Result<Self, String> {
|
pub fn new(mut conf: Configuration, deps: Dependencies) -> Result<Self, String> {
|
||||||
let self_secret = conf.self_secret.ok_or("self secret is required when using secretstore")?;
|
let self_secret = match conf.self_secret.take() {
|
||||||
|
Some(NodeSecretKey::Plain(secret)) => Arc::new(ethcore_secretstore::PlainNodeKeyPair::new(
|
||||||
|
KeyPair::from_secret(secret).map_err(|e| format!("invalid secret: {}", e))?)),
|
||||||
|
None => return Err("self secret is required when using secretstore".into()),
|
||||||
|
};
|
||||||
|
|
||||||
let mut conf = ethcore_secretstore::ServiceConfiguration {
|
let mut conf = ethcore_secretstore::ServiceConfiguration {
|
||||||
listener_address: ethcore_secretstore::NodeAddress {
|
listener_address: ethcore_secretstore::NodeAddress {
|
||||||
address: conf.http_interface.clone(),
|
address: conf.http_interface.clone(),
|
||||||
@ -99,12 +111,9 @@ mod server {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let self_key_pair = KeyPair::from_secret(self_secret.clone())
|
conf.cluster_config.nodes.insert(self_secret.public().clone(), conf.cluster_config.listener_address.clone());
|
||||||
.map_err(|e| format!("valid secret is required when using secretstore. Error: {}", e))?;
|
|
||||||
conf.cluster_config.nodes.insert(self_key_pair.public().clone(), conf.cluster_config.listener_address.clone());
|
|
||||||
|
|
||||||
let node_key_pair = Arc::new(ethcore_secretstore::PlainNodeKeyPair::new(self_key_pair));
|
let key_server = ethcore_secretstore::start(deps.client, self_secret, conf)
|
||||||
let key_server = ethcore_secretstore::start(deps.client, node_key_pair, conf)
|
|
||||||
.map_err(Into::<String>::into)?;
|
.map_err(Into::<String>::into)?;
|
||||||
|
|
||||||
Ok(KeyServer {
|
Ok(KeyServer {
|
||||||
|
Loading…
Reference in New Issue
Block a user