diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2022-11-04 00:49:49 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2022-11-04 00:49:49 -0700 |
commit | 6c5c1e84b3540e3a4da81334f34b4e53cc818f4d (patch) | |
tree | 140cd3963067c2e529dbee0fc3d2869adb9204e4 /adenosine-pds/src/bin/adenosine-pds.rs | |
parent | ed47a0bc0d1d6692c7c365bf33a69d8017129f96 (diff) | |
download | adenosine-6c5c1e84b3540e3a4da81334f34b4e53cc818f4d.tar.gz adenosine-6c5c1e84b3540e3a4da81334f34b4e53cc818f4d.zip |
pds: more progress
Diffstat (limited to 'adenosine-pds/src/bin/adenosine-pds.rs')
-rw-r--r-- | adenosine-pds/src/bin/adenosine-pds.rs | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/adenosine-pds/src/bin/adenosine-pds.rs b/adenosine-pds/src/bin/adenosine-pds.rs index ce36587..beb423a 100644 --- a/adenosine-pds/src/bin/adenosine-pds.rs +++ b/adenosine-pds/src/bin/adenosine-pds.rs @@ -43,8 +43,17 @@ struct Opt { enum Command { /// Start ATP server as a foreground process Serve { - #[structopt(long, default_value = "3030")] + /// Localhost port to listen on + #[structopt(long, default_value = "3030", env = "ATP_PDS_PORT")] port: u16, + + /// Secret key, encoded in hex. Use 'generate-secret' to create a new one + #[structopt( + long = "--pds-secret-key", + env = "ATP_PDS_SECRET_KEY", + hide_env_values = true + )] + pds_secret_key: String, }, /// Helper to import an IPLD CARv1 file in to sqlite data store @@ -53,11 +62,15 @@ enum Command { car_path: std::path::PathBuf, /// name of pointer to root of CAR DAG tree. Usually a DID + #[structopt(long, default_value = "last-import")] alias: String, }, /// Helper to print MST keys/docs from a sqlite repo Inspect, + + /// Generate a PDS secret key and print to stdout (as hex) + GenerateSecret, } fn main() -> Result<()> { @@ -82,14 +95,23 @@ fn main() -> Result<()> { debug!("config parsed, starting up"); match opt.cmd { - Command::Serve { port } => { + Command::Serve { + port, + pds_secret_key, + } => { // TODO: log some config stuff? - run_server(port, &opt.blockstore_db_path, &opt.atp_db_path) + let keypair = KeyPair::from_hex(&pds_secret_key)?; + run_server(port, &opt.blockstore_db_path, &opt.atp_db_path, keypair) } // TODO: handle alias Command::Import { car_path, alias } => { - load_car_to_sqlite(&opt.blockstore_db_path, &car_path) + load_car_to_sqlite(&opt.blockstore_db_path, &car_path, &alias) } Command::Inspect {} => mst::dump_mst_keys(&opt.blockstore_db_path), + Command::GenerateSecret {} => { + let keypair = KeyPair::new_random(); + println!("{}", keypair.to_hex()); + Ok(()) + } } } |