handler

package
v0.0.0-...-5d87fb3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UNAUTHORIZED = "You are not allowed to view that content"
)

Variables

This section is empty.

Functions

func DateEqual

func DateEqual(date1, date2 time.Time) bool

compare two dates

Types

type CustomValidator

type CustomValidator struct {
	Validator *validator.Validate
}

func (*CustomValidator) Validate

func (cv *CustomValidator) Validate(i interface{}) error

Validate implements the Validator.

type Envs

type Envs struct {
	AdminLogin string
	Domains    []string
}

type Error

type Error struct {
	Message string `json:"message"`
}

type Handler

type Handler struct {
	DB               *gorm.DB
	AuthAdmin        bool
	Config           Envs
	Title            string
	DisableAdminAuth bool
	LastClearedLogs  time.Time
	ClearInterval    uint64
	AllowWildcard    bool
	LogoutUrl        string
}

func (*Handler) AddCName

func (h *Handler) AddCName(c echo.Context) (err error)

AddCName just renders the "add cname" website. Therefore all host entries from the database are being fetched.

func (*Handler) AddHost

func (h *Handler) AddHost(c echo.Context) (err error)

AddHost just renders the "add host" website.

func (*Handler) AuthenticateAdmin

func (h *Handler) AuthenticateAdmin(username, password string, c echo.Context) (bool, error)

func (*Handler) AuthenticateUpdate

func (h *Handler) AuthenticateUpdate(username, password string, c echo.Context) (bool, error)

Authenticate is the method the website admin user and the host update user have to authenticate against. To gather admin rights the username password combination must match with the credentials given by the env var.

func (*Handler) CheckClearInterval

func (h *Handler) CheckClearInterval()

Check if a log cleaning is needed

func (*Handler) ClearLogs

func (h *Handler) ClearLogs()

func (*Handler) CreateCName

func (h *Handler) CreateCName(c echo.Context) (err error)

CreateCName validates the cname data from the "add cname" website, adds the cname entry to the database, and adds the entry to the DNS server.

func (*Handler) CreateHost

func (h *Handler) CreateHost(c echo.Context) (err error)

CreateHost validates the host data from the "add host" website, adds the host entry to the database, and adds the entry to the DNS server.

func (*Handler) CreateLogEntry

func (h *Handler) CreateLogEntry(log *model.Log) (err error)

CreateLogEntry simply adds a log entry to the database.

func (*Handler) DeleteCName

func (h *Handler) DeleteCName(c echo.Context) (err error)

DeleteCName fetches a cname entry from the database by "id" and deletes the database and DNS server entry to it.

func (*Handler) DeleteHost

func (h *Handler) DeleteHost(c echo.Context) (err error)

DeleteHost fetches a host entry from the database by "id" and deletes the database and DNS server entry to it.

func (*Handler) EditHost

func (h *Handler) EditHost(c echo.Context) (err error)

EditHost fetches a host by "id" and renders the "edit host" website.

func (*Handler) GetHost

func (h *Handler) GetHost(c echo.Context) (err error)

GetHost fetches a host from the database by "id".

func (*Handler) InitDB

func (h *Handler) InitDB() (err error)

InitDB creates an empty database and creates all tables if there isn't already one, or opens the existing one.

func (*Handler) ListCNames

func (h *Handler) ListCNames(c echo.Context) (err error)

ListCNames fetches all cnames from database and lists them on the website.

func (*Handler) ListHosts

func (h *Handler) ListHosts(c echo.Context) (err error)

ListHosts fetches all hosts from database and lists them on the website.

func (*Handler) ParseEnvs

func (h *Handler) ParseEnvs() (adminAuth bool, err error)

ParseEnvs parses all needed environment variables: DDNS_ADMIN_LOGIN: The basic auth login string in htpasswd style. DDNS_DOMAINS: All domains that will be handled by the dyndns server.

func (*Handler) ShowHostLogs

func (h *Handler) ShowHostLogs(c echo.Context) (err error)

ShowHostLogs fetches all log entries of a specific host by "id" and renders them to the website.

func (*Handler) ShowLogs

func (h *Handler) ShowLogs(c echo.Context) (err error)

ShowLogs fetches all log entries from all hosts and renders them to the website.

func (*Handler) UpdateHost

func (h *Handler) UpdateHost(c echo.Context) (err error)

UpdateHost validates the host data from the "edit host" website, and compares the host data with the entry in the database by "id". If anything has changed the database and DNS entries for the host will be updated.

func (*Handler) UpdateIP

func (h *Handler) UpdateIP(c echo.Context) (err error)

UpdateIP implements the update method called by the routers. Hostname, IP and senders IP are validated, a log entry is created and finally if everything is ok, the DNS Server will be updated

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL