more documentation
This commit is contained in:
parent
710e8aae56
commit
b6e428eba2
5 changed files with 50 additions and 18 deletions
30
README.md
30
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"?
|
||||
-----------------------
|
||||
|
|
7
doc/index.gmi
Normal file
7
doc/index.gmi
Normal 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!
|
||||
|
|
@ -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
|
||||
|
|
13
src/main.rs
13
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 => {
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue