server

package
v1.1.12 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: Unlicense Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CDNLimter = rate_limiter.New(rate_limiter.Config{
	Max:        6,
	Expiration: 1 * time.Second,
	KeyGenerator: func(c *fiber.Ctx) string {
		return c.Get("x-forwarded-for")
	},
	LimitReached: func(c *fiber.Ctx) error {
		ip_address := c.IP()
		log_message := fmt.Sprintf("%s === %s === %s === PUBLIC RATE LIMIT REACHED !!!", ip_address, c.Method(), c.Path())
		log.Info(log_message)
		c.Set("Content-Type", "text/html")
		return c.SendString("<html><h1>loading ...</h1><script>setTimeout(function(){ window.location.reload(1); }, 6000);</script></html>")
	},
})
View Source
var PublicLimter = rate_limiter.New(rate_limiter.Config{
	Max:        3,
	Expiration: 1 * time.Second,
	KeyGenerator: func(c *fiber.Ctx) string {
		return c.Get("x-forwarded-for")
	},
	LimitReached: func(c *fiber.Ctx) error {
		ip_address := c.IP()
		log_message := fmt.Sprintf("%s === %s === %s === PUBLIC RATE LIMIT REACHED !!!", ip_address, c.Method(), c.Path())
		log.Info(log_message)
		c.Set("Content-Type", "text/html")
		return c.SendString("<html><h1>loading ...</h1><script>setTimeout(function(){ window.location.reload(1); }, 6000);</script></html>")
	},
})

Functions

This section is empty.

Types

type Server

type Server struct {
	FiberApp *fiber.App        `yaml:"fiber_app"`
	Config   *types.ConfigFile `yaml:"config"`
	Location *time.Location    `yaml:"-"`
}

func New

func New(config *types.ConfigFile) (server Server)

func (*Server) GetFormattedTimeString

func (s *Server) GetFormattedTimeString() (result string)

func (*Server) GetLogMessages added in v1.1.2

func (s *Server) GetLogMessages(c *fiber.Ctx) error

func (*Server) GetLogMessagesWithKey added in v1.1.4

func (s *Server) GetLogMessagesWithKey(c *fiber.Ctx) error

func (*Server) HandleLogin

func (s *Server) HandleLogin(context *fiber.Ctx) error

POST http://localhost:5950/admin/login

func (*Server) HandleLogout

func (s *Server) HandleLogout(context *fiber.Ctx) error

func (*Server) LogMessage added in v1.1.3

func (s *Server) LogMessage(c *fiber.Ctx) error

func (*Server) LogMessageWithKey added in v1.1.4

func (s *Server) LogMessageWithKey(c *fiber.Ctx) error

func (*Server) LogRequest

func (s *Server) LogRequest(context *fiber.Ctx) error

func (*Server) RenderFailedLogin

func (s *Server) RenderFailedLogin(context *fiber.Ctx) error

func (*Server) RenderHomePage

func (s *Server) RenderHomePage(context *fiber.Ctx) error

func (*Server) RenderLoginPage

func (s *Server) RenderLoginPage(context *fiber.Ctx) error

func (*Server) SetupAdminRoutes

func (s *Server) SetupAdminRoutes()

func (*Server) SetupPublicRoutes

func (s *Server) SetupPublicRoutes()

func (*Server) Start

func (s *Server) Start()

func (*Server) ValidateAdmin

func (s *Server) ValidateAdmin(context *fiber.Ctx) (result bool)

func (*Server) ValidateAdminMW

func (s *Server) ValidateAdminMW(context *fiber.Ctx) error

func (*Server) ValidateLoginCredentials

func (s *Server) ValidateLoginCredentials(context *fiber.Ctx) (result bool)

Jump to

Keyboard shortcuts

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