💾 Archived View for gmi.noulin.net › gitRepositories › spartserv › file › README.md.gmi captured on 2023-01-29 at 11:25:16. Gemini links have been rewritten to link to archived content

View Raw

More Information

➡️ Next capture (2023-07-10)

-=-=-=-=-=-=-

spartserv

Log

Files

Refs

README

README.md (1990B)

     1 This repository has 2 simple clients and a simple server for the spartan protocol written in C.
     2 
     3 About the spartan protocol:
     4 [Spartan on the web](https://portal.mozz.us/spartan/spartan.mozz.us/)
     5 [Spartan on gemini](gemini://spartan.mozz.us)
     6 [Spartan on spartan](spartan://spartan.mozz.us)
     7 
     8 To build this, you need a shell and the GCC C compiler and run:
     9 ```
    10 apt-get install gcc
    11 ./build.sh
    12 ```
    13 
    14 `spartserv.c` is a server handling one request at a time and serves static pages. The configurations for the hostname and server root are on the top of `spartserv.c`.
    15 
    16 By default, `spartserv` opens port 3000 and serves on hostname `localhost`.
    17 
    18 Start `spartserv` with:
    19 ```
    20 ./spartserv
    21 ```
    22 
    23 `spartclient.c` is a client that downloads one page (maximum 8kb) and exits. It doesn't take a URL as argument, run it like this:
    24 ```
    25 ./spartclient hostname port path
    26 ./spartclient localhost 3000 /
    27 ```
    28 
    29 The `sparline.c` client takes a URL as argument and is able to browse in the terminal. The default port is 300 when no port is specified.
    30 
    31 ```
    32 ./sparline spartan://hostname:port/path
    33 ./sparline spartan://localhost:3000
    34 ```
    35 
    36 Each link on the page gets a number, enter the link number to open the link.
    37 Enter 'b' to go back to previous page.
    38 
    39 The line type `=:` is not supported, to upload data run `sparline` with the URL on the `=:` line and the `--infile` option:
    40 ```
    41 ./sparline spartan://hostname/path --infile afile.txt
    42 ```
    43 
    44 # Running on port 300
    45 The default port for spartan is port 300 and in general only root processes can open a listening socket on port under 1024.
    46 
    47 `spartservPrivDrop` starts as a root and open port 300 and then chroot and drops the privileges.
    48 
    49 Only necessary syscalls are allowed.
    50 
    51 Create a user `spartserv`, the server will run as this user:
    52 ```
    53 # as root
    54 adduser spartserv
    55 ```
    56 
    57 In `spartservPrivDrop.c`, set the hostname and the chroot directory, this is the directory being served.
    58 Compile and run:
    59 ```
    60 gcc -std=gnu11 -g3 spartservPrivDrop.c -o spartserv
    61 ./spartserv
    62 ```