spartserv

Simple client and server for the spartan protocol
git clone https://noulin.net/git/spartserv.git
Log | Files | Refs | README

README.md (2150B)


      1 This repository has 2 simple clients and 2 simple servers for the spartan protocol written in C and x64 assembly.
      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 `spartasm` is the server written in assembly and the information about `spartasm` is in `spartasm/README.md`.
      9 
     10 To build the clients and server written in C, you need a shell and the GCC C compiler and run:
     11 ```
     12 apt-get install gcc
     13 ./build.sh
     14 ```
     15 
     16 `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`.
     17 
     18 By default, `spartserv` opens port 3000 and serves on hostname `localhost`.
     19 
     20 Start `spartserv` with:
     21 ```
     22 ./spartserv
     23 ```
     24 
     25 `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:
     26 ```
     27 ./spartclient hostname port path
     28 ./spartclient localhost 3000 /
     29 ```
     30 
     31 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.
     32 
     33 ```
     34 ./sparline spartan://hostname:port/path
     35 ./sparline spartan://localhost:3000
     36 ```
     37 
     38 Each link on the page gets a number, enter the link number to open the link.
     39 Enter 'b' to go back to previous page.
     40 
     41 The line type `=:` is not supported, to upload data run `sparline` with the URL on the `=:` line and the `--infile` option:
     42 ```
     43 ./sparline spartan://hostname/path --infile afile.txt
     44 ```
     45 
     46 # Running on port 300
     47 The default port for spartan is port 300 and in general only root processes can open a listening socket on port under 1024.
     48 
     49 `spartservPrivDrop` starts as a root and open port 300 and then chroot and drops the privileges.
     50 
     51 Only necessary syscalls are allowed.
     52 
     53 Create a user `spartserv`, the server will run as this user:
     54 ```
     55 # as root
     56 adduser spartserv
     57 ```
     58 
     59 In `spartservPrivDrop.c`, set the hostname and the chroot directory, this is the directory being served.
     60 Compile and run:
     61 ```
     62 gcc -std=gnu11 -g3 spartservPrivDrop.c -o spartserv
     63 ./spartserv
     64 ```