feat: implement initial GoDump backup service with management web UI and MySQL support

This commit is contained in:
2026-06-04 16:59:53 +00:00
parent 2dc6ee723f
commit 318f6c9b46
16 changed files with 1935 additions and 1 deletions
+398
View File
@@ -0,0 +1,398 @@
package web
import (
"crypto/rand"
"embed"
"encoding/hex"
"fmt"
"html/template"
"net/http"
"os"
"path/filepath"
"strings"
"time"
"godump/backup"
"godump/config"
"godump/logger"
)
//go:embed templates/*
var templateFS embed.FS
type Server struct {
cfg *config.Config
manager *backup.Manager
mux *http.ServeMux
}
type FileInfo struct {
Name string
Size int64
Timestamp time.Time
}
type Inventory map[string]map[string][]FileInfo // Instance -> DB -> Files
func NewServer(cfg *config.Config, manager *backup.Manager) *Server {
s := &Server{
cfg: cfg,
manager: manager,
mux: http.NewServeMux(),
}
s.routes()
return s
}
func (s *Server) Start() error {
addr := fmt.Sprintf(":%d", s.cfg.Server.Port)
logger.Info("", "Starting web server on %s", addr)
return http.ListenAndServe(addr, s.mux)
}
func (s *Server) routes() {
s.mux.HandleFunc("/login", s.handleLogin)
s.mux.HandleFunc("/logout", s.handleLogout)
s.mux.HandleFunc("/icon.png", s.handleIcon)
s.mux.HandleFunc("/", s.requireAuth(s.handleIndex))
s.mux.HandleFunc("/api/logs", s.requireAuthAPI(s.handleLogs))
s.mux.HandleFunc("/api/run/all", s.requireAuthAPI(s.handleRunAll))
s.mux.HandleFunc("/api/run/", s.requireAuthAPI(s.handleRunInstance))
s.mux.HandleFunc("/api/download", s.requireAuthAPI(s.handleDownload))
s.mux.HandleFunc("/api/delete", s.requireAuthAPI(s.handleDelete))
}
var sessionToken string
func init() {
b := make([]byte, 32)
rand.Read(b)
sessionToken = hex.EncodeToString(b)
}
func (s *Server) requireAuth(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if !s.cfg.Auth.Enabled {
next(w, r)
return
}
cookie, err := r.Cookie("godump_session")
if err != nil || cookie.Value != sessionToken {
http.Redirect(w, r, "/login", http.StatusFound)
return
}
next(w, r)
}
}
func (s *Server) requireAuthAPI(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if !s.cfg.Auth.Enabled {
next(w, r)
return
}
cookie, err := r.Cookie("godump_session")
if err != nil || cookie.Value != sessionToken {
http.Error(w, "Unauthorized", http.StatusUnauthorized)
return
}
next(w, r)
}
}
func (s *Server) handleLogin(w http.ResponseWriter, r *http.Request) {
if !s.cfg.Auth.Enabled {
http.Redirect(w, r, "/", http.StatusFound)
return
}
if r.Method == http.MethodGet {
tmpl, err := template.ParseFS(templateFS, "templates/login.html")
if err != nil {
http.Error(w, "Template error", http.StatusInternalServerError)
return
}
tmpl.Execute(w, nil)
return
}
if r.Method == http.MethodPost {
r.ParseForm()
username := r.FormValue("username")
password := r.FormValue("password")
if username == s.cfg.Auth.Username && password == s.cfg.Auth.Password {
http.SetCookie(w, &http.Cookie{
Name: "godump_session",
Value: sessionToken,
Path: "/",
HttpOnly: true,
})
http.Redirect(w, r, "/", http.StatusFound)
return
}
tmpl, _ := template.ParseFS(templateFS, "templates/login.html")
tmpl.Execute(w, map[string]string{"Error": "Invalid credentials"})
return
}
}
func (s *Server) handleLogout(w http.ResponseWriter, r *http.Request) {
http.SetCookie(w, &http.Cookie{
Name: "godump_session",
Value: "",
Path: "/",
HttpOnly: true,
MaxAge: -1,
})
http.Redirect(w, r, "/login", http.StatusFound)
}
func (s *Server) handleIcon(w http.ResponseWriter, r *http.Request) {
data, err := templateFS.ReadFile("templates/icon.png")
if err != nil {
http.NotFound(w, r)
return
}
w.Header().Set("Content-Type", "image/png")
w.Write(data)
}
func (s *Server) resolveFilePath(instName, dbName, fileName string) (string, error) {
inst := s.manager.GetInstance(instName)
if inst == nil {
return "", fmt.Errorf("instance not found")
}
baseDir := filepath.Clean(inst.Config.BackupDir)
targetPath := filepath.Join(baseDir, dbName, fileName)
targetPath = filepath.Clean(targetPath)
if !strings.HasPrefix(targetPath, baseDir+string(filepath.Separator)) {
return "", fmt.Errorf("invalid file path")
}
if _, err := os.Stat(targetPath); err != nil {
return "", fmt.Errorf("file not found")
}
return targetPath, nil
}
func (s *Server) handleDownload(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
q := r.URL.Query()
instName := q.Get("instance")
dbName := q.Get("db")
fileName := q.Get("file")
if instName == "" || dbName == "" || fileName == "" {
http.Error(w, "Missing parameters", http.StatusBadRequest)
return
}
filePath, err := s.resolveFilePath(instName, dbName, fileName)
if err != nil {
http.Error(w, err.Error(), http.StatusNotFound)
return
}
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", fileName))
w.Header().Set("Content-Type", "application/x-gzip")
http.ServeFile(w, r, filePath)
}
func (s *Server) handleDelete(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodDelete && r.Method != http.MethodPost {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
q := r.URL.Query()
instName := q.Get("instance")
dbName := q.Get("db")
fileName := q.Get("file")
if instName == "" || dbName == "" || fileName == "" {
http.Error(w, "Missing parameters", http.StatusBadRequest)
return
}
filePath, err := s.resolveFilePath(instName, dbName, fileName)
if err != nil {
http.Error(w, err.Error(), http.StatusNotFound)
return
}
if err := os.Remove(filePath); err != nil {
logger.Error(instName, "Failed to manually delete backup %s: %v", filePath, err)
http.Error(w, "Failed to delete file", http.StatusInternalServerError)
return
}
logger.Info(instName, "Manually deleted backup file %s", fileName)
w.WriteHeader(http.StatusOK)
}
func formatBytes(b int64) string {
const unit = 1024
if b < unit {
return fmt.Sprintf("%d B", b)
}
div, exp := int64(unit), 0
for n := b / unit; n >= unit; n /= unit {
div *= unit
exp++
}
return fmt.Sprintf("%.1f %ciB", float64(b)/float64(div), "KMGTPE"[exp])
}
type TemplateData struct {
TotalInstances int
TotalDatabases int
UnreachableCount int
TotalBackupSize int64
AnyRunning bool
AuthEnabled bool
Instances []backup.InstanceSnapshot
Inventory Inventory
}
func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
http.NotFound(w, r)
return
}
funcMap := template.FuncMap{
"formatBytes": formatBytes,
"formatTime": func(t time.Time) string {
if t.IsZero() {
return "Never"
}
return t.Format("2006-01-02 15:04:05")
},
}
tmpl, err := template.New("index.html").Funcs(funcMap).ParseFS(templateFS, "templates/index.html")
if err != nil {
http.Error(w, fmt.Sprintf("Template error: %v", err), http.StatusInternalServerError)
return
}
instances := s.manager.GetInstances()
inventory, totalSize := s.getInventory()
data := TemplateData{
TotalInstances: len(instances),
Inventory: inventory,
TotalBackupSize: totalSize,
AuthEnabled: s.cfg.Auth.Enabled,
}
for _, inst := range instances {
snap := inst.Snapshot()
data.Instances = append(data.Instances, snap)
data.TotalDatabases += len(snap.Databases)
if snap.OverallResult == "failed" {
data.UnreachableCount++
}
if snap.IsRunning {
data.AnyRunning = true
}
}
if err := tmpl.Execute(w, data); err != nil {
logger.Error("", "Error executing template: %v", err)
}
}
func (s *Server) handleLogs(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
data, err := logger.GetRecentLogsJSON()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Write(data)
}
func (s *Server) handleRunAll(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
s.manager.RunAll()
w.WriteHeader(http.StatusOK)
}
func (s *Server) handleRunInstance(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
name := strings.TrimPrefix(r.URL.Path, "/api/run/")
if name == "" {
http.Error(w, "Instance name required", http.StatusBadRequest)
return
}
s.manager.RunInstance(name)
w.WriteHeader(http.StatusOK)
}
func (s *Server) getInventory() (Inventory, int64) {
inv := make(Inventory)
instances := s.manager.GetInstances()
var totalSize int64
for _, inst := range instances {
instName := inst.Config.Name
inv[instName] = make(map[string][]FileInfo)
entries, err := os.ReadDir(inst.Config.BackupDir)
if err != nil {
continue
}
for _, dbEntry := range entries {
if !dbEntry.IsDir() {
continue
}
dbName := dbEntry.Name()
dbPath := filepath.Join(inst.Config.BackupDir, dbName)
files, err := os.ReadDir(dbPath)
if err != nil {
continue
}
var fileInfos []FileInfo
for _, fileEntry := range files {
if fileEntry.IsDir() {
continue
}
info, err := fileEntry.Info()
if err != nil {
continue
}
fileInfos = append(fileInfos, FileInfo{
Name: info.Name(),
Size: info.Size(),
Timestamp: info.ModTime(),
})
totalSize += info.Size()
}
if len(fileInfos) > 0 {
inv[instName][dbName] = fileInfos
}
}
}
return inv, totalSize
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

+502
View File
@@ -0,0 +1,502 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GoDump</title>
<link rel="icon" type="image/png" href="/icon.png">
<style>
:root {
--bg: #0a0a0a;
--surface: #141414;
--surface-hover: #1f1f1f;
--border: #2a2a2a;
--text-primary: #f0f0f0;
--text-secondary: #888888;
--accent: #21D198;
--accent-hover: #1cb582;
--success: #21D198;
--warning: #f59e0b;
--error: #ef4444;
--font: 'Inter', system-ui, -apple-system, sans-serif;
}
body {
margin: 0;
padding: 2rem;
background-color: var(--bg);
color: var(--text-primary);
font-family: var(--font);
line-height: 1.6;
}
h1, h2, h3, h4 {
margin-top: 0;
font-weight: 500;
letter-spacing: -0.02em;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 2.5rem;
padding-bottom: 1rem;
border-bottom: 1px solid var(--border);
}
.header h1 {
margin: 0;
font-size: 2.5rem;
color: var(--text-primary);
font-weight: 700;
}
.header h1 span {
color: var(--accent);
}
.status-bar {
display: flex;
gap: 1.5rem;
margin-bottom: 3rem;
}
.stat-card {
background: var(--surface);
padding: 1.5rem 2rem;
border-radius: 8px;
flex: 1;
border: 1px solid var(--border);
position: relative;
overflow: hidden;
}
.stat-card::before {
content: '';
position: absolute;
top: 0; left: 0; right: 0;
height: 2px;
background: var(--accent);
opacity: 0.5;
}
.stat-card .value {
font-size: 2.5rem;
font-weight: 300;
margin-bottom: 0.25rem;
color: var(--text-primary);
}
.stat-card .label {
color: var(--text-secondary);
font-size: 0.75rem;
text-transform: uppercase;
letter-spacing: 0.1em;
}
.btn {
background: var(--accent);
color: #000;
border: 1px solid var(--accent);
padding: 0.5rem 1.25rem;
border-radius: 4px;
cursor: pointer;
font-family: inherit;
font-weight: 600;
font-size: 0.875rem;
transition: all 0.2s ease;
}
.btn:hover:not(:disabled) {
background: var(--accent-hover);
border-color: var(--accent-hover);
box-shadow: 0 0 10px rgba(33, 209, 152, 0.3);
}
.btn:disabled {
background: var(--surface-hover);
border-color: var(--border);
color: var(--text-secondary);
cursor: not-allowed;
box-shadow: none;
}
.btn-outline {
background: transparent;
color: var(--accent);
border: 1px solid var(--accent);
}
.btn-outline:hover:not(:disabled) {
background: rgba(33, 209, 152, 0.1);
color: var(--accent-hover);
}
.btn-danger {
background: transparent;
color: var(--error);
border: 1px solid var(--error);
}
.btn-danger:hover:not(:disabled) {
background: rgba(239, 68, 68, 0.1);
border-color: var(--error);
box-shadow: none;
}
.btn-sm {
padding: 0.25rem 0.75rem;
font-size: 0.75rem;
}
.instance-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 8px;
padding: 2rem;
margin-bottom: 2rem;
}
.instance-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 2rem;
}
.instance-header h3 {
font-size: 1.5rem;
margin-bottom: 0.5rem;
}
.instance-details {
display: flex;
gap: 2rem;
color: var(--text-secondary);
font-size: 0.875rem;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 1rem;
font-size: 0.875rem;
}
th, td {
padding: 1rem;
text-align: left;
border-bottom: 1px solid var(--border);
}
th {
color: var(--text-secondary);
font-weight: 500;
text-transform: uppercase;
letter-spacing: 0.05em;
font-size: 0.75rem;
}
tr:last-child td {
border-bottom: none;
}
tbody tr {
transition: background 0.2s;
}
tbody tr:hover {
background: rgba(255, 255, 255, 0.02);
}
.badge {
padding: 0.25rem 0.6rem;
border-radius: 4px;
font-size: 0.7rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
border: 1px solid transparent;
}
.badge.success { background: rgba(33, 209, 152, 0.1); color: var(--success); border-color: rgba(33, 209, 152, 0.3); }
.badge.failed { background: rgba(239, 68, 68, 0.1); color: var(--error); border-color: rgba(239, 68, 68, 0.3); }
.badge.running { background: rgba(59, 130, 246, 0.1); color: #60a5fa; border-color: rgba(59, 130, 246, 0.3); }
.badge.partial { background: rgba(245, 158, 11, 0.1); color: var(--warning); border-color: rgba(245, 158, 11, 0.3); }
.log-container {
background: #050505;
border-radius: 8px;
padding: 1.5rem;
margin-top: 1rem;
height: 350px;
overflow-y: auto;
font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
font-size: 0.85rem;
color: #888;
border: 1px solid var(--border);
box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
}
.log-container::-webkit-scrollbar { width: 8px; }
.log-container::-webkit-scrollbar-track { background: transparent; }
.log-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.log-container::-webkit-scrollbar-thumb:hover { background: #444; }
.log-entry {
margin-bottom: 0.4rem;
white-space: pre-wrap;
line-height: 1.4;
}
.log-timestamp { color: #555; }
.log-info { color: var(--accent); }
.log-warn { color: var(--warning); }
.log-error { color: var(--error); }
.log-instance { color: #8b5cf6; font-weight: bold; }
.inventory-section {
margin-top: 4rem;
}
.db-inventory {
margin-bottom: 1.5rem;
padding-left: 1.5rem;
border-left: 2px solid var(--border);
}
.db-inventory:hover {
border-left-color: var(--accent);
}
.table-responsive {
width: 100%;
overflow-x: auto;
}
@media (max-width: 768px) {
body {
padding: 1rem;
}
.header {
flex-direction: column;
align-items: flex-start;
gap: 1rem;
}
.status-bar {
flex-direction: column;
gap: 1rem;
}
.stat-card {
padding: 1rem 1.5rem;
}
.stat-card .value {
font-size: 2rem;
}
.instance-header {
flex-direction: column;
gap: 1rem;
}
.instance-details {
flex-direction: column;
gap: 0.25rem;
}
th, td {
padding: 0.75rem 0.5rem;
font-size: 0.8rem;
}
}
</style>
</head>
<body>
<div class="header">
<div style="display: flex; align-items: center;">
<img src="/icon.png" alt="" style="height: 2.5rem; margin-right: 1rem; border-radius: 4px;" onerror="this.style.display='none'">
<h1>Go<span>Dump</span></h1>
</div>
<div style="display: flex; align-items: center;">
{{if .AuthEnabled}}
<button class="btn btn-outline" style="margin-right: 1rem;" onclick="window.location.href='/logout'">Sign Out</button>
{{end}}
<button class="btn" onclick="runAll()" {{if .AnyRunning}}disabled{{end}}>Run All Now</button>
</div>
</div>
<div class="status-bar">
<div class="stat-card">
<div class="value">{{.TotalInstances}}</div>
<div class="label">Managed Instances</div>
</div>
<div class="stat-card">
<div class="value">{{.TotalDatabases}}</div>
<div class="label">Discovered Databases</div>
</div>
<div class="stat-card">
<div class="value" style="color: {{if gt .UnreachableCount 0}}var(--error){{else}}var(--success){{end}}">{{.UnreachableCount}}</div>
<div class="label">Unreachable Instances</div>
</div>
<div class="stat-card">
<div class="value">{{formatBytes .TotalBackupSize}}</div>
<div class="label">Total Backup Size</div>
</div>
</div>
<h2>Instances</h2>
{{range .Instances}}
<div class="instance-card">
<div class="instance-header">
<div>
<h3>{{.Name}} <span class="badge {{if .IsRunning}}running{{else}}{{.OverallResult}}{{end}}">{{if .IsRunning}}Running{{else}}{{if .OverallResult}}{{.OverallResult}}{{else}}Pending{{end}}{{end}}</span></h3>
<div class="instance-details">
<span>Host: {{.Host}}</span>
<span>Last Run: {{formatTime .LastRunTime}}</span>
<span>Next Run: {{formatTime .NextRunTime}}</span>
</div>
</div>
<button class="btn" onclick="runInstance('{{.Name}}')" {{if .IsRunning}}disabled{{end}}>Run Now</button>
</div>
{{if .Databases}}
<div class="table-responsive">
<table>
<thead>
<tr>
<th>Database</th>
<th>First Discovered</th>
<th>Last Backup Time</th>
<th>Size</th>
<th>Result</th>
</tr>
</thead>
<tbody>
{{range .Databases}}
<tr>
<td>{{.Name}}</td>
<td>{{formatTime .FirstDiscovered}}</td>
<td>{{formatTime .LastBackupTime}}</td>
<td>{{if gt .LastBackupSize 0}}{{formatBytes .LastBackupSize}}{{else}}-{{end}}</td>
<td>
{{if .LastBackupResult}}
<span class="badge {{.LastBackupResult}}">{{.LastBackupResult}}</span>
{{else}}
<span class="badge">Pending</span>
{{end}}
</td>
</tr>
{{end}}
</tbody>
</table>
</div>
{{else}}
<p style="color: var(--text-secondary); font-size: 0.875rem;">No databases discovered yet.</p>
{{end}}
</div>
{{end}}
<div class="inventory-section">
<h2>Backup Inventory</h2>
{{range $instName, $dbs := .Inventory}}
<details class="instance-card" style="padding: 1rem 1.5rem; cursor: pointer;">
<summary style="font-size: 1.5rem; font-weight: 500; outline: none; list-style-position: inside;">
{{$instName}}
</summary>
<div style="cursor: default; margin-top: 1.5rem;">
{{range $dbName, $files := $dbs}}
<details class="db-inventory" style="cursor: pointer;">
<summary style="font-size: 1.1rem; color: var(--text-secondary); margin: 0.5rem 0; outline: none; list-style-position: inside;">
{{$dbName}} <span style="font-size: 0.8rem; opacity: 0.7;">({{len $files}} files)</span>
</summary>
<div style="cursor: default; margin-top: 0.5rem;" class="table-responsive">
<table style="table-layout: fixed; width: 100%; min-width: 600px;">
<colgroup>
<col style="width: 40%;">
<col style="width: 25%;">
<col style="width: 12%;">
<col style="width: 23%;">
</colgroup>
<tbody>
{{range $files}}
<tr>
<td style="word-break: break-all;">{{.Name}}</td>
<td>{{formatTime .Timestamp}}</td>
<td>{{formatBytes .Size}}</td>
<td style="text-align: right;">
<button class="btn btn-sm btn-outline" onclick="downloadFile('{{$instName}}', '{{$dbName}}', '{{.Name}}')">Download</button>
<button class="btn btn-sm btn-danger" onclick="deleteFile('{{$instName}}', '{{$dbName}}', '{{.Name}}')">Delete</button>
</td>
</tr>
{{end}}
</tbody>
</table>
</div>
</details>
{{end}}
</div>
</details>
{{end}}
</div>
<h2>Recent Logs</h2>
<div class="log-container" id="logs"></div>
<script>
function runAll() {
fetch('/api/run/all', { method: 'POST' }).then(() => window.location.reload());
}
function runInstance(name) {
fetch('/api/run/' + name, { method: 'POST' }).then(() => window.location.reload());
}
function downloadFile(inst, db, file) {
window.location.href = '/api/download?instance=' + encodeURIComponent(inst) + '&db=' + encodeURIComponent(db) + '&file=' + encodeURIComponent(file);
}
async function deleteFile(inst, db, file) {
if (!confirm('Are you sure you want to delete ' + file + '?')) return;
try {
const res = await fetch('/api/delete?instance=' + encodeURIComponent(inst) + '&db=' + encodeURIComponent(db) + '&file=' + encodeURIComponent(file), {
method: 'POST'
});
if (res.ok) {
window.location.reload();
} else {
alert('Failed to delete file');
}
} catch (e) {
console.error(e);
alert('Error deleting file');
}
}
async function fetchLogs() {
try {
const res = await fetch('/api/logs');
const logs = await res.json();
const container = document.getElementById('logs');
const isScrolledToBottom = container.scrollHeight - container.clientHeight <= container.scrollTop + 1;
container.innerHTML = logs.map(l => {
let levelClass = '';
if (l.level === 'INFO') levelClass = 'log-info';
if (l.level === 'WARN') levelClass = 'log-warn';
if (l.level === 'ERROR') levelClass = 'log-error';
const inst = l.instance ? `<span class="log-instance">[${l.instance}]</span> ` : '';
return `<div class="log-entry"><span class="log-timestamp">[${l.timestamp}]</span> <span class="${levelClass}">[${l.level}]</span> ${inst}${l.message}</div>`;
}).join('');
if (isScrolledToBottom) {
container.scrollTop = container.scrollHeight;
}
} catch (e) {
console.error('Failed to fetch logs:', e);
}
}
fetchLogs();
setInterval(fetchLogs, 10000);
</script>
</body>
</html>
+139
View File
@@ -0,0 +1,139 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GoDump - Login</title>
<link rel="icon" type="image/png" href="/icon.png">
<style>
:root {
--bg: #0a0a0a;
--surface: #141414;
--border: #2a2a2a;
--text-primary: #f0f0f0;
--text-secondary: #888888;
--accent: #21D198;
--accent-hover: #1cb582;
--error: #ef4444;
--font: 'Inter', system-ui, -apple-system, sans-serif;
}
body {
margin: 0;
background-color: var(--bg);
color: var(--text-primary);
font-family: var(--font);
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.login-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 8px;
padding: 2.5rem;
width: 100%;
max-width: 400px;
box-shadow: 0 10px 25px rgba(0,0,0,0.5);
text-align: center;
}
h1 {
margin-top: 0;
font-size: 2.5rem;
font-weight: 700;
margin-bottom: 2rem;
letter-spacing: -0.02em;
}
h1 span {
color: var(--accent);
}
.form-group {
margin-bottom: 1.5rem;
text-align: left;
}
label {
display: block;
margin-bottom: 0.5rem;
color: var(--text-secondary);
font-size: 0.875rem;
text-transform: uppercase;
letter-spacing: 0.05em;
}
input {
width: 100%;
box-sizing: border-box;
background: var(--bg);
border: 1px solid var(--border);
color: var(--text-primary);
padding: 0.75rem 1rem;
border-radius: 4px;
font-family: inherit;
font-size: 1rem;
transition: border-color 0.2s;
}
input:focus {
outline: none;
border-color: var(--accent);
}
.btn {
width: 100%;
background: var(--accent);
color: #000;
border: 1px solid var(--accent);
padding: 0.75rem;
border-radius: 4px;
cursor: pointer;
font-family: inherit;
font-weight: 600;
font-size: 1rem;
margin-top: 1rem;
transition: all 0.2s ease;
}
.btn:hover {
background: var(--accent-hover);
border-color: var(--accent-hover);
box-shadow: 0 0 10px rgba(33, 209, 152, 0.3);
}
.error {
color: var(--error);
font-size: 0.875rem;
margin-bottom: 1.5rem;
}
</style>
</head>
<body>
<div class="login-card">
<div style="display: flex; align-items: center; justify-content: center; margin-bottom: 2rem;">
<img src="/icon.png" alt="" style="height: 2.5rem; margin-right: 1rem; border-radius: 4px;" onerror="this.style.display='none'">
<h1 style="margin-bottom: 0;">Go<span>Dump</span></h1>
</div>
{{if .Error}}
<div class="error">{{.Error}}</div>
{{end}}
<form method="POST" action="/login">
<div class="form-group">
<label>Username</label>
<input type="text" name="username" required autofocus autocomplete="username">
</div>
<div class="form-group">
<label>Password</label>
<input type="password" name="password" required autocomplete="current-password">
</div>
<button type="submit" class="btn">Sign In</button>
</form>
</div>
</body>
</html>