Documentation
¶
Index ¶
- Constants
- Variables
- func Addlog(ltype int, msg []byte, llev int, u User, r *http.Request)
- func Addtagsuf(tags []string, suf []string) []string
- func Appendfile(fname string, str string)
- func Cherr(e error) error
- func Cleanstring(src string, pat string) string
- func Cp(s string, d string) (int64, error)
- func Findstrinslice(v string, list []string) bool
- func Formattags(s string) []string
- func Identicalbs(s1 []byte, s2 []byte) bool
- func Initlog(prgname string)
- func Prettyfsize(b int64) string
- func Randstr(ln int) string
- func Rmall(dir string)
- func Rmdupstrfslice(list []string) []string
- func Rmifrslice(n int, s []int) ([]int, bool)
- func Sendstatus(code int, text string, w http.ResponseWriter)
- func Sendtagstatus(r int, w http.ResponseWriter)
- func Shutdown(settings Settings)
- func Sighandler(settings Settings)
- func Striptagsuf(stags []string) []string
- func Valuser(u User, pass []byte) bool
- func Wrdatafile(fnp string, sf io.Reader) error
- type Apicall
- type Deck
- type Deckreq
- type Hfn
- type Iindex
- type Imgobj
- type Login
- type Rtag
- type Settings
- type Slide
- type Slidetype
- type Smtp
- type Statusresp
- type Tagresp
- type Textobj
- type Textreq
- type Thindex
- type Uindex
- type User
Constants ¶
const ALEV_ADMIN = 2 // BOFH
const ALEV_CONTRIB = 1 // Contributor
const ALEV_USER = 0 // Regular user
User level definitions
const BPMAX = 8 // Max number of bullet points for lists
const BPMIN = 3 // Min number of bullet points for lists
const BPOINTMAX = 20 // Max length for bullet point
const BTEXTMAX = 80 // Max length for body text
const CU_CPASS = 2 // Password change request
const CU_MKADM = 0 // Makes specified user admin
Operation codes for user handling
const CU_PWDRS = 4 // Requests password reset email
const CU_RMADM = 1 // Removes admin status from user
const CU_RMUSR = 3 // Removes user account
const C_ALEV = 7 // User does not have sufficient access level
const C_IEMA = 12 // Invalid email address
const C_NLOG = 6 // User not logged in
const C_NOBJ = 14 // No such database object
const C_NOSU = 5 // No such user
const C_NSOP = 9 // No such operation
const C_NTAG = 8 // No tags provided
const C_OK = 0 // OK
Status response codes sent to client
const C_UICH = 4 // Username includes illegal characters
const C_UIDB = 3 // User already exists in database
const C_UNKN = 10 // Unknown error
const C_UNTS = 15 // User name too short
const C_USPW = 11 // Unsafe password
const C_WEMA = 13 // Incorrect email address
const C_WRFF = 1 // Incorrect file format
const C_WRSZ = 2 // Not able to classify image size
const DBNAME = "./data/rs.db" // Database location (change at own peril)
const DEFAULTPORT = 6291 // Port can also be supplied with -p flag
const FBFILE = "./data/fb.txt" // Storage of feedback data
const IMGDIR = "./static/img/" // Image directory
const IMG_BO = 2 // Box-shaped
const IMG_LS = 1 // Landscape
const IMG_PO = 3 // Portrait
const IMG_XL = 0 // X Large
Image type classifications
const LOGPATH = "./static/log/" // Logs should be accessible from frontend
const L_REQ = 0 // Request log
Logging codes parsed by Addlog()
const L_RESP = 1 // Response log
const L_SHUTDOWN = 2 // Server shutdown request log
const PIDFILEPATH = "./data/" // Base directory for storage of PID file
const PWMINLEN = 6 // Minimum accepted lendth of password
const RFNLEN = 20 // Length of random file names (w/o .ext)
const RNUMBMAX = 30 // Random number base max
const RNUMEMAX = 3 // Random number exponent max
const RPWDLEN = 15 // Length of random generated passwords
const SKEYLEN = 40 // # of characters in a session key
const STYPES = 8 // Number of slide types available
const THDIR = "./static/css/themes/" // CSS theme file directory
const TTEXTMAX = 35 // Max length for title text
const UNMINLEN = 2 // Minimum accepted lendth of user names
const VERBDEF = false // Verbose mode defaults to false
Variables ¶
var ALLSUF = []int{0, 1, 2, 3}
Data object including references to all IKEYs
var BBUC = []byte("bbuc") // Body text bucket
var DBUC = []byte("dbuc") // Deck bucket
var IBUC = []byte("ibuc") // Image bucket
var IMGMAX = [][]uint{
{1920, 1080},
{1920, 1080},
{1080, 1080},
{1080, 1920},
}
Max bounds for image sizes (w, h)
var IMGMIME = []string{
"image/jpeg",
"image/png",
"image/gif",
}
For verification of image mime types
var IMGMIN = [][]uint{
{1920, 1080},
{640, 360},
{360, 360},
{360, 480},
}
Min bounds for image sizes (w, h)
var INDEX = []byte(".index") // Untouchable database index position
var ISZINDEX = [][]int{
{0, 1},
{0},
{0},
{3},
{1, 2, 3},
{},
{1, 2, 3},
{},
}
Image size per slide type reference chart TODO map with TT & BT bools
var NUMPREF = []byte("$+-") // Potential number prefixes for slide type 2
var NUMSUFF = []byte("%!?") // Potential number suffixes for slide type 2
var RXTAGS = "[^a-zåäöüæø]+" // Regex for allowed tags
var RXUSER = "[^a-z0-9]+" // Regex for allowed user names
var SBUC = []byte("sbuc") // Settings bucket
var SPROB = []int{2, 6, 3, 4, 9, 6, 5, 4}
Probability chart for slide occurance. Higher number = higher probability.
var SUFINDEX = []string{
".s0",
".s1",
".s2",
".s3",
}
Index keys to be used for image size indexes
var Smut sync.Mutex // Settings mutex
var TBUC = []byte("tbuc") // Title text bucket
var TINDEX = []byte(".tindex") // Untouchable database tag index position
var UBUC = []byte("ubuc") // User bucket
Functions ¶
func Cleanstring ¶
Removes whitespace and special characters from string
func Findstrinslice ¶
Returns true if string is present in list
func Formattags ¶
Transforms whitespace separated string to tag slice
func Identicalbs ¶
Compares two byte slices, returs true if identical
func Rmdupstrfslice ¶
Removes duplicate strings from slice
func Rmifrslice ¶
Removes int from slice if present returns 1 if action taken
func Sendstatus ¶
func Sendstatus(code int, text string, w http.ResponseWriter)
Sends a status code response as JSON object
func Sendtagstatus ¶
func Sendtagstatus(r int, w http.ResponseWriter)
Wrapper for tag status responses
func Shutdown ¶
func Shutdown(settings Settings)
Enables clean shutdown. Needs delay for caller to send response
func Striptagsuf ¶
Removes all tag suffixes and returns 'clean' list
Types ¶
type Apicall ¶
type Apicall struct { User string // User name Pass string // Password Email string // Email address Skey string // Session key Tuser string // Target user Tags string // Tags Lang string // Languge code, 'en', 'de', 'se', etc Id string // Deck ID request Slide string // Slide number for reference Amount string // Amount of slides requested Ttext string // Title test Btext string // Body test Msg string // Feedback text Bpoint string // Bullet point Rop string // Raw (unprocessed) operation Wipe string // Request to wipe database Type string // Object type reference }
type Settings ¶
type Settings struct { Llev int // Log level Dmax int // Max id of decks Tmax int // Max id of title objects Bmax int // Max id of body objects Imax int // Max id of image objects Umax int // Max user ID in database Pidfile string // Location of pidfile Taglist []string // List of all existing tags Smtp Smtp // Settings for sending email }
var Set Settings // Global rsserver settings