Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

feat(http): add default values for --bits and --profile in ipfs init #502

Merged
merged 2 commits into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions http/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,18 @@ pub enum InitializationError {
pub fn init(
ipfs_path: &Path,
bits: NonZeroU16,
profiles: Vec<Profile>,
mut profiles: Vec<Profile>,
) -> Result<String, InitializationError> {
use multibase::Base::Base64Pad;
use prost::Message;
use std::fs::OpenOptions;
use std::io::{BufWriter, Write};

if profiles.len() != 1 {
unimplemented!("Multiple profiles are currently unsupported!")
}
match profiles.len() {
0 => profiles.push(Profile::Default),
1 => {}
_ => unimplemented!("Multiple profiles are currently unsupported!"),
};

let bits = bits.get();

Expand Down
6 changes: 3 additions & 3 deletions http/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ enum Options {
/// with two arguments by default, `--bits 1024` and `--profile test`.
Init {
/// Generated key length
#[structopt(long)]
#[structopt(long, default_value = "2048")]
bits: NonZeroU16,
/// List of configuration profiles to apply. Currently only the `Test` and `Default`
/// profiles are supported.
///
/// `Test` uses ephemeral ports (necessary for conformance tests), `Default` uses `4004`.
#[structopt(long, use_delimiter = true)]
#[structopt(long, use_delimiter = true, default_value = "default")]
profile: Vec<config::Profile>,
},
/// Start the IPFS node in the foreground (not detaching from parent process).
Expand Down Expand Up @@ -95,7 +95,7 @@ fn main() {
std::process::exit(1);
}
Err(config::InitializationError::InvalidRsaKeyLength(bits)) => {
eprintln!("Error: --bits out of range [1024, 16384]: {}", bits);
eprintln!("Error: --bits out of range [2048, 16384]: {}", bits);
Copy link
Collaborator

@koivunej koivunej Apr 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spotting! Unsure how this got left in, the 1024-bit rsa keys never worked with ring, which was an issue in the beginning as ipfs bootstrap nodes were using those.

eprintln!("This is a fake version of ipfs cli which does not support much");
std::process::exit(1);
}
Expand Down