aboutsummaryrefslogtreecommitdiff
path: root/cmd/xedn/main.go
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2024-10-25 14:06:42 -0400
committerXe Iaso <me@xeiaso.net>2024-10-25 14:06:42 -0400
commitafa4bc6c01297af78885bf0562e2dae7ff83605b (patch)
tree97a1149d5646cf9b1c7aa2892d6e849c589219cc /cmd/xedn/main.go
parent797eec6d94e193ae684db977179ea4a422b2499f (diff)
downloadx-afa4bc6c01297af78885bf0562e2dae7ff83605b.tar.xz
x-afa4bc6c01297af78885bf0562e2dae7ff83605b.zip
cmd: add amano and stealthmountain
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'cmd/xedn/main.go')
-rw-r--r--cmd/xedn/main.go57
1 files changed, 0 insertions, 57 deletions
diff --git a/cmd/xedn/main.go b/cmd/xedn/main.go
index 26d579c..f1dd391 100644
--- a/cmd/xedn/main.go
+++ b/cmd/xedn/main.go
@@ -8,7 +8,6 @@ import (
"flag"
"fmt"
"image/png"
- "io"
"log"
"log/slog"
"net/http"
@@ -22,10 +21,6 @@ import (
"github.com/sebest/xff"
"go.etcd.io/bbolt"
"golang.org/x/sync/singleflight"
- "tailscale.com/hostinfo"
- "tailscale.com/metrics"
- "tailscale.com/tsnet"
- "tailscale.com/tsweb"
"within.website/x/internal"
"within.website/x/internal/xesite"
"within.website/x/web/fly/flymachines"
@@ -39,7 +34,6 @@ var (
dir = flag.String("dir", envOr("XEDN_STATE", "./var"), "where XeDN should store cached data")
staticDir = flag.String("static-dir", envOr("XEDN_STATIC", "./static"), "where XeDN should look for static assets")
stableDiffusionServer = flag.String("stable-diffusion-server", "http://xe-automatic1111.internal:8080", "where XeDN should request Stable Diffusion images from (Automatic1111)")
- tailscaleVerbose = flag.Bool("tailscale-verbose", false, "enable verbose tailscale logging")
//go:embed index.html
indexHTML []byte
@@ -60,31 +54,17 @@ var (
etagMatches = expvar.NewInt("counter_xedn_etag_matches")
- referers = metrics.LabelMap{Label: "url"}
- fileHits = metrics.LabelMap{Label: "path"}
- fileDeaths = metrics.LabelMap{Label: "path"}
- fileMimeTypes = metrics.LabelMap{Label: "type"}
-
etags map[string]string
etagLock sync.RWMutex
)
func init() {
etags = map[string]string{}
-
- expvar.Publish("gauge_xedn_referers", &referers)
- expvar.Publish("gauge_xedn_file_hits", &fileHits)
- expvar.Publish("gauge_xedn_file_deaths", &fileDeaths)
- expvar.Publish("gauge_xedn_file_mime_type", &fileMimeTypes)
- expvar.Publish("gauge_xedn_ois_file_conversions", &OISFileConversions)
- expvar.Publish("gauge_xedn_ois_file_hits", &OISFileHits)
}
func main() {
internal.HandleStartup()
- hostinfo.SetApp("within.website/x/cmd/xedn")
-
os.MkdirAll(filepath.Join(*dir, "tsnet"), 0700)
db, err := bbolt.Open(filepath.Join(*dir, "data"), 0600, &bbolt.Options{})
@@ -108,19 +88,6 @@ func main() {
group: &singleflight.Group{},
}
- srv := &tsnet.Server{
- Hostname: "xedn-" + os.Getenv("FLY_REGION"),
- Logf: log.New(io.Discard, "", 0).Printf,
- AuthKey: os.Getenv("TS_AUTHKEY"),
- Dir: filepath.Join(*dir, "tsnet"),
- }
-
- if *tailscaleVerbose {
- srv.Logf = log.Printf
- }
-
- srv.Start()
-
sd := &StableDiffusion{
db: db,
client: &stablediffusion.Client{HTTP: http.DefaultClient, APIServer: *stableDiffusionServer},
@@ -137,26 +104,6 @@ func main() {
log.Fatal(err)
}
- go func() {
- lis, err := srv.Listen("tcp", ":80")
- if err != nil {
- log.Fatalf("can't listen on tsnet: %v", err)
- }
-
- http.DefaultServeMux.HandleFunc("/debug/varz", tsweb.VarzHandler)
- http.DefaultServeMux.HandleFunc("/xedn/files", dc.ListFiles)
- http.DefaultServeMux.HandleFunc("/xedn/purge", dc.Purge)
- http.DefaultServeMux.HandleFunc("/xesite/generations", zs.ListGenerations)
- http.DefaultServeMux.HandleFunc("/xesite/nuke", zs.NukeGeneration)
- http.DefaultServeMux.HandleFunc("/xesite/upload", zs.UploadNewZip)
- http.DefaultServeMux.HandleFunc("/sticker/files", ois.ListFiles)
- http.DefaultServeMux.HandleFunc("/sticker/purge", ois.Purge)
-
- defer srv.Close()
- defer lis.Close()
- log.Fatal(http.Serve(lis, http.DefaultServeMux))
- }()
-
xffMW, err := xff.Default()
if err != nil {
log.Fatal(err)
@@ -167,7 +114,6 @@ func main() {
{
mux := http.NewServeMux()
- mux.HandleFunc("/metrics", tsweb.VarzHandler)
mux.HandleFunc("/xedn/optimize", iu.CreateImage)
mux.HandleFunc("/", http.FileServer(http.Dir(filepath.Join(*dir, "uploud"))).ServeHTTP)
@@ -232,9 +178,6 @@ func main() {
return
}
- referers.Get(r.Header.Get("Referer")).Add(1)
- fileMimeTypes.Get(r.Header.Get("Content-Type")).Add(1)
-
if err := dc.GetFile(w, r); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return