Documentation ¶
Index ¶
- Constants
- Variables
- func AcceptHeader(accept string) func(next http.Handler) http.Handler
- func AdminOnly(w http.ResponseWriter, req *http.Request) error
- func AdminOnlyWithRedirect(w http.ResponseWriter, req *http.Request) error
- func AdminOrItselfOnly(w http.ResponseWriter, req *http.Request, nickname string) error
- func BandwithLimiterMiddleware(max int64) func(next http.Handler) http.Handler
- func BlockByCountryMiddleware(blockedCountries []string) func(http.Handler) http.Handler
- func BlockPostWithoutReferer(next http.Handler) http.Handler
- func CORSHeader(origin string) func(next http.Handler) http.Handler
- func CheckDNS(url string) error
- func CreateDefaultConfigFileIfNecessary() bool
- func DB() error
- func Debug(message string)
- func DisconnectDB()
- func DoLetsEncrypt() (string, string)
- func EnsureHostname(next http.Handler) http.Handler
- func Error(message string, err error)
- func Fatal(message string, err error)
- func FileExists(path string) bool
- func GenerateEd25519Certificates() (string, string)
- func GenerateRSAWebCertificates(domains []string) (string, string)
- func GenerateRandomString(n int) string
- func GetAllHostnames(applyWildCard bool, removePorts bool) []string
- func GetAvailableRAM() uint64
- func GetCPUUsage() []float64
- func GetClientIP(req *http.Request) string
- func GetCollection(applicationId string, collection string) (*mongo.Collection, error)
- func GetConfigFileName() string
- func GetIPLocation(ip string) (string, error)
- func GetPrivateAuthKey() string
- func GetPublicAuthKey() string
- func GetRAMUsage() uint64
- func GetRootAppId() string
- func GetServerURL() string
- func HTTPError(w http.ResponseWriter, message string, code int, userCode string)
- func HasAnyNewItem(after []string, before []string) bool
- func ImageToBase64(path string) (string, error)
- func IsAdmin(req *http.Request) bool
- func IsEmailEnabled() bool
- func IsValidHostname(hostname string) bool
- func LetsEncryptValidOnly(hostnames []string, acceptWildcard bool) []string
- func LoadBaseMainConfig(config Config)
- func Log(message string)
- func LoggedInOnly(w http.ResponseWriter, req *http.Request) error
- func LoggedInOnlyWithRedirect(w http.ResponseWriter, req *http.Request) error
- func LoggedInWeakOnly(w http.ResponseWriter, req *http.Request) error
- func Max(x, y int) int
- func MiddlewareTimeout(timeout time.Duration) func(next http.Handler) http.Handler
- func RestartServer()
- func Sanitize(s string) string
- func SanitizeSafe(s string) string
- func SaveConfigTofile(config Config)
- func SendEmail(recipients []string, subject string, body string) error
- func SetBaseMainConfig(config Config)
- func SetSecurityHeaders(next http.Handler) http.Handler
- func StringArrayContains(a []string, b string) bool
- func StringArrayEquals(a []string, b []string) bool
- func Warn(message string)
- type AddionalFiltersConfig
- type CertUser
- type Config
- type DiskStatus
- type DockerConfig
- type EmailConfig
- type FileStats
- type HTTPConfig
- type HTTPErrorResult
- type HomepageConfig
- type LoggingLevel
- type MarketConfig
- type MarketSource
- type MyUser
- type NetworkStatus
- type OpenIDClient
- type ProxyConfig
- type ProxyMode
- type ProxyRouteConfig
- type Role
- type SmartShieldPolicy
- type ThemeConfig
- type User
Constants ¶
View Source
const ( GUEST = 0 USER = 1 ADMIN = 2 )
View Source
const ( DEBUG = 0 INFO = 1 WARNING = 2 ERROR = 3 )
View Source
const ( STRICT = 1 NORMAL = 2 LENIENT = 3 )
Variables ¶
View Source
var AlphaNumRunes = []rune("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
View Source
var Blue = "\033[34m"
View Source
var ConfigLock sync.Mutex
View Source
var Cyan = "\033[36m"
View Source
var DefaultConfig = Config{ LoggingLevel: "INFO", NewInstall: true, AutoUpdate: true, BlockedCountries: []string{ "CN", "RU", "TR", "BR", "BD", "IN", "NP", "PK", "LK", "VN", "ID", "IR", "IQ", "EG", "AF", "RO", }, HTTPConfig: HTTPConfig{ HTTPSCertificateMode: "DISABLED", GenerateMissingAuthCert: true, HTTPPort: "80", HTTPSPort: "443", Hostname: "0.0.0.0", ProxyConfig: ProxyConfig{ Routes: []ProxyRouteConfig{}, }, }, DockerConfig: DockerConfig{ DefaultDataPath: "/usr", }, MarketConfig: MarketConfig{ Sources: []MarketSource{}, }, }
View Source
var Gray = "\033[37m"
View Source
var Green = "\033[32m"
View Source
var HTTPSCertModeList = map[string]string{
"DISABLED": "DISABLED",
"PROVIDED": "PROVIDED",
"SELFSIGNED": "SELFSIGNED",
"LETSENCRYPT": "LETSENCRYPT",
}
View Source
var IsHTTPS = false
View Source
var LetsEncryptErrors = []string{}
View Source
var LoggingLevelLabels = map[LoggingLevel]int{ "DEBUG": DEBUG, "INFO": INFO, "WARNING": WARNING, "ERROR": ERROR, }
View Source
var NeedsRestart = false
View Source
var NewVersionAvailable = false
View Source
var ProxyModeList = map[string]string{
"PROXY": "PROXY",
"SPA": "SPA",
"STATIC": "STATIC",
"SERVAPP": "SERVAPP",
"REDIRECT": "REDIRECT",
}
View Source
var Purple = "\033[35m"
View Source
var ReBootstrapContainer func(string) error
View Source
var Red = "\033[31m"
View Source
var Reset = "\033[0m"
View Source
var RestartHTTPServer func()
View Source
var Template = `` /* 1110-byte string literal not displayed */
View Source
var UpdateAvailable = map[string]bool{}
View Source
var Validate = validator.New()
View Source
var White = "\033[97m"
View Source
var Yellow = "\033[33m"
Functions ¶
func AdminOnlyWithRedirect ¶
func AdminOnlyWithRedirect(w http.ResponseWriter, req *http.Request) error
func AdminOrItselfOnly ¶
func BlockByCountryMiddleware ¶
BlockByCountryMiddleware returns a middleware function that blocks requests from specified countries.
func BlockPostWithoutReferer ¶
blockPostWithoutReferer blocks POST requests without a Referer header
func CreateDefaultConfigFileIfNecessary ¶
func CreateDefaultConfigFileIfNecessary() bool
func DisconnectDB ¶
func DisconnectDB()
func DoLetsEncrypt ¶
func FileExists ¶
func GenerateRandomString ¶
func GetAllHostnames ¶
func GetAvailableRAM ¶
func GetAvailableRAM() uint64
func GetCPUUsage ¶
func GetCPUUsage() []float64
func GetClientIP ¶ added in v0.9.17
func GetCollection ¶
func GetCollection(applicationId string, collection string) (*mongo.Collection, error)
func GetConfigFileName ¶
func GetConfigFileName() string
func GetIPLocation ¶
GetIPLocation returns the ISO country code for a given IP address.
func GetPrivateAuthKey ¶
func GetPrivateAuthKey() string
func GetPublicAuthKey ¶
func GetPublicAuthKey() string
func GetRAMUsage ¶
func GetRAMUsage() uint64
func GetRootAppId ¶
func GetRootAppId() string
func GetServerURL ¶
func GetServerURL() string
func HasAnyNewItem ¶
func ImageToBase64 ¶
func IsEmailEnabled ¶
func IsEmailEnabled() bool
func IsValidHostname ¶
func LetsEncryptValidOnly ¶
func LoadBaseMainConfig ¶
func LoadBaseMainConfig(config Config)
func LoggedInOnly ¶
func LoggedInOnly(w http.ResponseWriter, req *http.Request) error
func LoggedInOnlyWithRedirect ¶
func LoggedInOnlyWithRedirect(w http.ResponseWriter, req *http.Request) error
func LoggedInWeakOnly ¶
func LoggedInWeakOnly(w http.ResponseWriter, req *http.Request) error
func MiddlewareTimeout ¶
func RestartServer ¶
func RestartServer()
func SanitizeSafe ¶
func SaveConfigTofile ¶
func SaveConfigTofile(config Config)
func SetBaseMainConfig ¶
func SetBaseMainConfig(config Config)
func StringArrayContains ¶
func StringArrayEquals ¶
Types ¶
type AddionalFiltersConfig ¶ added in v0.9.9
type CertUser ¶
type CertUser struct { Email string Registration *registration.Resource // contains filtered or unexported fields }
func (*CertUser) GetPrivateKey ¶
func (u *CertUser) GetPrivateKey() crypto.PrivateKey
func (CertUser) GetRegistration ¶
func (u CertUser) GetRegistration() *registration.Resource
type Config ¶
type Config struct { LoggingLevel LoggingLevel `required,validate:"oneof=DEBUG INFO WARNING ERROR"` MongoDB string DisableUserManagement bool NewInstall bool `validate:"boolean"` HTTPConfig HTTPConfig `validate:"required,dive,required"` EmailConfig EmailConfig `validate:"required,dive,required"` DockerConfig DockerConfig BlockedCountries []string ServerCountry string RequireMFA bool AutoUpdate bool OpenIDClients []OpenIDClient MarketConfig MarketConfig HomepageConfig HomepageConfig ThemeConfig ThemeConfig }
var BaseMainConfig Config
var MainConfig Config
func GetBaseMainConfig ¶
func GetBaseMainConfig() Config
func GetMainConfig ¶
func GetMainConfig() Config
func ReadConfigFromFile ¶
func ReadConfigFromFile() Config
type DiskStatus ¶
func GetDiskUsage ¶
func GetDiskUsage() []DiskStatus
type DockerConfig ¶
type EmailConfig ¶
type HTTPConfig ¶
type HTTPConfig struct { TLSCert string `validate:"omitempty,contains=\n` TLSKey string TLSKeyHostsCached []string TLSValidUntil time.Time AuthPrivateKey string AuthPublicKey string GenerateMissingAuthCert bool HTTPSCertificateMode string DNSChallengeProvider string ForceHTTPSCertificateRenewal bool HTTPPort string `validate:"required,containsany=0123456789,min=1,max=6"` HTTPSPort string `validate:"required,containsany=0123456789,min=1,max=6"` ProxyConfig ProxyConfig Hostname string `validate:"required,excludesall=0x2C/ "` SSLEmail string `validate:"omitempty,email"` UseWildcardCertificate bool OverrideWildcardDomains string `validate:"omitempty,excludesall=/ "` AcceptAllInsecureHostname bool DNSChallengeConfig map[string]string `json:"DNSChallengeConfig,omitempty"` }
type HTTPErrorResult ¶
type HomepageConfig ¶
type LoggingLevel ¶
type LoggingLevel string
type MarketConfig ¶
type MarketConfig struct {
Sources []MarketSource
}
type MarketSource ¶
type MyUser ¶
type MyUser struct { Email string Registration *registration.Resource // contains filtered or unexported fields }
You'll need a user or account type that implements acme.User
func (*MyUser) GetPrivateKey ¶
func (u *MyUser) GetPrivateKey() crypto.PrivateKey
func (MyUser) GetRegistration ¶
func (u MyUser) GetRegistration() *registration.Resource
type NetworkStatus ¶
func GetNetworkUsage ¶
func GetNetworkUsage() NetworkStatus
type OpenIDClient ¶
type ProxyConfig ¶
type ProxyConfig struct {
Routes []ProxyRouteConfig
}
type ProxyRouteConfig ¶
type ProxyRouteConfig struct { Name string `validate:"required"` Description string UseHost bool Host string UsePathPrefix bool PathPrefix string Timeout time.Duration ThrottlePerMinute int CORSOrigin string StripPathPrefix bool MaxBandwith int64 AuthEnabled bool AdminOnly bool Target string `validate:"required"` SmartShield SmartShieldPolicy Mode ProxyMode BlockCommonBots bool BlockAPIAbuse bool AcceptInsecureHTTPSTarget bool HideFromDashboard bool DisableHeaderHardening bool VerboseForwardHeader bool AddionalFilters []AddionalFiltersConfig }
type SmartShieldPolicy ¶
type ThemeConfig ¶
type User ¶
type User struct { ID primitive.ObjectID `json:"-" bson:"_id,omitempty"` Nickname string `validate:"required" json:"nickname"` Password string `validate:"required" json:"-"` RegisterKey string `json:"registerKey"` RegisterKeyExp time.Time `json:"registerKeyExp"` Role Role `validate:"required" json:"role"` PasswordCycle int `json:"-"` Link string `json:"link"` Email string `validate:"email" json:"email"` RegisteredAt time.Time `json:"registeredAt"` LastPasswordChangedAt time.Time `json:"lastPasswordChangedAt"` CreatedAt time.Time `json:"createdAt"` LastLogin time.Time `json:"lastLogin"` MFAKey string `json:"-"` Was2FAVerified bool `json:"-"` MFAState int `json:"-"` // 0 = done, 1 = needed, 2 = not set }
Click to show internal directories.
Click to hide internal directories.