lib

package
v2.2.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2017 License: MIT Imports: 18 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SendOptions = telebot.SendOptions{DisableWebPagePreview: true, ParseMode: telebot.ModeMarkdown}

Functions

func CleanDatabase

func CleanDatabase()

Removes all check-results older than one month from the Database

func GetDatabase

func GetDatabase() *sql.DB

Returns the current Database-object.

func GetHttpStatus

func GetHttpStatus(code int) string

Returns a HTTP-status-code-string representing the given HTTP-status-code.

func InitHttpStatusCodeMap

func InitHttpStatusCodeMap()

Init the httpCodes-map.

func InitSessionManagement

func InitSessionManagement()

Init the cookieStorage-map.

func IsLoggedIn

func IsLoggedIn(r *http.Request) bool

Checks if the given Request contains a Cookie and if the Cookie authenticates a specific user.

func LoginAndGetCookie

func LoginAndGetCookie(username string) http.Cookie

Logs the user in by returning a Cookie containing a randomId.

func LogoutAndDestroyCookie

func LogoutAndDestroyCookie(r *http.Request) http.Cookie

Logs the user out by returning a Cookie, which expired a day ago.

func OpenDatabase

func OpenDatabase(config databaseConfiguration)

Opens a new connection-pool to the database using the given databaseConfiguration.

func ReadConfigurationFromDatabase

func ReadConfigurationFromDatabase(db *sql.DB)

Reads all configuration-data from the database.

func ReadConfigurationFromFile

func ReadConfigurationFromFile(filePath string)

Reads a configuration-file from a specified path.

func ReadDefaultConfiguration

func ReadDefaultConfiguration(filePath string)

Reads the default configuration-file from a specified path.

func RunTelegramBot

func RunTelegramBot()

func SetStaticConfiguration

func SetStaticConfiguration(c StaticConfiguration)

Allows to replace the current StaticConfiguration.

func SetupLogger

func SetupLogger()

Init the logger.

Types

type Admin

type Admin struct {
	// contains filtered or unexported fields
}

Contains the current password hash.

func (*Admin) Add

func (a *Admin) Add()

Adds a new admin user to the database.

func (*Admin) ChangePassword

func (a *Admin) ChangePassword(userInput string) error

Changes the current password to the given one. Returns an error (if there was one).

func (*Admin) Init

func (a *Admin) Init()

Init an Admin-struct. Creates an Admin user if there is none.

func (*Admin) LoadPassword

func (a *Admin) LoadPassword() bool

Loads the current password hash into the Admin-struct. Returns true, if there was a password hash in the database or false, if not.

func (*Admin) ValidatePassword

func (a *Admin) ValidatePassword(userInput string) bool

Validates the entered password. Returns true, if the password matched the stored hash and false, if not.

type Configuration

type Configuration struct {
	Address      string
	Port         int
	Database     databaseConfiguration
	Application  applicationConfiguration
	Notification notificationConfiguration
	Dynamic      dynamicConfiguration
	Static       StaticConfiguration
}

The whole configuration. Contains all other configuration-data.

func GetConfiguration

func GetConfiguration() *Configuration

Returns the current Configuration-object.

type StaticConfiguration

type StaticConfiguration struct {
	Version   string
	GoVersion string
	GoArch    string
}

Static data about (e.g.) the application's version.

type Website

type Website struct {
	Id          int
	Protocol    string
	Url         string
	CheckMethod string
}

Represents a single Website-object.

func (*Website) RunCheck

func (w *Website) RunCheck(secondTry bool)

Runs a check and saves the result inside the database.

Jump to

Keyboard shortcuts

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