💾 Archived View for gmi.noulin.net › markdown › spartserv_README.md captured on 2023-07-10 at 18:19:05.
-=-=-=-=-=-=-
# Spartserv This repository has 2 simple clients and 2 simple servers for the spartan protocol written in C and x64 assembly. Additionally, there is a client and a server using the spartan protocol over UDP: - spartservudp - spartclientudp About the spartan protocol: [Spartan on the web](https://portal.mozz.us/spartan/spartan.mozz.us/) [Spartan on gemini](gemini://spartan.mozz.us) [Spartan on spartan](spartan://spartan.mozz.us) `spartasm` is the server written in assembly and the information about `spartasm` is in `spartasm/README.md`. # Build To build the clients and server written in C, you need a shell and the GCC C compiler and run:
apt-get install gcc
./build.sh
`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`. By default, `spartserv` opens port 3000 and serves on hostname `localhost`. Start `spartserv` with:
./spartserv
`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:
./spartclient hostname port path
./spartclient localhost 3000 /
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.
./sparline spartan://hostname:port/path
./sparline spartan://localhost:3000
Each link on the page gets a number, enter the link number to open the link. Enter 'b' to go back to previous page. The line type `=:` is not supported, to upload data run `sparline` with the URL on the `=:` line and the `--infile` option:
./sparline spartan://hostname/path --infile afile.txt
# Spartan over UDP To run spartan over UDP, you need 2 machines (it is not possible to run the server and client on the same machine) and these machines have to be to send and received UDP packets. If you have router with NAT, you need to setup port forwarding or port triggering. The define `HOSTNAME` in `spartservudp.c` has to be set to the address used on the client machine. `spartclientudp` works in the same way as `spartclient`:
./spartclient 192.168.1.2 3000 /
A request is one UDP packet and a response is also one UDP packet, so the maximum document length is 63000 bytes. # Running on port 300 The default port for spartan is port 300 and in general only root processes can open a listening socket on port under 1024. `spartservPrivDrop` starts as a root and open port 300 and then chroot and drops the privileges. Only necessary syscalls are allowed. Create a user `spartserv`, the server will run as this user:
adduser spartserv
In `spartservPrivDrop.c`, set the hostname and the chroot directory, this is the directory being served. Compile and run:
gcc -std=gnu11 -g3 spartservPrivDrop.c -o spartserv
./spartserv