Skip to content

Commit 623254f

Browse files
committed
Args for configuration, TLS cert support
1 parent b314254 commit 623254f

6 files changed

Lines changed: 364 additions & 40 deletions

File tree

Cargo.lock

Lines changed: 127 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.gmi

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Chaykin: Linked Data over the Small Web
2+
3+
A Linked Data server in Rust that makes the Semantic Web available over the Small Web (or "smolweb") through the Gemini protocol.
4+
5+
=> https://geminiprotocol.net/ Gemini Protocol
6+
7+
## Synopsis
8+
9+
Gemini is a minimalistic, inextensible, read-only application protocol with cryptography support. It is intended to live alongside HTTP, but also with Gopher and other, more recent application protocols that share the same philosophy of a functional Web that doesn't assume bloated clients to run.
10+
11+
Chaykin tries to follow that spirit by offering an application that can act as a Linked Data server in its own right, or as a proxy to existing Linked Open Data (note the difference here, though I very much hope that, if you choose to serve data through it, they will still be open data). With one instance of Chaykin, you can host a Gemini capsule that does both.
12+
13+
### Why bother?
14+
15+
The contemporary Web is a far cry from the one TimBL (was) promised. At the same time, Gopher site count is increasing. This suggests that those true to the traditional spirit of the Web are attempting to remediate the current situation through alternative protocols, without losing the best of the HTTP world.
16+
17+
=> https://en.wikipedia.org/wiki/Gopher_(protocol)#Server_census Gopher site count is increasing
18+
19+
With this project, I want to help bring the Web of Data philosophy into that world that stays true to the spirit of the Web of Information, whilst at the same time being a bridge to the better part of the HTTP web.
20+
21+
### Why Chaykin?
22+
23+
Lester Chaykin is a fictional particle physicist and the protagonist of Eric Chahi's classic video game Another World ("Out of This World" for my American friends). Much like Dr Chaykin is transported out of this world and into another, this project attempts to bring Linked Data out of the cluttered, HTTP-based web and into the dimension of the small web.
24+
25+
=> https://another-world-game.fandom.com/wiki/The_Story_of_Lester_Knight_Chaykin Lester Chaykin
26+
=> http://www.wikidata.org/entity/Q257469 Another World (Wikidata)
27+
28+
Another World was also fascinating through its many ways of being minimalistic: in the aesthetic (using cinematic animation on top of a bare-polygon 3D engine), interface (HUDless), and narrative (dialogue-free). Similarly, the minimalist Gemini protocol is here used to host the beauty and complexity of linked data and knowledge graphs.
29+
30+
Finally, Another World was first released on the Amiga computer, and there are Gemini browsers running on AmigaOS with which you can now explore Linked Data too (running this _Rust server_ on the Amiga might be trickier though).
31+
32+
### Why Rust?
33+
34+
Because I've wanted to learn it for long; because a significant chunk of Gemini software is in Rust; and because such a minimalist protocol calls for an optimised implementation, which I very much hope to someday deliver in this blazing fast language.
35+
36+
=> https://geminiprotocol.net/software/ Gemini software in Rust
37+
38+
### Why you?
39+
40+
Because I do research on the applicability of the Semantic Web and because, if that wasn't clear already, I am a retrogamer--and a gaming historian in training, I daresay--and miss the thrill of the 1990's Web that was largely there to support the likes of me. So there.
41+
42+
=> https://doi.org/10.1145/3603163.3609074 DOI of a panel at Hypertext 2023 where I made my case
43+
44+
## Features
45+
46+
* Gemini Server: Custom Tokio+Rustls implementation.
47+
* Linked Data Store: Consumes RDF data in Turtle via `rio_turtle` and holds them into an in-memory store.
48+
* Gemtext Mapping: A proposed serialization of RDF to the hypertext format of Gemini, offering a recursively browsable knowledge graph.
49+
* External Proxy: Acts as a browser for all the Linked Open Data out there.
50+
* Encoded URLs in the request path are fetched via `reqwest`.
51+
* `Accept: text/turtle` is used for Content Negotiation.
52+
* Fetched RDF is parsed and rendered.
53+
* Links to other external resources are re-encoded to point back to the proxy.
54+
55+
## Setup & Running
56+
57+
Pretty standard stuff:
58+
59+
1. Dependencies: `tokio`, `rustls`, `rcgen`, `rio_turtle`, `rio_api`, `reqwest`, `percent-encoding`.
60+
2. Build:
61+
62+
```sh
63+
cd server
64+
cargo build
65+
```
66+
67+
3. Run:
68+
69+
Either launch the `chaykin` executable in `server/target`, or
70+
71+
```sh
72+
cargo run
73+
```
74+
75+
The server listens on `127.0.0.1:1965` by default.
76+
77+
### Configuration
78+
79+
You can configure the server using command-line arguments:
80+
81+
```sh
82+
cargo run -- --help
83+
```
84+
85+
Arguments:
86+
* `--host`: IP address to bind to (default: 127.0.0.1)
87+
* `--port`: Port number to bind to (default: 1965)
88+
* `--file`: Path to the RDF data file (default: sample_data.ttl)
89+
* `--cert`: Path to TLS certificate (PEM)
90+
* `--key`: Path to TLS private key (PEM)
91+
92+
If no certificate/key is provided, a self-signed certificate is generated for development.
93+
94+
## Usage & Verification
95+
96+
### 1. Local Resource
97+
98+
```sh
99+
printf "gemini://localhost/me\r\n" | openssl s_client -connect 127.0.0.1:1965 -quiet
100+
```
101+
102+
Returns data about yours truly (from `sample_data.ttl`).
103+
104+
### 2. External Resource (Proxy)
105+
106+
See Another World on Wikidata:
107+
108+
=> http://www.wikidata.org/entity/Q257469 Another World on Wikidata
109+
110+
```sh
111+
# Encoded URL: http://www.wikidata.org/entity/Q257469
112+
printf "gemini://localhost/http%3A%2F%2Fwww.wikidata.org%2Fentity%2FQ257469\r\n" | openssl s_client -connect 127.0.0.1:1965 -quiet
113+
```
114+
115+
(Note: you will need to replace every `%` with `%%` for printf escaping in bash).
116+
117+
**Output:**
118+
119+
```text
120+
20 text/gemini
121+
# Proxy: http://www.wikidata.org/entity/Q257469
122+
...
123+
=> gemini://localhost/http%3A%2F%2Fdata%2Ebnf%2Efr%2Fark%3A%2F12148%2Fcb169157795%23about http://www.wikidata.org/prop/direct-normalized/P268 : http://data.bnf.fr/ark:/12148/cb169157795#about
124+
...
125+
* http://www.wikidata.org/prop/direct/P1476: LanguageTaggedString { value: "Out of This World", language: "en" }
126+
...
127+
```
128+
129+
If you got this, then the server successfully:
130+
131+
1. Decoded the URL.
132+
2. Fetched the Turtle data from `www.wikidata.org`.
133+
3. Parsed the triples.
134+
4. Found the subject (handling http/https mismatch automatically).
135+
5. Generated links pointing back to `gemini://localhost/...`.
136+
137+
## Rights
138+
139+
This is free software; see LICENSE.
140+
141+
=> LICENSE LICENSE

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ DOI of a panel at Hypertext 2023 where I made my case: [10.1145/3603163.3609074]
4141
- `Accept: text/turtle` is used for Content Negotiation.
4242
- Fetched RDF is parsed and rendered.
4343
- Links to other external resources are re-encoded to point back to the proxy.
44+
- You can provide a custom TLS certificate via the `--cert` flag.
4445

