summaryrefslogtreecommitdiffstats
path: root/roseh.moe.go
diff options
context:
space:
mode:
Diffstat (limited to 'roseh.moe.go')
-rw-r--r--roseh.moe.go25
1 files changed, 20 insertions, 5 deletions
diff --git a/roseh.moe.go b/roseh.moe.go
index f41d184..637c22b 100644
--- a/roseh.moe.go
+++ b/roseh.moe.go
@@ -1138,6 +1138,19 @@ func (h *authHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h.h.ServeHTTP(w, r)
}
+type loggingHandler struct {
+ h http.Handler
+}
+
+func (h *loggingHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ u := *r.URL
+ if strings.HasPrefix(u.Path, "/otp/") {
+ u.Path = "/otp/__REDACTED__"
+ }
+ log.Printf("%q from %q", r.Method+" "+r.Host+u.String(), r.RemoteAddr)
+ h.h.ServeHTTP(w, r)
+}
+
func main() {
flag.Parse()
@@ -1216,12 +1229,13 @@ func main() {
apiMux.HandleFunc("PUT /api/wormhole/{name}", wormholeAPIUpload)
mux.Handle("/api/", apiMux)
mux.HandleFunc("/", notFound)
- http.Handle(selfURL.Hostname()+"/", http.NewCrossOriginProtection().Handler(&gzipHandler{mux}))
+ serverMux := http.NewServeMux()
+ serverMux.Handle(selfURL.Hostname()+"/", http.NewCrossOriginProtection().Handler(&gzipHandler{mux}))
jellyfinURL, err := url.Parse("http://127.0.0.1:8096")
if err != nil {
log.Fatal(err)
}
- http.Handle("cinema."+selfURL.Hostname()+"/", &authHandler{h: &httputil.ReverseProxy{
+ serverMux.Handle("cinema."+selfURL.Hostname()+"/", &authHandler{h: &httputil.ReverseProxy{
Rewrite: func(r *httputil.ProxyRequest) {
r.SetURL(jellyfinURL)
r.SetXForwarded()
@@ -1243,7 +1257,8 @@ func main() {
}
cgitCGI.PathLocationHandler = cgitCGI
codeMux.Handle("/", cgitCGI)
- http.Handle("code."+selfURL.Hostname()+"/", &gzipHandler{codeMux})
+ serverMux.Handle("code."+selfURL.Hostname()+"/", &gzipHandler{codeMux})
+ handler := &loggingHandler{serverMux}
port := selfURL.Port()
if port == "" {
@@ -1255,8 +1270,8 @@ func main() {
addr := ":" + port
log.Printf("Listening on %q", addr)
if *https != "" {
- log.Fatal(http.ListenAndServeTLS(addr, *https+"/cert.pem", *https+"/key.pem", nil))
+ log.Fatal(http.ListenAndServeTLS(addr, *https+"/cert.pem", *https+"/key.pem", handler))
} else {
- log.Fatal(http.ListenAndServe(addr, nil))
+ log.Fatal(http.ListenAndServe(addr, handler))
}
}