Merge pull request #28 from FoxFromDarkness66/patch-2
Add bind address CL option
This commit is contained in:
commit
465873e095
3 changed files with 18 additions and 6 deletions
11
README.MD
11
README.MD
|
@ -105,14 +105,14 @@ Remember, MicroBin will create your database and file storage wherever you execu
|
|||
|
||||
`cd ~/microbin/`
|
||||
|
||||
`microbin --port 8080 --highlightsyntax --editable`
|
||||
`microbin --highlightsyntax --editable`
|
||||
|
||||
### From AUR (for any Arch-based distro)
|
||||
Install `microbin` package from AUR and start/enable microbin systemd service. Systemd will start server on port 8080, which can be [changed](https://wiki.archlinux.org/title/Systemd#Editing_providd_units) via `systemctl edit microbin`. By default, almost all functions are enabled, and data is stored in `/var/lib/microbin`
|
||||
|
||||
### Building MicroBin
|
||||
|
||||
Simply clone the repository, build it with `cargo build --release` and run the `microbin` executable in the created `target/release/` directory. It will start on port 8080. You can change the port with `-p` or `--port` CL arguments. For other arguments see [the Wiki](https://github.com/szabodanika/microbin/wiki).
|
||||
Simply clone the repository, build it with `cargo build --release` and run the `microbin` executable in the created `target/release/` directory. It will start listening on 0.0.0.0:8080. You can change the port or bind address with CL arguments `-p (--port)` or `-b (--bind)` respectively . For other arguments see [the Wiki](https://github.com/szabodanika/microbin/wiki).
|
||||
|
||||
```
|
||||
git clone https://github.com/szabodanika/microbin.git
|
||||
|
@ -286,6 +286,13 @@ Default value: 8080
|
|||
|
||||
Sets the port for the server will be listening on.
|
||||
|
||||
|
||||
### -b, --bind [ADDRESS]
|
||||
|
||||
Default value: 0.0.0.0
|
||||
|
||||
Sets the bind address for the server will be listening on. Both ipv4 and ipv6 are supported.
|
||||
|
||||
### --private
|
||||
|
||||
Enables private pastas. Adds a new checkbox to make your pasta private, which then won't show up on the pastalist page. With the URL to your pasta, it will still be accessible.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use std::net::IpAddr;
|
||||
use clap::Parser;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
|
@ -36,7 +37,10 @@ pub struct Args {
|
|||
pub highlightsyntax: bool,
|
||||
|
||||
#[clap(short, long, default_value_t = 8080)]
|
||||
pub port: u32,
|
||||
pub port: u16,
|
||||
|
||||
#[clap(short, long, default_value_t = IpAddr::from([0, 0, 0, 0]))]
|
||||
pub bind: IpAddr,
|
||||
|
||||
#[clap(long)]
|
||||
pub private: bool,
|
||||
|
@ -55,4 +59,4 @@ pub struct Args {
|
|||
|
||||
#[clap(long)]
|
||||
pub wide: bool,
|
||||
}
|
||||
}
|
|
@ -58,7 +58,8 @@ async fn main() -> std::io::Result<()> {
|
|||
.init();
|
||||
|
||||
log::info!(
|
||||
"MicroBin starting on http://127.0.0.1:{}",
|
||||
"MicroBin starting on http://{}:{}",
|
||||
ARGS.bind.to_string(),
|
||||
ARGS.port.to_string()
|
||||
);
|
||||
|
||||
|
@ -97,7 +98,7 @@ async fn main() -> std::io::Result<()> {
|
|||
HttpAuthentication::basic(util::auth::auth_validator),
|
||||
))
|
||||
})
|
||||
.bind(format!("0.0.0.0:{}", ARGS.port.to_string()))?
|
||||
.bind((ARGS.bind, ARGS.port))?
|
||||
.workers(ARGS.threads as usize)
|
||||
.run()
|
||||
.await
|
||||
|
|
Loading…
Reference in a new issue