sr-71/types.go

67 lines
1.0 KiB
Go
Raw Normal View History

2023-09-28 14:08:48 +00:00
package main
import (
"context"
"crypto/tls"
"net"
"os/user"
"github.com/go-kit/log/level"
"tildegit.org/tjp/sliderule"
)
type Modifiers struct {
DirDefault string
DirList bool
Exec bool
ExtendedGophermap bool
AutoAtom bool
Titan *Auth
titanName string
}
func (m Modifiers) Empty() bool {
return m.DirDefault == "" && !m.DirList && !m.Exec && !m.ExtendedGophermap
}
type RouteDirective struct {
// Allowed: "static", "cgi", "git", "titan"
Type string
// "<FsPath> at <URLPath>"
FsPath string
URLPath string
// "with ..."
Modifiers Modifiers
Auth *Auth
authName string
}
type Server struct {
Type string
IP net.IP
Port uint16
TLS *tls.Config
Hostnames []string
Routes []RouteDirective
}
type Auth struct {
Name string
Strategy AuthStrategy
}
type AuthStrategy interface {
Approve(context.Context, *sliderule.Request) bool
}
type Configuration struct {
SystemUser *user.User
LogLevel level.Value
Servers []Server
}