summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Wolff <janw@mailbox.org>2020-05-19 07:25:03 +0200
committerJan Wolff <janw@mailbox.org>2020-05-19 07:25:03 +0200
commitb6e428eba2397ab063f6580098fe100906c44fb1 (patch)
tree967a5c6a48bd8f10458250d57a0b5f5d014e78be
parent710e8aae565bd376d493ed89859c52d7f58a34f7 (diff)
more documentation
-rw-r--r--README.md28
-rw-r--r--doc/index.gmi7
-rw-r--r--doc/sheldond.conf10
-rw-r--r--src/main.rs13
-rw-r--r--src/server/mod.rs8
5 files changed, 49 insertions, 17 deletions
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:
+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`.
+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!
-An example config file can be found in this repository in `doc/sheldond.conf`.
+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<SslAcceptor> {
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");
+ }
}
}
}