diff --git a/CHANGELOG.md b/CHANGELOG.md index 91dbf43..fd233a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,43 +4,4 @@ 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.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] -### Added -- `document` API for creating Gemini documents -- preliminary timeout API, incl a special case for complex MIMEs by [@Alch-Emi] -- `Response::success_*` variants by [@Alch-Emi] -- `redirect_temporary_lossy` for `Response` and `ResponseHeader` -- `bad_request_lossy` for `Response` and `ResponseHeader` -- support for a lot more mime-types in `guess_mime_from_path`, backed by the `mime_guess` crate -- customizable TLS cert & key paths by [@Alch-Emi] -- `server_dir` default feature for serve_dir utils [@Alch-Emi] -- Docments can be converted into responses with std::convert::Into [@Alch-Emi] -- Added ratelimiting API [@Alch-Emi] -### Improved -- build time and size by [@Alch-Emi] -- Improved error handling in serve_dir [@Alch-Emi] -### Changed -- Added route API [@Alch-Emi](https://github.com/Alch-Emi) -- API for adding handlers now accepts async handlers [@Alch-Emi](https://github.com/Alch-Emi) -- `Response::success` now takes a request body [@Alch-Emi] - -## [0.3.0] - 2020-11-14 -### Added -- `GEMINI_MIME_STR`, the `&str` representation of the Gemini MIME -- `Meta::new_lossy`, constructor that never fails -- `Meta::MAX_LEN`, which is `1024` -- "lossy" constructors for `Response` and `Status` (see `Meta::new_lossy`) - -### Changed -- `Meta::new` now rejects strings exceeding `Meta::MAX_LEN` (`1024`) -- Some `Response` and `Status` constructors are now infallible -- Improve error messages - -### Deprecated -- Instead of `gemini_mime()` use `GEMINI_MIME` - -## [0.2.0] - 2020-11-14 -### Added -- Access to client certificates by [@Alch-Emi] - -[@Alch-Emi]: https://github.com/Alch-Emi +As of yet no versions have been released diff --git a/Cargo.toml b/Cargo.toml index 6362ef0..0d80a93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,11 @@ [package] -name = "northstar" +name = "kochab" version = "0.3.1" -authors = ["panicbit "] +authors = ["Emii Tatsuo ", "panicbit "] edition = "2018" -license = "MIT OR Apache-2.0" -description = "Gemini server implementation" -repository = "https://github.com/panicbit/northstar" -documentation = "https://docs.rs/northstar" +license = "Hippocratic 2.1" +description = "Ergonomic Gemini SDK" +repository = "https://github.com/Alch-Emi/kochab" [features] user_management = ["sled", "bincode", "serde/derive", "crc32fast"] diff --git a/README.md b/README.md index 6a06f9b..b6a4b1f 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,23 @@ ``` - __ __ __ - ____ ____ _____/ /_/ /_ _____/ /_____ ______ - / __ \/ __ \/ ___/ __/ __ \/ ___/ __/ __ `/ ___/ - / / / / /_/ / / / /_/ / / (__ ) /_/ /_/ / / -/_/ /_/\____/_/ \__/_/ /_/____/\__/\__,_/_/ + *. ,.-*,,.. + .` `. .,-'` ````--*,,,.. + .` ;*` ```''-o + * ,' __ __ __ + `. ,' / /______ _____/ /_ ____ _/ /_ + ⭐ / //_/ __ \/ ___/ __ \/ __ `/ __ \ + / ,< / /_/ / /__/ / / / /_/ / /_/ / + /_/|_|\____/\___/_/ /_/\__,_/_.___/ ``` +# kochab -- [Documentation](https://docs.rs/northstar) -- [GitHub](https://github.com/panicbit/northstar) +Kochab is an extension & a fork of the Gemini SDK [northstar]. Where northstar creates an efficient and flexible foundation for Gemini projects, kochab seeks to be as ergonomic and intuitive as possible, making it possible to get straight into getting your ideas into geminispace, with no worrying about needing to build the tools to get there. # Usage -Add the latest version of northstar to your `Cargo.toml`. - -## Manually +It is currently only possible to use kochab through it's git repo, although it may wind up on crates.rs someday. ```toml -northstar = "0.3.0" # check crates.io for the latest version -``` - -## Automatically - -```sh -cargo add northstar +kochab = { git = "https://github.com/Alch-Emi/kochab.git" } ``` # Generating a key & certificate @@ -35,3 +30,5 @@ openssl req -x509 -nodes -newkey rsa:4096 -keyout key.pem -out cert.pem -days 36 and enter your domain name (e.g. "localhost" for testing) as Common Name (CN). Alternatively, if you want to include multiple domains add something like `-addext "subjectAltName = DNS:localhost, DNS:example.org"`. + +[northstar]: https://github.com/panicbit/northstar "Northstar GitHub" diff --git a/examples/certificates.rs b/examples/certificates.rs index 5cf997c..a5ca78b 100644 --- a/examples/certificates.rs +++ b/examples/certificates.rs @@ -1,7 +1,7 @@ use anyhow::*; use log::LevelFilter; use tokio::sync::RwLock; -use northstar::{Certificate, GEMINI_PORT, Request, Response, Server}; +use kochab::{Certificate, GEMINI_PORT, Request, Response, Server}; use std::collections::HashMap; use std::sync::Arc; @@ -11,7 +11,7 @@ type CertBytes = Vec; #[tokio::main] async fn main() -> Result<()> { env_logger::builder() - .filter_module("northstar", LevelFilter::Debug) + .filter_module("kochab", LevelFilter::Debug) .init(); let users = Arc::>>::default(); diff --git a/examples/document.rs b/examples/document.rs index 5ea2678..a3d3a6c 100644 --- a/examples/document.rs +++ b/examples/document.rs @@ -1,33 +1,36 @@ use anyhow::*; use log::LevelFilter; -use northstar::{Server, Response, GEMINI_PORT, Document}; -use northstar::document::HeadingLevel::*; +use kochab::{Server, Response, GEMINI_PORT, Document}; +use kochab::document::HeadingLevel::*; #[tokio::main] async fn main() -> Result<()> { env_logger::builder() - .filter_module("northstar", LevelFilter::Debug) + .filter_module("kochab", LevelFilter::Debug) .init(); let response: Response = Document::new() - .add_preformatted(include_str!("northstar_logo.txt")) + .add_preformatted_with_alt("kochab", include_str!("kochab_logo.txt")) .add_blank_line() - .add_link("https://docs.rs/northstar", "Documentation") - .add_link("https://github.com/panicbit/northstar", "GitHub") + .add_text( + concat!( + "Kochab is an extension & a fork of the Gemini SDK [northstar]. Where", + " northstar creates an efficient and flexible foundation for Gemini projects,", + " kochab seeks to be as ergonomic and intuitive as possible, making it", + " possible to get straight into getting your ideas into geminispace, with no", + " worrying about needing to build the tools to get there." + ) + ) .add_blank_line() - .add_heading(H1, "Usage") + .add_link("https://github.com/Alch-Emi/kochab", "GitHub") .add_blank_line() - .add_text("Add the latest version of northstar to your `Cargo.toml`.") + .add_heading(H2, "Usage") .add_blank_line() - .add_heading(H2, "Manually") + .add_text("Add the latest version of kochab to your `Cargo.toml`.") .add_blank_line() - .add_preformatted_with_alt("toml", r#"northstar = "0.3.0" # check crates.io for the latest version"#) + .add_preformatted_with_alt("toml", r#"kochab = { git = "https://github.com/Alch-Emi/kochab.git" }"#) .add_blank_line() - .add_heading(H2, "Automatically") - .add_blank_line() - .add_preformatted_with_alt("sh", "cargo add northstar") - .add_blank_line() - .add_heading(H1, "Generating a key & certificate") + .add_heading(H2, "Generating a key & certificate") .add_blank_line() .add_preformatted_with_alt("sh", concat!( "mkdir cert && cd cert\n", diff --git a/examples/kochab_logo.txt b/examples/kochab_logo.txt new file mode 100644 index 0000000..c01ae2e --- /dev/null +++ b/examples/kochab_logo.txt @@ -0,0 +1,8 @@ + *. ,.-*,,.. + .` `. .,-'` ````--*,,,.. + .` ;*` ```''-o + * ,' __ __ __ + `. ,' / /______ _____/ /_ ____ _/ /_ + ⭐ / //_/ __ \/ ___/ __ \/ __ `/ __ \ + / ,< / /_/ / /__/ / / / /_/ / /_/ / + /_/|_|\____/\___/_/ /_/\__,_/_.___/ diff --git a/examples/northstar_logo.txt b/examples/northstar_logo.txt deleted file mode 100644 index 9fe390c..0000000 --- a/examples/northstar_logo.txt +++ /dev/null @@ -1,5 +0,0 @@ - __ __ __ - ____ ____ _____/ /_/ /_ _____/ /_____ ______ - / __ \/ __ \/ ___/ __/ __ \/ ___/ __/ __ `/ ___/ - / / / / /_/ / / / /_/ / / (__ ) /_/ /_/ / / -/_/ /_/\____/_/ \__/_/ /_/____/\__/\__,_/_/ \ No newline at end of file diff --git a/examples/ratelimiting.rs b/examples/ratelimiting.rs index 48b215c..9838d82 100644 --- a/examples/ratelimiting.rs +++ b/examples/ratelimiting.rs @@ -1,15 +1,13 @@ use std::time::Duration; use anyhow::*; -use futures_core::future::BoxFuture; -use futures_util::FutureExt; use log::LevelFilter; -use northstar::{Server, Request, Response, GEMINI_PORT, Document}; +use kochab::{Server, Request, Response, GEMINI_PORT, Document}; #[tokio::main] async fn main() -> Result<()> { env_logger::builder() - .filter_module("northstar", LevelFilter::Debug) + .filter_module("kochab", LevelFilter::Debug) .init(); Server::bind(("localhost", GEMINI_PORT)) diff --git a/examples/routing.rs b/examples/routing.rs index a2fb78d..dfa871b 100644 --- a/examples/routing.rs +++ b/examples/routing.rs @@ -1,14 +1,14 @@ use anyhow::*; use log::LevelFilter; -use northstar::{Document, document::HeadingLevel, Request, Response, GEMINI_PORT}; +use kochab::{Document, document::HeadingLevel, Request, Response, GEMINI_PORT}; #[tokio::main] async fn main() -> Result<()> { env_logger::builder() - .filter_module("northstar", LevelFilter::Debug) + .filter_module("kochab", LevelFilter::Debug) .init(); - northstar::Server::bind(("localhost", GEMINI_PORT)) + kochab::Server::bind(("localhost", GEMINI_PORT)) .add_route("/", handle_base) .add_route("/route", handle_short) .add_route("/route/long", handle_long) diff --git a/examples/serve_dir.rs b/examples/serve_dir.rs index cfdb345..a41ca7e 100644 --- a/examples/serve_dir.rs +++ b/examples/serve_dir.rs @@ -2,12 +2,12 @@ use std::path::PathBuf; use anyhow::*; use log::LevelFilter; -use northstar::{Server, GEMINI_PORT}; +use kochab::{Server, GEMINI_PORT}; #[tokio::main] async fn main() -> Result<()> { env_logger::builder() - .filter_module("northstar", LevelFilter::Debug) + .filter_module("kochab", LevelFilter::Debug) .init(); Server::bind(("localhost", GEMINI_PORT)) diff --git a/examples/user_management.rs b/examples/user_management.rs index 3329b40..740a0f1 100644 --- a/examples/user_management.rs +++ b/examples/user_management.rs @@ -1,6 +1,6 @@ use anyhow::*; use log::LevelFilter; -use northstar::{ +use kochab::{ GEMINI_PORT, Document, Request, @@ -23,7 +23,7 @@ use northstar::{ async fn main() -> Result<()> { // Turn on logging env_logger::builder() - .filter_module("northstar", LevelFilter::Debug) + .filter_module("kochab", LevelFilter::Debug) .init(); Server::bind(("0.0.0.0", GEMINI_PORT)) @@ -45,7 +45,7 @@ async fn main() -> Result<()> { /// Displays the user's current secret string, or prompts the user to sign in if they /// haven't. Includes links to update your string (`/update`) or your account /// (`/account`). Even though we haven't added an explicit handler for `/account`, this -/// route is managed by northstar. +/// route is managed by kochab. /// /// Because this route is registered as an authenticated route, any connections without a /// certificate will be prompted to add a certificate and register. diff --git a/public/README.gemini b/public/README.gemini deleted file mode 100644 index 9de0018..0000000 --- a/public/README.gemini +++ /dev/null @@ -1,33 +0,0 @@ -``` - __ __ __ - ____ ____ _____/ /_/ /_ _____/ /_____ ______ - / __ \/ __ \/ ___/ __/ __ \/ ___/ __/ __ `/ ___/ - / / / / /_/ / / / /_/ / / (__ ) /_/ /_/ / / -/_/ /_/\____/_/ \__/_/ /_/____/\__/\__,_/_/ -``` - -=> https://docs.rs/northstar Documentation -=> https://github.com/panicbit/northstar GitHub - -# Usage - -Add the latest version of northstar to your `Cargo.toml`. - -## Manually - -```toml -northstar = "0.3.0" # check crates.io for the latest version -``` - -## Automatically - -```sh -cargo add northstar -``` - -# Generating a key & certificate - -```sh -mkdir cert && cd cert -openssl req -x509 -nodes -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -``` diff --git a/public/README.gmi b/public/README.gmi new file mode 100644 index 0000000..4522571 --- /dev/null +++ b/public/README.gmi @@ -0,0 +1,37 @@ +```kochab + *. ,.-*,,.. + .` `. .,-'` ````--*,,,.. + .` ;*` ```''-o + * ,' __ __ __ + `. ,' / /______ _____/ /_ ____ _/ /_ + ⭐ / //_/ __ \/ ___/ __ \/ __ `/ __ \ + / ,< / /_/ / /__/ / / / /_/ / /_/ / + /_/|_|\____/\___/_/ /_/\__,_/_.___/ +``` + +Kochab is an extension & a fork of the Gemini SDK northstar. Where northstar creates an efficient and flexible foundation for Gemini projects, kochab seeks to be as ergonomic and intuitive as possible, making it possible to get straight into getting your ideas into geminispace, with no worrying about needing to build the tools to get there. + +=> https://github.com/panicbit/northstar Northstar GitHub + +## Usage + +It is currently only possible to use kochab through it's git repo, although it may wind up on crates.rs someday. + +```toml +kochab = { git = "https://github.com/Alch-Emi/kochab.git" } +``` + +## Generating a key & certificate + +Run +```sh +mkdir cert && cd cert +openssl req -x509 -nodes -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 +``` +and enter your domain name (e.g. "localhost" for testing) as Common Name (CN). + +Alternatively, if you want to include multiple domains add something like: +``` +-addext "subjectAltName = DNS:localhost, DNS:example.org" +``` + diff --git a/src/lib.rs b/src/lib.rs index 338b960..827b21b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -273,7 +273,7 @@ impl Builder { self } - /// Sets the directory that northstar should look for TLS certs and keys into + /// Sets the directory that kochab should look for TLS certs and keys into /// /// Northstar will look for files called `cert.pem` and `key.pem` in the provided /// directory. @@ -288,7 +288,7 @@ impl Builder { .set_key(dir.join("key.pem")) } - /// Set the path to the TLS certificate northstar will use + /// Set the path to the TLS certificate kochab will use /// /// This defaults to `cert/cert.pem`. /// @@ -299,7 +299,7 @@ impl Builder { self } - /// Set the path to the ertificate key northstar will use + /// Set the path to the ertificate key kochab will use /// /// This defaults to `cert/key.pem`. /// @@ -509,7 +509,7 @@ pub const GEMINI_MIME_STR: &str = "text/gemini"; lazy_static! { /// Mime for Gemini documents ("text/gemini") - pub static ref GEMINI_MIME: Mime = GEMINI_MIME_STR.parse().expect("northstar BUG"); + pub static ref GEMINI_MIME: Mime = GEMINI_MIME_STR.parse().unwrap(); } #[deprecated(note = "Use `GEMINI_MIME` instead", since = "0.3.0")] diff --git a/src/routing.rs b/src/routing.rs index e77faf8..69ff34e 100644 --- a/src/routing.rs +++ b/src/routing.rs @@ -25,7 +25,7 @@ use crate::types::Request; /// considered to be the same route. /// /// ``` -/// # use northstar::routing::RoutingNode; +/// # use kochab::routing::RoutingNode; /// let mut routes = RoutingNode::<&'static str>::default(); /// routes.add_route("/", "base"); /// routes.add_route("/trans/rights/", "short route"); @@ -171,7 +171,7 @@ impl RoutingNode { /// ## Example /// ``` /// # use std::collections::HashSet; - /// # use northstar::routing::RoutingNode; + /// # use kochab::routing::RoutingNode; /// let mut map = RoutingNode::::default(); /// map.add_route("/", 0); /// map.add_route("/hello/world", 1312); diff --git a/src/types/document.rs b/src/types/document.rs index d71c851..f5b5291 100644 --- a/src/types/document.rs +++ b/src/types/document.rs @@ -7,9 +7,9 @@ //! # Examples //! //! ``` -//! use northstar::document::HeadingLevel::*; +//! use kochab::document::HeadingLevel::*; //! -//! let mut document = northstar::Document::new(); +//! let mut document = kochab::Document::new(); //! //! document.add_heading(H1, "Heading 1"); //! document.add_heading(H2, "Heading 2"); @@ -57,7 +57,7 @@ impl Document { /// # Examples /// /// ``` - /// let document = northstar::Document::new(); + /// let document = kochab::Document::new(); /// /// assert_eq!(document.to_string(), ""); /// ``` @@ -73,7 +73,7 @@ impl Document { /// # Examples /// /// ```compile_fail - /// use northstar::document::{Document, Item, Text}; + /// use kochab::document::{Document, Item, Text}; /// /// let mut document = Document::new(); /// let text = Text::new_lossy("foo"); @@ -95,7 +95,7 @@ impl Document { /// # Examples /// /// ```compile_fail - /// use northstar::document::{Document, Item, Text}; + /// use kochab::document::{Document, Item, Text}; /// /// let mut document = Document::new(); /// let items = vec!["foo", "bar", "baz"] @@ -120,7 +120,7 @@ impl Document { /// # Examples /// /// ``` - /// let mut document = northstar::Document::new(); + /// let mut document = kochab::Document::new(); /// /// document.add_blank_line(); /// @@ -141,7 +141,7 @@ impl Document { /// # Examples /// /// ``` - /// let mut document = northstar::Document::new(); + /// let mut document = kochab::Document::new(); /// /// document.add_text("hello\n* world!"); /// @@ -168,7 +168,7 @@ impl Document { /// # Examples /// /// ``` - /// let mut document = northstar::Document::new(); + /// let mut document = kochab::Document::new(); /// /// document.add_link("https://wikipedia.org", "Wiki\n\nWiki"); /// @@ -198,7 +198,7 @@ impl Document { /// # Examples /// /// ``` - /// let mut document = northstar::Document::new(); + /// let mut document = kochab::Document::new(); /// /// document.add_link_without_label("https://wikipedia.org"); /// @@ -230,7 +230,7 @@ impl Document { /// # Examples /// /// ``` - /// let mut document = northstar::Document::new(); + /// let mut document = kochab::Document::new(); /// /// document.add_preformatted("a\n b\n c"); /// @@ -251,7 +251,7 @@ impl Document { /// # Examples /// /// ``` - /// let mut document = northstar::Document::new(); + /// let mut document = kochab::Document::new(); /// /// document.add_preformatted_with_alt("rust", "fn main() {\n}\n"); /// @@ -282,9 +282,9 @@ impl Document { /// # Examples /// /// ``` - /// use northstar::document::HeadingLevel::H1; + /// use kochab::document::HeadingLevel::H1; /// - /// let mut document = northstar::Document::new(); + /// let mut document = kochab::Document::new(); /// /// document.add_heading(H1, "Welcome!"); /// @@ -311,7 +311,7 @@ impl Document { /// # Examples /// /// ``` - /// let mut document = northstar::Document::new(); + /// let mut document = kochab::Document::new(); /// /// document.add_unordered_list_item("milk"); /// document.add_unordered_list_item("eggs"); @@ -334,7 +334,7 @@ impl Document { /// # Examples /// /// ``` - /// let mut document = northstar::Document::new(); + /// let mut document = kochab::Document::new(); /// /// document.add_quote("I think,\ntherefore I am"); /// diff --git a/src/types/meta.rs b/src/types/meta.rs index bfb36e5..8123d46 100644 --- a/src/types/meta.rs +++ b/src/types/meta.rs @@ -33,7 +33,7 @@ impl Meta { let meta: String = match truncate_pos { None => meta.into(), - Some(truncate_pos) => meta.get(..truncate_pos).expect("northstar BUG").into(), + Some(truncate_pos) => meta.get(..truncate_pos).unwrap().into(), }; Self(meta)