sr-71/types.go

80 lines
1.3 KiB
Go
Raw Permalink Normal View History

2023-09-28 14:08:48 +00:00
package main
import (
"context"
"crypto/tls"
"net"
"os/user"
"text/template"
2023-09-28 14:08:48 +00:00
"github.com/go-kit/log/level"
"tildegit.org/tjp/sliderule"
)
type Modifiers struct {
DirDefault string
DirList bool
Exec bool
ExecCmd string
2023-09-28 14:08:48 +00:00
ExtendedGophermap bool
AutoAtom bool
2023-10-31 17:11:53 +00:00
Auth *Auth
2023-09-28 14:08:48 +00:00
Titan *Auth
Templates *template.Template
2023-09-28 14:08:48 +00:00
2023-10-31 17:11:53 +00:00
authName string
2023-09-28 14:08:48 +00:00
titanName string
}
func (m Modifiers) Empty() bool {
return (m.DirDefault == "" &&
!m.DirList &&
!m.Exec &&
!m.ExtendedGophermap &&
m.ExecCmd == "" &&
!m.AutoAtom &&
m.Titan == nil &&
m.titanName == "" &&
m.Templates == nil)
2023-09-28 14:08:48 +00:00
}
type RouteDirective struct {
// Allowed: "static", "cgi", "git", "titan"
Type string
// "<FsPath> at <URLPath>"
FsPath string
URLPath string
// "with ..."
Modifiers Modifiers
}
type Server struct {
Type string
IP net.IP
Port uint16
TLS *tls.Config
Hostnames []string
Routes []RouteDirective
tlsKeyFile string
tlsCertFile string
2023-09-28 14:08:48 +00:00
}
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
}