move auth and favicon form main to handlers, linting

This commit is contained in:
ladddder
2023-12-05 16:00:31 +01:00
parent 692b2a5d17
commit f437bcabf3
13 changed files with 249 additions and 226 deletions

25
handlers/auth.go Normal file
View File

@@ -0,0 +1,25 @@
package handlers
import (
"os"
"strings"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/basicauth"
)
func Auth() fiber.Handler {
userpass := os.Getenv("USERPASS")
if userpass != "" {
userpass := strings.Split(userpass, ":")
return basicauth.New(basicauth.Config{
Users: map[string]string{
userpass[0]: userpass[1],
},
})
}
return func(c *fiber.Ctx) error {
return c.Next()
}
}

18
handlers/favicon.go Normal file
View File

@@ -0,0 +1,18 @@
package handlers
import (
_ "embed"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/favicon"
)
//go:embed favicon.ico
var faviconData string
func Favicon() fiber.Handler {
return favicon.New(favicon.Config{
Data: []byte(faviconData),
URL: "/favicon.ico",
})
}

BIN
handlers/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -33,13 +33,13 @@ func NewProxySiteHandler(opts *ProxyOptions) fiber.Handler {
SetRequestModifications(
// rx.SpoofJA3fingerprint(ja3, "Googlebot"),
// rx.MasqueradeAsFacebookBot(),
//rx.MasqueradeAsGoogleBot(),
// rx.MasqueradeAsGoogleBot(),
rx.DeleteOutgoingCookies(),
rx.ForwardRequestHeaders(),
//rx.SpoofReferrerFromGoogleSearch(),
// rx.SpoofReferrerFromGoogleSearch(),
rx.SpoofReferrerFromLinkedInPost(),
//rx.RequestWaybackMachine(),
//rx.RequestArchiveIs(),
// rx.RequestWaybackMachine(),
// rx.RequestArchiveIs(),
).
AddResponseModifications(
tx.ForwardResponseHeaders(),