more documentation

This commit is contained in:
Jan Wolff 2020-05-19 07:25:03 +02:00
parent 710e8aae56
commit b6e428eba2
5 changed files with 50 additions and 18 deletions

View file

@ -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 opened in user-mode, but not changing the user after startup would retain read
permissions to the private key. 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 Starting
-------- --------
Sheldon Director look for a config file in `/etc/sheldond.conf`. If you want to 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: 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 start can look like this:
```sh
sudo ./sheldond -c ./sheldond.conf
```
An example config file can be found in this repository in `doc/sheldond.conf`. 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"? Why "Sheldon Director"?
----------------------- -----------------------

7
doc/index.gmi Normal file
View file

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

View file

@ -2,16 +2,16 @@
default_host = localhost default_host = localhost
# should be self explanatory # should be self explanatory
gem_root = /var/gemini/ gem_root = ./doc
# you can define as many of these as you like # you can define as many of these as you like
listen = [::1]:1965 listen = [::1]:1965
listen = 127.0.0.1:1965 listen = 127.0.0.1:1965
# privilege level for the server to drop to after initializing # privilege level for the server to drop to after initializing
user = gem-data user = nobody
group = gem-data group = nobody
# certificate data MUST be in PEM format right now # certificate data MUST be in PEM format right now
cert_key = /etc/ssl/private/gemini-key.pem cert_key = ./doc/key.pem
cert_chain = /etc/ssl/certs/gemini-chain.pem cert_chain = ./doc/cert.pem

View file

@ -6,12 +6,8 @@ use std::io::{BufRead, BufReader};
use std::path::Path; use std::path::Path;
fn help() { fn help() {
let version = match option_env!("CARGO_PKG_VERSION") { println!("usage:");
Some(v) => v, println!(" -h, --help\t\tdisplay this message");
None => "",
};
println!("usage: sheldond {}", version);
println!(" -c, --config\t\tpath to the configuration file"); println!(" -c, --config\t\tpath to the configuration file");
} }
@ -83,6 +79,11 @@ fn parse_config(fname: String) -> server::ServerConfig {
} }
fn main() { fn main() {
println!("sheldond {}", match option_env!("CARGO_PKG_VERSION") {
Some(v) => v,
None => "",
});
let config_fname = match parse_args() { let config_fname = match parse_args() {
Some(config_fname) => config_fname, Some(config_fname) => config_fname,
None => { None => {

View file

@ -97,9 +97,12 @@ impl Server {
fn build_acceptor(config: &ServerConfig) -> std::sync::Arc<SslAcceptor> { fn build_acceptor(config: &ServerConfig) -> std::sync::Arc<SslAcceptor> {
let mut acceptor = SslAcceptor::mozilla_intermediate_v5(SslMethod::tls()).unwrap(); let mut acceptor = SslAcceptor::mozilla_intermediate_v5(SslMethod::tls()).unwrap();
println!("reading certificate private key: {}", config.cert_key);
// TODO: allow more than PEM
acceptor acceptor
.set_private_key_file(config.cert_key.as_str(), SslFiletype::PEM) .set_private_key_file(config.cert_key.as_str(), SslFiletype::PEM)
.unwrap(); .unwrap();
println!("reading certificate chain file: {}", config.cert_chain);
acceptor acceptor
.set_certificate_chain_file(config.cert_chain.as_str()) .set_certificate_chain_file(config.cert_chain.as_str())
.unwrap(); .unwrap();
@ -146,9 +149,12 @@ impl Server {
thread::spawn(move || { thread::spawn(move || {
let stream = acceptor.accept(stream).unwrap(); let stream = acceptor.accept(stream).unwrap();
handler::handle_request(&config, stream); handler::handle_request(&config, stream);
println!("closing connection");
}); });
} }
Err(_) => { /* connection failed */ } Err(_) => {
println!("connection failed");
}
} }
} }
} }