Documentation
¶
Overview ¶
Date: 2023/11/25 Created By ybenel
Date: 23/06/2019 Created By ybenel
Date: 2023/07/25 Middleware for authentication/Logging.
Date: 23/06/2019 Created By ybenel
Date: 21/06/2019 || 2023/09/11 Created By ybenel
Index ¶
- Variables
- func ParseFlags(cfg *Config)
- type App
- func (a *App) Deniedhandler(w http.ResponseWriter, r *http.Request, error *ErrorHandler)
- func (a *App) FailedSession(w http.ResponseWriter, r *http.Request)
- func (app *App) GetLogger() *mylog.Logger
- func (a *App) MediaAcess(w http.ResponseWriter, r *http.Request, restricted bool) (bool, error)
- func (a *App) Run() error
- func (a *App) Unfoundhandler(w http.ResponseWriter, r *http.Request)
- type Config
- type DebugConfig
- type ErrorHandler
- type FeedConfig
- type MData
- type Middleware
- func (m *Middleware) AuthMiddleware(next http.Handler) http.Handler
- func (m *Middleware) AuthenticateAndSetSession(username, password string, w http.ResponseWriter, r *http.Request) bool
- func (m *Middleware) InitializeDB() error
- func (m *Middleware) LogUser(r *http.Request)
- func (m *Middleware) SignUpAndSetSession(name, password, email string, w http.ResponseWriter, r *http.Request) (bool, error)
- type PathConfig
- type ServerConfig
- type StremioConfig
- type TorConfig
- type TorControllerConfig
Constants ¶
This section is empty.
Variables ¶
var ( //DefaultLoggerPrintFunc is fmt.Printf without return values DefaultLoggerPrintFunc = func(format string, data ...interface{}) { fmt.Printf(format+"\n", data...) } )
Functions ¶
func ParseFlags ¶
func ParseFlags(cfg *Config)
Types ¶
type App ¶
type App struct { Config *Config Middleware *Middleware Library *media.Library Watcher *fsnotify.Watcher Templates *template.Template Tor *tor Listener net.Listener Router *mux.Router Sessions *sessions.CookieStore Mdata MData Logger *mylog.Logger Debug *DebugConfig }
App represents main application.
func (*App) Deniedhandler ¶
func (a *App) Deniedhandler(w http.ResponseWriter, r *http.Request, error *ErrorHandler)
func (*App) FailedSession ¶
func (a *App) FailedSession(w http.ResponseWriter, r *http.Request)
Failed Sessions
func (*App) MediaAcess ¶
Restricted Acesss and authentication
func (*App) Unfoundhandler ¶
func (a *App) Unfoundhandler(w http.ResponseWriter, r *http.Request)
404 Page handler
type Config ¶
type Config struct { Library []*PathConfig `json:"library"` Server *ServerConfig `json:"server"` Feed *FeedConfig `json:"feed"` Tor *TorConfig `json:"tor,omitempty"` Stremio *StremioConfig `json:"stremio"` }
Config settings for main App.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns Config initialized with default values.
type DebugConfig ¶
func (*DebugConfig) DefaultConfig ¶
func (Conf *DebugConfig) DefaultConfig() *errlog.Config
func (*DebugConfig) NewDebug ¶
func (c *DebugConfig) NewDebug() errlog.Logger
type ErrorHandler ¶
type ErrorHandler struct {
Error string
}
type FeedConfig ¶
type FeedConfig struct { ExternalURL string `json:"external_url"` Title string `json:"title"` Link string `json:"link"` Description string `json:"description"` Author struct { Name string `json:"name"` Email string `json:"email"` } `json:"author"` Copyright string `json:"copyright"` }
FeedConfig settings for App Feed.
type Middleware ¶
func (*Middleware) AuthMiddleware ¶
func (m *Middleware) AuthMiddleware(next http.Handler) http.Handler
Main Middleware
func (*Middleware) AuthenticateAndSetSession ¶
func (m *Middleware) AuthenticateAndSetSession(username, password string, w http.ResponseWriter, r *http.Request) bool
Function to authenticate a user and set the session
func (*Middleware) InitializeDB ¶
func (m *Middleware) InitializeDB() error
Initialize the SQLite database connection
func (*Middleware) LogUser ¶
func (m *Middleware) LogUser(r *http.Request)
Log Visitor Ip And User-Agent (Can be disabled on the cmd options).
func (*Middleware) SignUpAndSetSession ¶
func (m *Middleware) SignUpAndSetSession(name, password, email string, w http.ResponseWriter, r *http.Request) (bool, error)
Sign up and set set a session
type PathConfig ¶
type PathConfig struct { Path string `json:"path"` Prefix string `json:"prefix"` Private bool `json:"private"` }
PathConfig settings for media library path.
type ServerConfig ¶
type ServerConfig struct { Host string `json:"host"` Port int `json:"port"` Logging bool `json:"logging"` Regisration bool `json:"registration"` Tls bool `json:"tls"` TlsCert string `json:"cert"` TlsKey string `json:"keyfile"` }
ServerConfig settings for App Server.
type TorConfig ¶
type TorConfig struct { Enable bool `json:"enable"` Controller *TorControllerConfig `json:"controller"` }
TorConfig stores tor configuration.
type TorControllerConfig ¶
type TorControllerConfig struct { Host string `json:"host"` Port int `json:"port"` Password string `json:"password,omitempty"` }
TorControllerConfig stores tor controller configuration.