Skip to content

Commit

Permalink
fix!: remove --bearer-token
Browse files Browse the repository at this point in the history
  • Loading branch information
KisaragiEffective committed Apr 14, 2023
1 parent c864d8a commit 4d003e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
## How to run
```sh
cargo run -- \
--bearer-token=INSERT_YOUR_OWN_PASSWORD \
--http-host=127.0.0.1 \
--http-port=8080 \
--telnet-host=127.0.0.1 \
--telnet-port=12345
```

### 解説
* `--bearer-token`: 記事を更新するときのパスワードを設定する。このパスワードは使い回さないこと。このパスワードは永続化されないので、起動するたびに入力する必要がある
* `--bearer-token`: 廃止。標準入力から改行終端で与えること
* `--http-host`: HTTPサーバーのホスト。通常は`127.0.0.1`を指定して良い。
* `--http-port`: HTTPサーバーのポート番号。
* `--telnet-host`: telnetサーバーのホスト。通常は`127.0.0.1`を指定して良い。
* `--telnet-port`: telnetサーバーのポート番号。
* `--read-bearer-token-from-stdin`: 次のメジャーバージョンで廃止予定。このスイッチはもはや互換性のためだけに残されている。

### 動作させるにあたっての注意事項
* Cloudflareのトンネルを使っている場合、`--cloudflare`スイッチを付け足すこと。
Expand Down
15 changes: 3 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ struct Args {
#[derive(Subcommand)]
enum Commands {
Run {
/// DEPRECATED
#[clap(long)]
bearer_token: Option<String>,
#[clap(long)]
http_port: u16,
#[clap(long)]
Expand All @@ -50,6 +47,7 @@ enum Commands {
telnet_host: String,
#[clap(long = "cloudflare")]
cloudflare_support: bool,
/// DEPRECATED, It will be removed in next major version. This switch is no-op.
#[clap(long)]
read_bearer_token_from_stdin: bool,
},
Expand Down Expand Up @@ -86,25 +84,18 @@ async fn main() -> Result<()> {
let args: Args = Args::parse();
match args.subcommand {
Commands::Run {
bearer_token,
http_port,
http_host,
telnet_port,
telnet_host,
cloudflare_support,
read_bearer_token_from_stdin
} => {
let bearer_token = bearer_token.map_or_else(|| if read_bearer_token_from_stdin {
let bearer_token = {
let mut buf = String::new();
stdin().read_line(&mut buf).expect("failed to read from stdin");
buf.trim_end().to_string()
} else {
eprintln!("You must set bearer token to protecting your server.");
exit(1)
}, |token| {
eprintln!("--bearer-token is unsecure. It will be removed by next major release. Please use --read-bearer-token-from-stdin.");
token
});
};

WRITE_TOKEN.set(bearer_token).unwrap();

Expand Down

0 comments on commit 4d003e4

Please sign in to comment.