-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
99 lines (84 loc) · 2.58 KB
/
main.go
File metadata and controls
99 lines (84 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// RendererPool manages a pool of Renderer instances for concurrent page rendering
// Created by DINKIssTyle on 2026. Copyright (C) 2026 DINKI'ssTyle. All rights reserved.
package main
import (
"embed"
"flag"
"fmt"
"net/http"
"os"
"time"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
)
//go:embed all:frontend/dist
var assets embed.FS
func main() {
// Parse command line flags
start := flag.Bool("start", false, "Start proxy server on startup")
port := flag.Int("p", 8080, "Port for the proxy server")
encoding := flag.String("e", "auto", "Forced encoding (e.g. utf-8, euc-kr)")
mode := flag.String("m", "html32", "Proxy mode (nossl, html32, html32new, html401, textonly, imagemap)")
image := flag.String("i", "original", "Image conversion format (original, jpeg, gif, png)")
stop := flag.Bool("stop", false, "Do not start server even if -start is passed")
quit := flag.Bool("quit", false, "Quit application after processing flags")
flag.Parse()
// Handle remote control commands if requested
if *stop || *quit {
action := "stop"
if *quit {
action = "quit"
}
fmt.Printf("Sending %s command to running instance on port %d...\n", action, *port)
client := &http.Client{Timeout: 5 * time.Second}
controlURL := fmt.Sprintf("http://localhost:%d/_drp/control?action=%s", *port, action)
resp, err := client.Get(controlURL)
if err != nil {
fmt.Printf("Error: Could not connect to running instance on port %d: %v\n", *port, err)
os.Exit(1)
}
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {
fmt.Printf("Success: %s command accepted\n", action)
os.Exit(0)
} else {
fmt.Printf("Error: Server returned status %d\n", resp.StatusCode)
os.Exit(1)
}
}
config := AppConfig{
StartServer: *start,
Port: *port,
Encoding: *encoding,
Mode: *mode,
ImageFormat: *image,
StopServer: *stop,
QuitApp: *quit,
SetFlags: make(map[string]bool),
}
// Track which flags were explicitly provided by the user
flag.Visit(func(f *flag.Flag) {
config.SetFlags[f.Name] = true
})
// Create an instance of the app structure
app := NewApp(config)
// Create application with options
err := wails.Run(&options.App{
Title: "DKST RetroProxy",
Width: 550,
Height: 580,
AssetServer: &assetserver.Options{
Assets: assets,
},
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
OnStartup: app.startup,
OnShutdown: app.shutdown,
Bind: []interface{}{
app,
},
})
if err != nil {
println("Error:", err.Error())
}
}