Added CLI flags
This commit is contained in:
parent
451cf42452
commit
ad8e3f0230
@ -29,6 +29,7 @@ mod handler;
|
|||||||
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::net::{SocketAddr, IpAddr, Ipv4Addr};
|
||||||
use error::ServerError;
|
use error::ServerError;
|
||||||
use handler::{IpfsHandler, Out};
|
use handler::{IpfsHandler, Out};
|
||||||
use hyper::server::{Listening, Handler, Request, Response};
|
use hyper::server::{Listening, Handler, Request, Response};
|
||||||
@ -128,8 +129,8 @@ fn write_chunk<W: Write>(transport: &mut W, progress: &mut usize, data: &[u8]) -
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_server(client: Arc<BlockChainClient>) -> Result<Listening, ServerError> {
|
pub fn start_server(port: u16, client: Arc<BlockChainClient>) -> Result<Listening, ServerError> {
|
||||||
let addr = "0.0.0.0:5001".parse().expect("can't fail on static input; qed");
|
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), port);
|
||||||
|
|
||||||
Ok(
|
Ok(
|
||||||
hyper::Server::http(&addr)?
|
hyper::Server::http(&addr)?
|
||||||
|
@ -68,7 +68,7 @@ user = "test_user"
|
|||||||
pass = "test_pass"
|
pass = "test_pass"
|
||||||
|
|
||||||
[ipfs]
|
[ipfs]
|
||||||
disable = true
|
enable = false
|
||||||
port = 5001
|
port = 5001
|
||||||
|
|
||||||
[mining]
|
[mining]
|
||||||
|
@ -39,7 +39,7 @@ user = "username"
|
|||||||
pass = "password"
|
pass = "password"
|
||||||
|
|
||||||
[ipfs]
|
[ipfs]
|
||||||
disable = true
|
enable = false
|
||||||
port = 5001
|
port = 5001
|
||||||
|
|
||||||
[mining]
|
[mining]
|
||||||
|
@ -190,9 +190,9 @@ usage! {
|
|||||||
flag_dapps_apis_all: bool = false, or |_| None,
|
flag_dapps_apis_all: bool = false, or |_| None,
|
||||||
|
|
||||||
// IPFS
|
// IPFS
|
||||||
flag_ipfs_off: bool = true,
|
flag_ipfs_api: bool = false,
|
||||||
or |c: &Config| otry!(c.ipfs).disable.clone(),
|
or |c: &Config| otry!(c.ipfs).enable.clone(),
|
||||||
flag_ipfs_port: u16 = 5001u16,
|
flag_ipfs_api_port: u16 = 5001u16,
|
||||||
or |c: &Config| otry!(c.ipfs).port.clone(),
|
or |c: &Config| otry!(c.ipfs).port.clone(),
|
||||||
|
|
||||||
// -- Sealing/Mining Options
|
// -- Sealing/Mining Options
|
||||||
@ -418,7 +418,7 @@ struct Dapps {
|
|||||||
|
|
||||||
#[derive(Default, Debug, PartialEq, RustcDecodable)]
|
#[derive(Default, Debug, PartialEq, RustcDecodable)]
|
||||||
struct Ipfs {
|
struct Ipfs {
|
||||||
disable: Option<bool>,
|
enable: Option<bool>,
|
||||||
port: Option<u16>,
|
port: Option<u16>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,8 +651,8 @@ mod tests {
|
|||||||
flag_dapps_apis_all: false,
|
flag_dapps_apis_all: false,
|
||||||
|
|
||||||
// IPFS
|
// IPFS
|
||||||
flag_ipfs_off: true,
|
flag_ipfs_api: false,
|
||||||
flag_ipfs_port: 5001u16,
|
flag_ipfs_api_port: 5001u16,
|
||||||
|
|
||||||
// -- Sealing/Mining Options
|
// -- Sealing/Mining Options
|
||||||
flag_author: Some("0xdeadbeefcafe0000000000000000000000000001".into()),
|
flag_author: Some("0xdeadbeefcafe0000000000000000000000000001".into()),
|
||||||
@ -840,7 +840,7 @@ mod tests {
|
|||||||
pass: Some("password".into())
|
pass: Some("password".into())
|
||||||
}),
|
}),
|
||||||
ipfs: Some(Ipfs {
|
ipfs: Some(Ipfs {
|
||||||
disable: Some(true),
|
enable: Some(false),
|
||||||
port: Some(5001)
|
port: Some(5001)
|
||||||
}),
|
}),
|
||||||
mining: Some(Mining {
|
mining: Some(Mining {
|
||||||
|
@ -175,9 +175,9 @@ API and Console Options:
|
|||||||
--dapps-apis-all Expose all possible RPC APIs on Dapps port.
|
--dapps-apis-all Expose all possible RPC APIs on Dapps port.
|
||||||
WARNING: INSECURE. Used only for development.
|
WARNING: INSECURE. Used only for development.
|
||||||
(default: {flag_dapps_apis_all})
|
(default: {flag_dapps_apis_all})
|
||||||
--no-ipfs Disable IPFS-compatible HTTP API. (default: {flag_ipfs_off})
|
--ipfs-api Enable IPFS-compatible HTTP API. (default: {flag_ipfs_api})
|
||||||
--ipfs-port PORT Configure on which port the IPFS HTTP API should listen.
|
--ipfs-api-port PORT Configure on which port the IPFS HTTP API should listen.
|
||||||
(default: {flag_ipfs_port})
|
(default: {flag_ipfs_api_port})
|
||||||
|
|
||||||
Sealing/Mining Options:
|
Sealing/Mining Options:
|
||||||
--author ADDRESS Specify the block author (aka "coinbase") address
|
--author ADDRESS Specify the block author (aka "coinbase") address
|
||||||
|
@ -37,6 +37,7 @@ use params::{ResealPolicy, AccountsConfig, GasPricerConfig, MinerExtras};
|
|||||||
use ethcore_logger::Config as LogConfig;
|
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 signer::{Configuration as SignerConfiguration};
|
use signer::{Configuration as SignerConfiguration};
|
||||||
use updater::{UpdatePolicy, UpdateFilter, ReleaseTrack};
|
use updater::{UpdatePolicy, UpdateFilter, ReleaseTrack};
|
||||||
use run::RunCmd;
|
use run::RunCmd;
|
||||||
@ -118,6 +119,7 @@ impl Configuration {
|
|||||||
let geth_compatibility = self.args.flag_geth;
|
let geth_compatibility = self.args.flag_geth;
|
||||||
let ui_address = self.ui_port().map(|port| (self.ui_interface(), port));
|
let ui_address = self.ui_port().map(|port| (self.ui_interface(), port));
|
||||||
let dapps_conf = self.dapps_config();
|
let dapps_conf = self.dapps_config();
|
||||||
|
let ipfs_conf = self.ipfs_config();
|
||||||
let signer_conf = self.signer_config();
|
let signer_conf = self.signer_config();
|
||||||
let format = self.format()?;
|
let format = self.format()?;
|
||||||
|
|
||||||
@ -342,6 +344,7 @@ impl Configuration {
|
|||||||
ui_address: ui_address,
|
ui_address: ui_address,
|
||||||
net_settings: self.network_settings(),
|
net_settings: self.network_settings(),
|
||||||
dapps_conf: dapps_conf,
|
dapps_conf: dapps_conf,
|
||||||
|
ipfs_conf: ipfs_conf,
|
||||||
signer_conf: signer_conf,
|
signer_conf: signer_conf,
|
||||||
dapp: self.dapp_to_open()?,
|
dapp: self.dapp_to_open()?,
|
||||||
ui: self.args.cmd_ui,
|
ui: self.args.cmd_ui,
|
||||||
@ -539,6 +542,13 @@ impl Configuration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn ipfs_config(&self) -> IpfsConfiguration {
|
||||||
|
IpfsConfiguration {
|
||||||
|
enabled: self.args.flag_ipfs_api,
|
||||||
|
port: self.args.flag_ipfs_api_port,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn dapp_to_open(&self) -> Result<Option<String>, String> {
|
fn dapp_to_open(&self) -> Result<Option<String>, String> {
|
||||||
if !self.args.cmd_dapp {
|
if !self.args.cmd_dapp {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
@ -1101,6 +1111,7 @@ mod tests {
|
|||||||
ui_address: Some(("127.0.0.1".into(), 8180)),
|
ui_address: Some(("127.0.0.1".into(), 8180)),
|
||||||
net_settings: Default::default(),
|
net_settings: Default::default(),
|
||||||
dapps_conf: Default::default(),
|
dapps_conf: Default::default(),
|
||||||
|
ipfs_conf: Default::default(),
|
||||||
signer_conf: Default::default(),
|
signer_conf: Default::default(),
|
||||||
ui: false,
|
ui: false,
|
||||||
dapp: None,
|
dapp: None,
|
||||||
|
16
parity/ipfs.rs
Normal file
16
parity/ipfs.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
pub use parity_ipfs::start_server;
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
|
pub struct Configuration {
|
||||||
|
pub enabled: bool,
|
||||||
|
pub port: u16,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Configuration {
|
||||||
|
fn default() -> Self {
|
||||||
|
Configuration {
|
||||||
|
enabled: false,
|
||||||
|
port: 5001,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -56,7 +56,7 @@ extern crate ethcore_signer;
|
|||||||
extern crate ethcore_util as util;
|
extern crate ethcore_util as util;
|
||||||
extern crate ethsync;
|
extern crate ethsync;
|
||||||
extern crate parity_hash_fetch as hash_fetch;
|
extern crate parity_hash_fetch as hash_fetch;
|
||||||
extern crate parity_ipfs as ipfs;
|
extern crate parity_ipfs;
|
||||||
extern crate parity_reactor;
|
extern crate parity_reactor;
|
||||||
extern crate parity_updater as updater;
|
extern crate parity_updater as updater;
|
||||||
extern crate rpc_cli;
|
extern crate rpc_cli;
|
||||||
@ -88,6 +88,7 @@ mod cache;
|
|||||||
mod cli;
|
mod cli;
|
||||||
mod configuration;
|
mod configuration;
|
||||||
mod dapps;
|
mod dapps;
|
||||||
|
mod ipfs;
|
||||||
mod deprecated;
|
mod deprecated;
|
||||||
mod dir;
|
mod dir;
|
||||||
mod helpers;
|
mod helpers;
|
||||||
|
@ -94,6 +94,7 @@ pub struct RunCmd {
|
|||||||
pub ui_address: Option<(String, u16)>,
|
pub ui_address: Option<(String, u16)>,
|
||||||
pub net_settings: NetworkSettings,
|
pub net_settings: NetworkSettings,
|
||||||
pub dapps_conf: dapps::Configuration,
|
pub dapps_conf: dapps::Configuration,
|
||||||
|
pub ipfs_conf: ipfs::Configuration,
|
||||||
pub signer_conf: signer::Configuration,
|
pub signer_conf: signer::Configuration,
|
||||||
pub dapp: Option<String>,
|
pub dapp: Option<String>,
|
||||||
pub ui: bool,
|
pub ui: bool,
|
||||||
@ -422,7 +423,10 @@ pub fn execute(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>) -> R
|
|||||||
let signer_server = signer::start(cmd.signer_conf.clone(), signer_deps)?;
|
let signer_server = signer::start(cmd.signer_conf.clone(), signer_deps)?;
|
||||||
|
|
||||||
// the ipfs server
|
// the ipfs server
|
||||||
let ipfs_server = ipfs::start_server(client.clone())?;
|
let ipfs_server = match cmd.ipfs_conf.enabled {
|
||||||
|
true => Some(ipfs::start_server(cmd.ipfs_conf.port, client.clone())?),
|
||||||
|
false => None,
|
||||||
|
};
|
||||||
|
|
||||||
// the informant
|
// the informant
|
||||||
let informant = Arc::new(Informant::new(
|
let informant = Arc::new(Informant::new(
|
||||||
|
Loading…
Reference in New Issue
Block a user