Rebrand as kochab

I spent /so/ long looking for that figlet font.
    __              __          __
   / /______  _____/ /_  ____ _/ /_
  / //_/ __ \/ ___/ __ \/ __ `/ __ \
 / ,< / /_/ / /__/ / / / /_/ / /_/ /
/_/|_|\____/\___/_/ /_/\__,_/_.___/
This commit is contained in:
Emii Tatsuo 2020-11-25 00:42:09 -05:00
parent 16721a7321
commit b69aba139f
Signed by: Emi
GPG Key ID: 68FAB2E2E6DFC98B
17 changed files with 117 additions and 152 deletions

View File

@ -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

View File

@ -1,12 +1,11 @@
[package]
name = "northstar"
name = "kochab"
version = "0.3.1"
authors = ["panicbit <panicbit.dev@gmail.com>"]
authors = ["Emii Tatsuo <emi@alchemi.dev>", "panicbit <panicbit.dev@gmail.com>"]
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"]

View File

@ -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"

View File

@ -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<u8>;
#[tokio::main]
async fn main() -> Result<()> {
env_logger::builder()
.filter_module("northstar", LevelFilter::Debug)
.filter_module("kochab", LevelFilter::Debug)
.init();
let users = Arc::<RwLock::<HashMap<CertBytes, String>>>::default();

View File

@ -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",

8
examples/kochab_logo.txt Normal file
View File

@ -0,0 +1,8 @@
*. ,.-*,,..
.` `. .,-'` ````--*,,,..
.` ;*` ```''-o
* ,' __ __ __
`. ,' / /______ _____/ /_ ____ _/ /_
⭐ / //_/ __ \/ ___/ __ \/ __ `/ __ \
/ ,< / /_/ / /__/ / / / /_/ / /_/ /
/_/|_|\____/\___/_/ /_/\__,_/_.___/

View File

@ -1,5 +0,0 @@
__ __ __
____ ____ _____/ /_/ /_ _____/ /_____ ______
/ __ \/ __ \/ ___/ __/ __ \/ ___/ __/ __ `/ ___/
/ / / / /_/ / / / /_/ / / (__ ) /_/ /_/ / /
/_/ /_/\____/_/ \__/_/ /_/____/\__/\__,_/_/

View File

@ -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))

View File

@ -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)

View File

@ -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))

View File

@ -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.

View File

@ -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
```

37
public/README.gmi Normal file
View File

@ -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"
```

View File

@ -273,7 +273,7 @@ impl<A: ToSocketAddrs> Builder<A> {
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<A: ToSocketAddrs> Builder<A> {
.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<A: ToSocketAddrs> Builder<A> {
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")]

View File

@ -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<T> RoutingNode<T> {
/// ## Example
/// ```
/// # use std::collections::HashSet;
/// # use northstar::routing::RoutingNode;
/// # use kochab::routing::RoutingNode;
/// let mut map = RoutingNode::<usize>::default();
/// map.add_route("/", 0);
/// map.add_route("/hello/world", 1312);

View File

@ -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");
///

View File

@ -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)