Compare commits

..

2 Commits

Author SHA1 Message Date
5cb2649eff Add change log
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
Signed-off-by: Jacob Kiers <code@kiers.eu>
2024-06-22 13:55:01 +02:00
e6ecdf5ed8 Add self update functionality
Signed-off-by: Jacob Kiers <code@kiers.eu>
2024-06-22 13:54:41 +02:00
5 changed files with 1006 additions and 4 deletions

42
CHANGELOG.md Normal file
View File

@ -0,0 +1,42 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [0.1.9] - 2024-06-22
### Deprecated
The ability to run `l4p` without arguments is now deprecated. Please use
`l4p serve` going forward.
### Added
* Added self update functionality. Just run `l4p update` to use it.
* Now keeping a change log in the `CHANGELOG.md` file.
### Changed
* Updated build pipeline to generate much smaller binaries
-------
## Previous versions
[unreleased]: https://code.kiers.eu/jjkiers/layer4-proxy/compare/v0.1.9...HEAD
[0.1.9]: https://code.kiers.eu/jjkiers/layer4-proxy/compare/v0.1.8...v0.1.9
Types of changes:
* `Added` for new features.
* `Changed` for changes in existing functionality.
* `Deprecated` for soon-to-be removed features.
* `Removed` for now removed features.
* `Fixed` for any bug fixes.
* `Security` in case of vulnerabilities.

923
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
[package] [package]
name = "l4p" name = "l4p"
version = "0.1.8" version = "0.1.9"
edition = "2021" edition = "2021"
authors = ["Jacob Kiers <code@kiers.eu>"] authors = ["Jacob Kiers <code@kiers.eu>"]
license = "Apache-2.0" license = "Apache-2.0"
@ -25,7 +25,9 @@ byte_string = "1"
bytes = "1.1" bytes = "1.1"
futures = "0.3" futures = "0.3"
log = "0.4" log = "0.4"
pico-args = "0.5.0"
pretty_env_logger = "0.5" pretty_env_logger = "0.5"
self_update = { version = "0.40.0", features = ["rustls"] }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.9.21" serde_yaml = "0.9.21"
time = { version = "0.3.1", features = ["local-offset", "formatting"] } time = { version = "0.3.1", features = ["local-offset", "formatting"] }

View File

@ -1,14 +1,33 @@
mod config; mod config;
mod servers; mod servers;
mod update;
mod upstreams; mod upstreams;
use crate::config::ConfigV1; use crate::config::ConfigV1;
use crate::servers::Server; use crate::servers::Server;
use log::{debug, error, info}; use log::{debug, error, info};
use pico_args::Arguments;
use std::path::PathBuf; use std::path::PathBuf;
fn main() { fn main() {
let mut args = Arguments::from_env();
match args.subcommand().expect("Unexpected error").as_deref() {
Some("serve") => serve(),
Some("update") => update::update(),
Some(cmd) => {
eprintln!("Invalid command: {cmd}");
std::process::exit(1);
}
None => {
eprintln!("Calling l4p without argument is deprecated now. Please use: l4p serve");
serve();
}
}
}
fn serve() {
let config_path = match find_config() { let config_path = match find_config() {
Ok(p) => p, Ok(p) => p,
Err(paths) => { Err(paths) => {

22
src/update.rs Normal file
View File

@ -0,0 +1,22 @@
use self_update::{cargo_crate_version, version};
pub(crate) fn update() {
println!("Updating to the latest version...");
let backend = self_update::backends::gitea::Update::configure()
.with_host("https://code.kiers.eu")
.repo_owner("jjkiers")
.repo_name("layer4-proxy")
.bin_name("l4p")
.show_download_progress(true)
.current_version(cargo_crate_version!())
.build()
.expect("Should initialize correctly.");
let status = backend.update_extended();
match status {
Err(e) => eprintln!("Error updating: {e}"),
Ok(_) => (),
}
}