Initial commit
This commit is contained in:
commit
5c89cd901a
|
@ -0,0 +1,61 @@
|
|||
#!/usr/bin/env bash
|
||||
# BASTORD, a gemini server in bash
|
||||
# by Case Duckworth <acdw@acdw.net>
|
||||
# License: ISC
|
||||
|
||||
# CONFIGURATION ################################################################
|
||||
# bastord has a few ways to set variables:
|
||||
#
|
||||
# - set environment variables
|
||||
# - use a config file (default: /etc/bastord.conf.sh)
|
||||
# - pass them in as arguments, Make-style
|
||||
#
|
||||
# Unless I can figure out how to tell bash to source a file and /not/ clobber
|
||||
# other environment variables, I can't just have the first two forms of setting
|
||||
# variables. Basically, if you have a config file, use the make-style arguments
|
||||
# (bastord var=value).
|
||||
|
||||
: "${BASTORD_CONFIG:=/etc/bastord.conf.sh}"
|
||||
[[ -r "$BASTORD_CONFIG" ]] && source "$BASTORD_CONFIG"
|
||||
|
||||
: "${BASTORD_PORT:=1965}"
|
||||
: "${BASTORD_ROOT:=/var/gemini}"
|
||||
|
||||
# CONSTANTS ####################################################################
|
||||
#
|
||||
### Status codes
|
||||
# These come straight from the spec, with underscores instead of spaces
|
||||
SC_INPUT=10
|
||||
SC_SENSITIVE_INPUT=11
|
||||
SC_SUCCESS=20
|
||||
SC_TEMPORARY_REDIRECT=30
|
||||
SC_PERMANENT_REDIRECT=31
|
||||
SC_TEMPORARY_FAILURE=40
|
||||
SC_SERVER_UNAVAILABLE=41
|
||||
SC_CGI_ERROR=42
|
||||
SC_PROXY_ERROR=43
|
||||
SC_SLOW_DOWN=44
|
||||
SC_PERMANENT_ERROR=50
|
||||
SC_NOT_FOUND=51
|
||||
SC_GONE=52
|
||||
SC_PROXY_REQUEST_REFUSED=53
|
||||
SC_BAD_REQUEST=59
|
||||
SC_CLIENT_CERTIFICATE_REQUIRED=60
|
||||
SC_CERTIFICATE_NOT_AUTHORIZED=61
|
||||
SC_CERTIFICATE_NOT_VALID=62
|
||||
|
||||
# FUNCTIONS ####################################################################
|
||||
|
||||
reply() { # reply STATUS_CODE MESSAGE
|
||||
local sc="$1"; shift
|
||||
printf '%d %s\r\n' "$sc" "$*"
|
||||
}
|
||||
|
||||
handle_request() { # handle_request REQUEST
|
||||
# as per the spec, a Gemini request is a URL followed by \r\n, of a maximum
|
||||
# length of 1024 bytes.
|
||||
local req="$1"
|
||||
|
||||
# badly-formed request
|
||||
|
||||
}
|
Loading…
Reference in New Issue