From 4a5dce6c238aa85b8e20575339ff664727bb3c7d Mon Sep 17 00:00:00 2001 From: Mahdi Robatipoor Date: Mon, 18 Mar 2024 03:13:28 +0330 Subject: [PATCH] edit README file --- Makefile | 34 ++++++++++++++++++++++++++++++++++ README.md | 15 ++++++++------- api/settings/base.toml | 2 +- sdk/src/client.rs | 3 +-- 4 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e04f190 --- /dev/null +++ b/Makefile @@ -0,0 +1,34 @@ +.PHONY: local +local: + cargo build --release + +.PHONY: run +run: +ifndef ARGS + @echo Run "make run" with ARGS set to pass arguments… +endif + cargo run --release -- $(ARGS) + +.PHONY: build-linux +build-linux: + cargo build --target x86_64-unknown-linux-musl --release --locked + strip target/x86_64-unknown-linux-musl/release/api + upx --lzma target/x86_64-unknown-linux-musl/release/api + strip target/x86_64-unknown-linux-musl/release/cli + upx --lzma target/x86_64-unknown-linux-musl/release/cli + +.PHONY: build-win +build-win: + RUSTFLAGS="-C linker=x86_64-w64-mingw32-gcc" cargo build --target x86_64-pc-windows-gnu --release --locked + strip target/x86_64-pc-windows-gnu/release/api.exe + upx --lzma target/x86_64-pc-windows-gnu/release/api.exe + strip target/x86_64-pc-windows-gnu/release/cli.exe + upx --lzma target/x86_64-pc-windows-gnu/release/cli.exe + +.PHONY: build-mac +build-mac: + cargo build --target x86_64-apple-darwin --release --locked + strip target/x86_64-apple-darwin/release/api + upx --lzma target/x86_64-apple-darwin/release/api + strip target/x86_64-apple-darwin/release/cli + upx --lzma target/x86_64-apple-darwin/release/cli \ No newline at end of file diff --git a/README.md b/README.md index 3bf9a3d..a5576ea 100644 --- a/README.md +++ b/README.md @@ -40,14 +40,15 @@ $ cargo run --bin api **Run API Service via Docker** ```sh -# Build docker image +# Pull the image from the github registry and run container +$ docker run --name pf-api --rm -p 8080:8080 -d ghcr.io/robatipoor/pf-api:latest + +# Alternatively, if you need to configure the server with custom settings, +# edit api/settings/base.toml and then build the Docker image. $ docker build -t pf-api:latest -f api/Dockerfile . # Run Docker container on address 0.0.0.0:8080 $ docker run --name pf-api --rm -p 8080:8080 -d pf-api:latest - -# Alternatively, you can pull the image from the github registry and run container -$ docker run --name pf-api --rm -p 8080:8080 -d ghcr.io/robatipoor/pf-api:latest ``` **How to Use** @@ -125,7 +126,7 @@ port = 8080 domain_name = "localhost:8080" # Public IP address -public_addr = "192.168.100.130:8080" +public_addr = "192.168.1.1:8080" # TLS key file path file_tls_key_path = "key.pem" @@ -163,10 +164,10 @@ $ mv ~/.cargo/bin/cli ~/.cargo/bin/pf # Define an alias in the shell profile for 'pf' with server address $ alias pf="pf --server-addr http://localhost:8080" -# Copy a text content to the server with an expiration time of 10 minutes. +# Copy text content to the server with an expiration time of 10 minutes. $ echo 'Hello World!' | pf copy --expire "10 minute" -# Paste a text content to the file. +# Paste text content into the file. $ pf paste --url-path "{code}/{file_name}" > my_file.txt # Encrypt and upload a file and retrieve the corresponding download URL. diff --git a/api/settings/base.toml b/api/settings/base.toml index b4419fe..b791016 100644 --- a/api/settings/base.toml +++ b/api/settings/base.toml @@ -17,7 +17,7 @@ port = 8080 # Domain name URL domain_name = "localhost:8080" # Public IP address -public_addr = "127.0.0.1:8080" +public_addr = "192.168.1.1:8080" # TLS key file path file_tls_key_path = "key.pem" # TLS certificate file path diff --git a/sdk/src/client.rs b/sdk/src/client.rs index 1854320..98a630b 100644 --- a/sdk/src/client.rs +++ b/sdk/src/client.rs @@ -24,9 +24,8 @@ use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; use tokio_util::io::{ReaderStream, StreamReader}; pub static CLIENT: Lazy = Lazy::new(|| { - let disable_redirect = reqwest::redirect::Policy::custom(|attempt| attempt.stop()); reqwest::Client::builder() - .redirect(disable_redirect) + .redirect(reqwest::redirect::Policy::custom(|attempt| attempt.stop())) .build() .unwrap() });