mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 08:11:11 +08:00
24w18e
This commit is contained in:
parent
e5d941414e
commit
aee81ba4fd
3 changed files with 7 additions and 7 deletions
|
|
@ -6,7 +6,7 @@ import (
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Server ServerConfig
|
Server ServerConfig
|
||||||
Page PageConfig
|
Pages PagesConfig
|
||||||
Log LogConfig
|
Log LogConfig
|
||||||
CORS CORSConfig
|
CORS CORSConfig
|
||||||
Auth AuthConfig
|
Auth AuthConfig
|
||||||
|
|
@ -20,7 +20,7 @@ type ServerConfig struct {
|
||||||
SizeLimit int `toml:"sizeLimit"`
|
SizeLimit int `toml:"sizeLimit"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PageConfig struct {
|
type PagesConfig struct {
|
||||||
Enabled bool `toml:"enabled"`
|
Enabled bool `toml:"enabled"`
|
||||||
StaticDir string `toml:"staticDir"`
|
StaticDir string `toml:"staticDir"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ host = "127.0.0.1"
|
||||||
port = 8080
|
port = 8080
|
||||||
sizeLimit = 131072000 # 125MB
|
sizeLimit = 131072000 # 125MB
|
||||||
|
|
||||||
[page]
|
[pages]
|
||||||
enabled = true
|
enabled = true
|
||||||
staticDir = "/data/www"
|
staticDir = "/data/www"
|
||||||
|
|
||||||
|
|
|
||||||
8
main.go
8
main.go
|
|
@ -79,14 +79,14 @@ func init() {
|
||||||
|
|
||||||
setupApi(cfg, router)
|
setupApi(cfg, router)
|
||||||
|
|
||||||
if cfg.Page.Enabled {
|
if cfg.Pages.Enabled {
|
||||||
indexPagePath := fmt.Sprintf("%s/index.html", cfg.Page.StaticDir)
|
indexPagePath := fmt.Sprintf("%s/index.html", cfg.Pages.StaticDir)
|
||||||
faviconPath := fmt.Sprintf("%s/favicon.ico", cfg.Page.StaticDir)
|
faviconPath := fmt.Sprintf("%s/favicon.ico", cfg.Pages.StaticDir)
|
||||||
// 静态index页
|
// 静态index页
|
||||||
router.StaticFile("/", indexPagePath)
|
router.StaticFile("/", indexPagePath)
|
||||||
// 静态favicon.ico
|
// 静态favicon.ico
|
||||||
router.StaticFile("/favicon.ico", faviconPath)
|
router.StaticFile("/favicon.ico", faviconPath)
|
||||||
} else if !cfg.Page.Enabled {
|
} else if !cfg.Pages.Enabled {
|
||||||
router.GET("/", func(c *gin.Context) {
|
router.GET("/", func(c *gin.Context) {
|
||||||
c.String(http.StatusForbidden, "403 Forbidden This route is not allowed to access.")
|
c.String(http.StatusForbidden, "403 Forbidden This route is not allowed to access.")
|
||||||
LogWarning("Forbidden: IP:%s UA:%s METHOD:%s HTTPv:%s", c.ClientIP(), c.Request.UserAgent(), c.Request.Method, c.Request.Proto)
|
LogWarning("Forbidden: IP:%s UA:%s METHOD:%s HTTPv:%s", c.ClientIP(), c.Request.UserAgent(), c.Request.Method, c.Request.Proto)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue