From 7ad406a082bdf432937eee8f8576da0c5e2d0d15 Mon Sep 17 00:00:00 2001 From: XOF Date: Mon, 15 Dec 2025 01:45:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20proxy/index.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy/index.go | 271 +++---------------------------------------------- 1 file changed, 16 insertions(+), 255 deletions(-) diff --git a/proxy/index.go b/proxy/index.go index 675bd19..59de55e 100644 --- a/proxy/index.go +++ b/proxy/index.go @@ -2,262 +2,23 @@ package proxy import ( + "html/template" "net/http" ) -func ServeIndexPage(w http.ResponseWriter, r *http.Request) { - html := ` - - - - - Secure Site Proxy - - - -
-
-

🔒 Secure Site Proxy

-

Access websites securely through encrypted proxy

-
- -
-
- -
- - -
-
-
- -
-

Security Features:

-
    -
  • End-to-end encrypted connection
  • -
  • No logging of accessed URLs
  • -
  • Automatic content rewriting
  • -
  • Protection against private network access
  • -
-
- - -
- - - -` - - w.Header().Set("Content-Type", "text/html; charset=utf-8") - w.Write([]byte(html)) +type IndexHandler struct { + templates *template.Template } + +func NewIndexHandler(templates *template.Template) *IndexHandler { + return &IndexHandler{ + templates: templates, + } +} + +func (h *IndexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "text/html; charset=utf-8") + if err := h.templates.ExecuteTemplate(w, "index.html", nil); err != nil { + http.Error(w, "Internal server error", http.StatusInternalServerError) + } +} \ No newline at end of file