Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
13f95ee895 | |||
99c0137034 | |||
64551704a3 |
13
main.go
13
main.go
@ -114,12 +114,13 @@ func main() {
|
||||
r.Use(RealIPMiddleware)
|
||||
r.Use(logger.Logger("router", log.StandardLogger()))
|
||||
|
||||
r.HandleFunc("/status", statusHandler)
|
||||
r.HandleFunc("/mirrors", mirrorsHandler)
|
||||
r.HandleFunc("/reload", reloadHandler)
|
||||
r.HandleFunc("/dl_map", dlMapHandler)
|
||||
r.Handle("/metrics", promhttp.Handler())
|
||||
r.HandleFunc("/", redirectHandler)
|
||||
r.Get("/status", statusHandler)
|
||||
r.Get("/mirrors", mirrorsHandler)
|
||||
r.Post("/reload", reloadHandler)
|
||||
r.Get("/dl_map", dlMapHandler)
|
||||
r.Get("/metrics", promhttp.Handler().ServeHTTP)
|
||||
|
||||
r.NotFound(redirectHandler)
|
||||
|
||||
go http.ListenAndServe(viper.GetString("bind"), r)
|
||||
|
||||
|
@ -29,7 +29,9 @@ func RealIPMiddleware(f http.Handler) http.Handler {
|
||||
return
|
||||
}
|
||||
|
||||
if !net.ParseIP(host).IsPrivate() {
|
||||
netIP := net.ParseIP(host)
|
||||
|
||||
if !netIP.IsLoopback() && !netIP.IsPrivate() {
|
||||
f.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user