Merge branch 'master' into ui-2

This commit is contained in:
Jaco Greeff 2017-05-12 17:19:50 +02:00
commit 9bc82543ee
6 changed files with 97 additions and 25 deletions

2
Cargo.lock generated
View File

@ -1783,7 +1783,7 @@ dependencies = [
[[package]] [[package]]
name = "parity-ui-precompiled" name = "parity-ui-precompiled"
version = "1.4.0" version = "1.4.0"
source = "git+https://github.com/paritytech/js-precompiled.git#d370bad71ec9c573828136f7b64f893173cdacee" source = "git+https://github.com/paritytech/js-precompiled.git#1be3eaa4cefa85e25b48ac5e8cf579c92108e562"
dependencies = [ dependencies = [
"parity-dapps-glue 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-dapps-glue 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]

View File

@ -49,33 +49,25 @@
//! //!
//! ```bash //! ```bash
//! //!
//! # install multirust //! # install rustup
//! curl -sf https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh | sh -s -- --yes //! curl https://sh.rustup.rs -sSf | sh
//!
//! # export rust LIBRARY_PATH
//! export LIBRARY_PATH=/usr/local/lib
//! //!
//! # download and build parity //! # download and build parity
//! git clone https://github.com/paritytech/parity //! git clone https://github.com/paritytech/parity
//! cd parity //! cd parity
//! multirust override beta
//! cargo build --release //! cargo build --release
//! ``` //! ```
//! //!
//! - OSX: //! - OSX:
//! //!
//! ```bash //! ```bash
//! # install rocksdb && multirust //! # install rocksdb && rustup
//! brew update //! brew update
//! brew install multirust //! curl https://sh.rustup.rs -sSf | sh
//!
//! # export rust LIBRARY_PATH
//! export LIBRARY_PATH=/usr/local/lib
//! //!
//! # download and build parity //! # download and build parity
//! git clone https://github.com/paritytech/parity //! git clone https://github.com/paritytech/parity
//! cd parity //! cd parity
//! multirust override beta
//! cargo build --release //! cargo build --release
//! ``` //! ```

View File

@ -1,6 +1,6 @@
{ {
"name": "parity.js", "name": "parity.js",
"version": "1.7.74", "version": "1.7.75",
"main": "release/index.js", "main": "release/index.js",
"jsnext:main": "src/index.js", "jsnext:main": "src/index.js",
"author": "Parity Team <admin@parity.io>", "author": "Parity Team <admin@parity.io>",
@ -46,7 +46,7 @@
"ci:build:npm": "NODE_ENV=production webpack --config webpack/npm", "ci:build:npm": "NODE_ENV=production webpack --config webpack/npm",
"ci:build:jsonrpc": "babel-node ./scripts/build-rpc-json.js --output .npmjs/jsonrpc", "ci:build:jsonrpc": "babel-node ./scripts/build-rpc-json.js --output .npmjs/jsonrpc",
"ci:build:embed": "NODE_ENV=production EMBED=1 node webpack/embed", "ci:build:embed": "NODE_ENV=production EMBED=1 node webpack/embed",
"start": "npm install && npm run build:lib && npm run build:dll && npm run start:app", "start": "npm run clean && npm install && npm run build:lib && npm run build:dll && npm run start:app",
"start:app": "node webpack/dev.server", "start:app": "node webpack/dev.server",
"clean": "rm -rf ./.build ./.coverage ./.happypack ./.npmjs ./build ./node_modules/.cache ./node_modules/@parity", "clean": "rm -rf ./.build ./.coverage ./.happypack ./.npmjs ./build ./node_modules/.cache ./node_modules/@parity",
"coveralls": "npm run testCoverage && coveralls < coverage/lcov.info", "coveralls": "npm run testCoverage && coveralls < coverage/lcov.info",

View File

@ -90,9 +90,9 @@ Account Options:
UI Options: UI Options:
--force-ui Enable Trusted UI WebSocket endpoint, --force-ui Enable Trusted UI WebSocket endpoint,
even when --unlock is in use. (default: ${flag_force_ui}) even when --unlock is in use. (default: {flag_force_ui})
--no-ui Disable Trusted UI WebSocket endpoint. --no-ui Disable Trusted UI WebSocket endpoint.
(default: ${flag_no_ui}) (default: {flag_no_ui})
--ui-port PORT Specify the port of Trusted UI server --ui-port PORT Specify the port of Trusted UI server
(default: {flag_ui_port}). (default: {flag_ui_port}).
--ui-interface IP Specify the hostname portion of the Trusted UI --ui-interface IP Specify the hostname portion of the Trusted UI

View File

@ -411,7 +411,7 @@ pub fn execute(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>) -> R
); );
info!("Operating mode: {}", Colour::White.bold().paint(format!("{}", mode))); info!("Operating mode: {}", Colour::White.bold().paint(format!("{}", mode)));
// display warning about using experimental journaldb alorithm // display warning about using experimental journaldb algorithm
if !algorithm.is_stable() { if !algorithm.is_stable() {
warn!("Your chosen strategy is {}! You can re-run with --pruning to change.", Colour::Red.bold().paint("unstable")); warn!("Your chosen strategy is {}! You can re-run with --pruning to change.", Colour::Red.bold().paint("unstable"));
} }

View File

@ -16,7 +16,7 @@
use std::io; use std::io;
use std::time; use std::time;
use std::sync::Arc; use std::sync::{Arc, Weak};
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::collections::{BTreeMap, BTreeSet, VecDeque}; use std::collections::{BTreeMap, BTreeSet, VecDeque};
use std::collections::btree_map::Entry; use std::collections::btree_map::Entry;
@ -27,8 +27,8 @@ use parking_lot::{RwLock, Mutex};
use tokio_io::IoFuture; use tokio_io::IoFuture;
use tokio_core::reactor::{Handle, Remote, Interval}; use tokio_core::reactor::{Handle, Remote, Interval};
use tokio_core::net::{TcpListener, TcpStream}; use tokio_core::net::{TcpListener, TcpStream};
use ethkey::{Secret, KeyPair, Signature, Random, Generator}; use ethkey::{Public, Secret, KeyPair, Signature, Random, Generator};
use key_server_cluster::{Error, NodeId, SessionId, AclStorage, KeyStorage}; use key_server_cluster::{Error, NodeId, SessionId, AclStorage, KeyStorage, DocumentEncryptedKeyShadow};
use key_server_cluster::message::{self, Message, ClusterMessage, EncryptionMessage, DecryptionMessage}; use key_server_cluster::message::{self, Message, ClusterMessage, EncryptionMessage, DecryptionMessage};
use key_server_cluster::decryption_session::{SessionImpl as DecryptionSessionImpl, SessionState as DecryptionSessionState, use key_server_cluster::decryption_session::{SessionImpl as DecryptionSessionImpl, SessionState as DecryptionSessionState,
SessionParams as DecryptionSessionParams, Session as DecryptionSession, DecryptionSessionId}; SessionParams as DecryptionSessionParams, Session as DecryptionSession, DecryptionSessionId};
@ -236,6 +236,28 @@ pub struct Connection {
last_message_time: Mutex<time::Instant>, last_message_time: Mutex<time::Instant>,
} }
/// Encryption session implementation, which removes session from cluster on drop.
struct EncryptionSessionWrapper {
/// Wrapped session.
session: Arc<EncryptionSession>,
/// Session Id.
session_id: SessionId,
/// Cluster data reference.
cluster: Weak<ClusterData>,
}
/// Decryption session implementation, which removes session from cluster on drop.
struct DecryptionSessionWrapper {
/// Wrapped session.
session: Arc<DecryptionSession>,
/// Session Id.
session_id: SessionId,
/// Session sub id.
access_key: Secret,
/// Cluster data reference.
cluster: Weak<ClusterData>,
}
impl ClusterCore { impl ClusterCore {
pub fn new(handle: Handle, config: ClusterConfiguration) -> Result<Arc<Self>, Error> { pub fn new(handle: Handle, config: ClusterConfiguration) -> Result<Arc<Self>, Error> {
let listen_address = make_socket_address(&config.listen_address.0, config.listen_address.1)?; let listen_address = make_socket_address(&config.listen_address.0, config.listen_address.1)?;
@ -1011,9 +1033,9 @@ impl ClusterClient for ClusterClientImpl {
connected_nodes.insert(self.data.self_key_pair.public().clone()); connected_nodes.insert(self.data.self_key_pair.public().clone());
let cluster = Arc::new(ClusterView::new(self.data.clone(), connected_nodes.clone())); let cluster = Arc::new(ClusterView::new(self.data.clone(), connected_nodes.clone()));
let session = self.data.sessions.new_encryption_session(self.data.self_key_pair.public().clone(), session_id, cluster)?; let session = self.data.sessions.new_encryption_session(self.data.self_key_pair.public().clone(), session_id.clone(), cluster)?;
session.initialize(threshold, connected_nodes)?; session.initialize(threshold, connected_nodes)?;
Ok(session) Ok(EncryptionSessionWrapper::new(Arc::downgrade(&self.data), session_id, session))
} }
fn new_decryption_session(&self, session_id: SessionId, requestor_signature: Signature, is_shadow_decryption: bool) -> Result<Arc<DecryptionSession>, Error> { fn new_decryption_session(&self, session_id: SessionId, requestor_signature: Signature, is_shadow_decryption: bool) -> Result<Arc<DecryptionSession>, Error> {
@ -1022,9 +1044,9 @@ impl ClusterClient for ClusterClientImpl {
let access_key = Random.generate()?.secret().clone(); let access_key = Random.generate()?.secret().clone();
let cluster = Arc::new(ClusterView::new(self.data.clone(), connected_nodes.clone())); let cluster = Arc::new(ClusterView::new(self.data.clone(), connected_nodes.clone()));
let session = self.data.sessions.new_decryption_session(self.data.self_key_pair.public().clone(), session_id, access_key, cluster)?; let session = self.data.sessions.new_decryption_session(self.data.self_key_pair.public().clone(), session_id, access_key.clone(), cluster)?;
session.initialize(requestor_signature, is_shadow_decryption)?; session.initialize(requestor_signature, is_shadow_decryption)?;
Ok(session) Ok(DecryptionSessionWrapper::new(Arc::downgrade(&self.data), session_id, access_key, session))
} }
#[cfg(test)] #[cfg(test)]
@ -1043,6 +1065,64 @@ impl ClusterClient for ClusterClientImpl {
} }
} }
impl EncryptionSessionWrapper {
pub fn new(cluster: Weak<ClusterData>, session_id: SessionId, session: Arc<EncryptionSession>) -> Arc<Self> {
Arc::new(EncryptionSessionWrapper {
session: session,
session_id: session_id,
cluster: cluster,
})
}
}
impl EncryptionSession for EncryptionSessionWrapper {
fn state(&self) -> EncryptionSessionState {
self.session.state()
}
fn wait(&self, timeout: Option<time::Duration>) -> Result<Public, Error> {
self.session.wait(timeout)
}
#[cfg(test)]
fn joint_public_key(&self) -> Option<Result<Public, Error>> {
self.session.joint_public_key()
}
}
impl Drop for EncryptionSessionWrapper {
fn drop(&mut self) {
if let Some(cluster) = self.cluster.upgrade() {
cluster.sessions.remove_encryption_session(&self.session_id);
}
}
}
impl DecryptionSessionWrapper {
pub fn new(cluster: Weak<ClusterData>, session_id: SessionId, access_key: Secret, session: Arc<DecryptionSession>) -> Arc<Self> {
Arc::new(DecryptionSessionWrapper {
session: session,
session_id: session_id,
access_key: access_key,
cluster: cluster,
})
}
}
impl DecryptionSession for DecryptionSessionWrapper {
fn wait(&self) -> Result<DocumentEncryptedKeyShadow, Error> {
self.session.wait()
}
}
impl Drop for DecryptionSessionWrapper {
fn drop(&mut self) {
if let Some(cluster) = self.cluster.upgrade() {
cluster.sessions.remove_decryption_session(&self.session_id, &self.access_key);
}
}
}
fn make_socket_address(address: &str, port: u16) -> Result<SocketAddr, Error> { fn make_socket_address(address: &str, port: u16) -> Result<SocketAddr, Error> {
let ip_address: IpAddr = address.parse().map_err(|_| Error::InvalidNodeAddress)?; let ip_address: IpAddr = address.parse().map_err(|_| Error::InvalidNodeAddress)?;
Ok(SocketAddr::new(ip_address, port)) Ok(SocketAddr::new(ip_address, port))