4546
## Setup & Running
4647
Pretty standard stuff:
@@ -93,12 +94,9 @@ If you got this, then the server successfully:
9394
Lots and lots, but mainly:
9495
- Move to RDF support via [Sophia](https://docs.rs/sophia/) and access existing triple stores.
9596
- Make it an extension of existing Gemini servers in Rust like [Agate](https://github.com/mbrubeck/agate).
96-
- Better TLS support: right now it is only supported via self-signed certificates.
9797
- SPARQL API? Only if it can respect the basic principles of the Small Web.
9898
- Support something along the lines of the [Titan protocol](https://transjovian.org/view/titan/) if we need to have something like HTTP POST (which we would if SPARQL were to be implemented). Could also be useful if we want a form-like frontend for the user to enter a custom Linked Data URI.
99-
- Full specification of the Gemtext RDF serialization (with support for labels!).
100-
- Make the server configurable.
101-
- This documentation in gemtext :)
99+
- Full specification, including grammar, of the Gemtext RDF serialization (with support for labels!).
102100

103101
## Rights
104102
This is free software; see [LICENSE](LICENSE).

server/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ rio_api = "0.8"
1515
reqwest = { version = "0.11", features = ["rustls-tls"], default-features = false }
1616
percent-encoding = "2.3"
1717
anyhow = "1.0"
18+
clap = { version = "4.5", features = ["derive"] }
1819

0 commit comments

Comments
 (0)