mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -07:00
fix: http.server module now logs accesses
This commit is contained in:
parent
659762c0ad
commit
758adaf3d5
1 changed files with 9 additions and 1 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/evilsocket/bettercap-ng/core"
|
||||
"github.com/evilsocket/bettercap-ng/log"
|
||||
"github.com/evilsocket/bettercap-ng/session"
|
||||
)
|
||||
|
@ -62,6 +63,13 @@ func (httpd *HttpServer) Author() string {
|
|||
return "Simone Margaritelli <evilsocket@protonmail.com>"
|
||||
}
|
||||
|
||||
func wrapHandler(h http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
log.Info("(%s) %s %s %s", core.Green("httpd"), core.Bold(r.RemoteAddr), r.Method, r.URL.Path)
|
||||
h.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
||||
func (httpd *HttpServer) Configure() error {
|
||||
var err error
|
||||
var path string
|
||||
|
@ -72,7 +80,7 @@ func (httpd *HttpServer) Configure() error {
|
|||
return err
|
||||
}
|
||||
|
||||
http.Handle("/", http.FileServer(http.Dir(path)))
|
||||
http.Handle("/", wrapHandler(http.FileServer(http.Dir(path))))
|
||||
|
||||
if err, address = httpd.StringParam("http.server.address"); err != nil {
|
||||
return err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue