summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--roseh.moe.go27
1 files changed, 20 insertions, 7 deletions
diff --git a/roseh.moe.go b/roseh.moe.go
index bfd5b97..b1cf181 100644
--- a/roseh.moe.go
+++ b/roseh.moe.go
@@ -24,9 +24,11 @@ import (
"log"
"mime/multipart"
"net/http"
+ "net/http/cgi"
"net/http/httputil"
"net/url"
"os"
+ "path/filepath"
"slices"
"strconv"
"strings"
@@ -43,13 +45,14 @@ import (
var (
port = flag.Int("port", 42069, "port to listen on")
selfURL = flag.String("self-url", "http://localhost:42069", "base URL of the server")
- domain = flag.String("domain", "", "domain for auth cookie")
+ domain = flag.String("domain", "localhost", "domain for auth cookie")
secretsFile = flag.String("secrets", "secrets.xml", "secrets file")
configFile = flag.String("config", "config.xml", "configuration file (XML, baby!!)")
https = flag.String("https", "", "directory containing cert.pem and key.pem, or empty string to use unencrypted http")
holeTempDir = flag.String("hole-temp-dir", "hole", "directory to store temporary files for the wormhole")
- codeDir = flag.String("code-dir", "code", "directory to serve git repos")
nezuko = flag.String("nezuko", "/mnt/nezuko", "nezuko partition")
+ cgit = flag.String("cgit", "", "directory containing cgit.cgi")
+ cgitConfig = flag.String("cgit-config", "", "cgit config file")
)
var notepadPassword, secretKey, authenticatorKey []byte
@@ -1063,7 +1066,7 @@ func main() {
mux := http.NewServeMux()
mux.HandleFunc("GET /{$}", index)
- mux.HandleFunc("GET /games/", gamesIndex)
+ mux.HandleFunc("GET /games/{$}", gamesIndex)
mux.HandleFunc("GET /games/pong", pong)
mux.HandleFunc("GET /games/rms", stallmanShooter)
mux.HandleFunc("GET /qr.png", qrHandler)
@@ -1074,11 +1077,10 @@ func main() {
mux.HandleFunc("POST /login", login)
mux.Handle("GET /notepad", &authHandler{h: http.HandlerFunc(notepad)})
mux.Handle("POST /notepad", &authHandler{h: http.HandlerFunc(autosave), noRedirect: true})
- mux.HandleFunc("GET /cmd/", cmdIndex)
+ mux.HandleFunc("GET /cmd/{$}", cmdIndex)
mux.HandleFunc("GET /cmd/{cmd}", cmd)
- mux.HandleFunc("GET /pkg/", pkgIndex)
+ mux.HandleFunc("GET /pkg/{$}", pkgIndex)
mux.HandleFunc("GET /pkg/{pkg}", pkg)
- mux.Handle("GET /code/", http.StripPrefix("/code/", http.FileServer(http.Dir(*codeDir))))
mux.Handle("GET /nezuko/", &authHandler{h: http.StripPrefix("/nezuko/", http.FileServer(http.Dir(*nezuko)))})
mux.HandleFunc("GET /static/", static)
mux.HandleFunc("GET /favicon.ico", favicon)
@@ -1091,12 +1093,23 @@ func main() {
if err != nil {
log.Fatal(err)
}
- http.Handle("cinema.roseh.moe/", &authHandler{h: &httputil.ReverseProxy{
+ http.Handle("cinema."+*domain+"/", &authHandler{h: &httputil.ReverseProxy{
Rewrite: func(r *httputil.ProxyRequest) {
r.SetURL(jellyfinURL)
r.SetXForwarded()
},
}})
+ cgitStaticFiles := http.FileServer(http.Dir(*cgit))
+ http.Handle("code."+*domain+"/cgit.css", cgitStaticFiles)
+ http.Handle("code."+*domain+"/cgit.js", cgitStaticFiles)
+ http.Handle("code."+*domain+"/cgit.png", cgitStaticFiles)
+ http.Handle("code."+*domain+"/favicon.ico", cgitStaticFiles)
+ http.Handle("code."+*domain+"/robots.txt", cgitStaticFiles)
+ http.Handle("code."+*domain+"/", &cgi.Handler{
+ Path: filepath.Join(*cgit, "cgit.cgi"),
+ Env: []string{"CGIT_CONFIG=" + *cgitConfig},
+ PathLocationHandler: http.DefaultServeMux,
+ })
addr := fmt.Sprintf(":%d", *port)
log.Printf("Listening on %q", addr)