diff --git a/README.md b/README.md index 73023ea..ed6cd45 100644 --- a/README.md +++ b/README.md @@ -23,18 +23,36 @@ there is no way to disable this. Of course, Gemini's default port (1965) can be opened in user-mode, but not changing the user after startup would retain read permissions to the private key. +Building +-------- + +Set up a Cargo build environment, then simply run +```sh +cargo build +``` +to create a debug build or +```sh +cargo build --release +``` +to create a release build. + Starting -------- Sheldon Director look for a config file in `/etc/sheldond.conf`. If you want to -change this, pass an alternative path on startup like so: - -An example start can look like this: -```sh -sudo ./sheldond -c ./sheldond.conf -``` +change this, pass an alternative path on startup using the `-c` parameter. +Use `-h` to get a list of all supported command line arguments. An example config file can be found in this repository in `doc/sheldond.conf`. +Use it to serve the content of the `doc/` directory on localhost: +``` +sudo ./target/debug/sheldond -c ./doc/sheldond.conf +``` +Try connecting to `gemini://localhost` via your favorite Gemini client! + +Note: This sets the user to `nobody` and the group to `nobody` as well. This +naming scheme is not consistent for all Unix systems... Try changing the group +name to `nogroup` if the software fails to start. Why "Sheldon Director"? ----------------------- diff --git a/doc/index.gmi b/doc/index.gmi new file mode 100644 index 0000000..9bfce2a --- /dev/null +++ b/doc/index.gmi @@ -0,0 +1,7 @@ +# Gemini! + +This file is served over Gemini by Sheldon Director! + +=> spec-spec.txt Read the Gemini spec +=> key.pem The private key of this server! + diff --git a/doc/sheldond.conf b/doc/sheldond.conf index 1af1389..7c39f06 100644 --- a/doc/sheldond.conf +++ b/doc/sheldond.conf @@ -2,16 +2,16 @@ default_host = localhost # should be self explanatory -gem_root = /var/gemini/ +gem_root = ./doc # you can define as many of these as you like listen = [::1]:1965 listen = 127.0.0.1:1965 # privilege level for the server to drop to after initializing -user = gem-data -group = gem-data +user = nobody +group = nobody # certificate data MUST be in PEM format right now -cert_key = /etc/ssl/private/gemini-key.pem -cert_chain = /etc/ssl/certs/gemini-chain.pem +cert_key = ./doc/key.pem +cert_chain = ./doc/cert.pem diff --git a/src/main.rs b/src/main.rs index b22b626..1a00173 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,12 +6,8 @@ use std::io::{BufRead, BufReader}; use std::path::Path; fn help() { - let version = match option_env!("CARGO_PKG_VERSION") { - Some(v) => v, - None => "", - }; - - println!("usage: sheldond {}", version); + println!("usage:"); + println!(" -h, --help\t\tdisplay this message"); println!(" -c, --config\t\tpath to the configuration file"); } @@ -83,6 +79,11 @@ fn parse_config(fname: String) -> server::ServerConfig { } fn main() { + println!("sheldond {}", match option_env!("CARGO_PKG_VERSION") { + Some(v) => v, + None => "", + }); + let config_fname = match parse_args() { Some(config_fname) => config_fname, None => { diff --git a/src/server/mod.rs b/src/server/mod.rs index 3b01ce2..9909fd2 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -97,9 +97,12 @@ impl Server { fn build_acceptor(config: &ServerConfig) -> std::sync::Arc { let mut acceptor = SslAcceptor::mozilla_intermediate_v5(SslMethod::tls()).unwrap(); + println!("reading certificate private key: {}", config.cert_key); + // TODO: allow more than PEM acceptor .set_private_key_file(config.cert_key.as_str(), SslFiletype::PEM) .unwrap(); + println!("reading certificate chain file: {}", config.cert_chain); acceptor .set_certificate_chain_file(config.cert_chain.as_str()) .unwrap(); @@ -146,9 +149,12 @@ impl Server { thread::spawn(move || { let stream = acceptor.accept(stream).unwrap(); handler::handle_request(&config, stream); + println!("closing connection"); }); } - Err(_) => { /* connection failed */ } + Err(_) => { + println!("connection failed"); + } } } }