improve logging and add disable form feature
This commit is contained in:
@@ -76,3 +76,4 @@ http://localhost:8080/raw/https://www.google.com
|
|||||||
| `X_FORWARDED_FOR` | IP forwarder address | `66.249.66.1` |
|
| `X_FORWARDED_FOR` | IP forwarder address | `66.249.66.1` |
|
||||||
| `USERPASS` | Enables Basic Auth, format `admin:123456` | `` |
|
| `USERPASS` | Enables Basic Auth, format `admin:123456` | `` |
|
||||||
| `LOG_URLS` | Log fetched URL's | `true` |
|
| `LOG_URLS` | Log fetched URL's | `true` |
|
||||||
|
| `DISABLE_FORM` | Disables URL Form Frontpage | `false` |
|
||||||
|
|||||||
14
cmd/main.go
14
cmd/main.go
@@ -41,7 +41,19 @@ func main() {
|
|||||||
URL: "/favicon.ico",
|
URL: "/favicon.ico",
|
||||||
}))
|
}))
|
||||||
|
|
||||||
app.Get("/", handlers.Form)
|
if os.Getenv("NOLOGS") != "true" {
|
||||||
|
app.Use(func(c *fiber.Ctx) error {
|
||||||
|
log.Println(c.Method(), c.Path())
|
||||||
|
return c.Next()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if os.Getenv("DISABLE_FORM") != "true" {
|
||||||
|
app.Get("/", handlers.Form)
|
||||||
|
} else {
|
||||||
|
app.Get("/", handlers.NoForm)
|
||||||
|
}
|
||||||
|
|
||||||
app.Get("raw/*", handlers.Raw)
|
app.Get("raw/*", handlers.Raw)
|
||||||
app.Get("api/*", handlers.Api)
|
app.Get("api/*", handlers.Api)
|
||||||
app.Get("/*", handlers.ProxySite)
|
app.Get("/*", handlers.ProxySite)
|
||||||
|
|||||||
@@ -2,6 +2,12 @@ package handlers
|
|||||||
|
|
||||||
import "github.com/gofiber/fiber/v2"
|
import "github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
|
func NoForm(c *fiber.Ctx) error {
|
||||||
|
c.Set("Content-Type", "text/html")
|
||||||
|
c.SendStatus(fiber.StatusNotFound)
|
||||||
|
return c.SendString("Form Disabled")
|
||||||
|
}
|
||||||
|
|
||||||
func Form(c *fiber.Ctx) error {
|
func Form(c *fiber.Ctx) error {
|
||||||
c.Set("Content-Type", "text/html")
|
c.Set("Content-Type", "text/html")
|
||||||
return c.SendString(html)
|
return c.SendString(html)
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ func fetchSite(urlpath string, queries map[string]string) (string, *http.Request
|
|||||||
return "", nil, nil, err
|
return "", nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.Getenv("LOG_URLS ") == "" || os.Getenv("NOLOGS") == "true" {
|
if os.Getenv("DEBUG ") == "true" {
|
||||||
log.Println(u.String() + urlQuery)
|
log.Println(u.String() + urlQuery)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user