fix: /debug убран (утечка секретов)
This commit is contained in:
@@ -5,9 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -90,44 +88,3 @@ func readyzHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte("ok"))
|
||||
}
|
||||
|
||||
func debugHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||
|
||||
fmt.Fprintf(w, "=== ENV ===\n")
|
||||
for _, e := range os.Environ() {
|
||||
if strings.Contains(e, "S3_") || strings.Contains(e, "REGISTRY") || strings.Contains(e, "PORT") {
|
||||
fmt.Fprintln(w, e)
|
||||
}
|
||||
}
|
||||
|
||||
s3ep := os.Getenv("S3_ENDPOINT")
|
||||
fmt.Fprintf(w, "\n=== DNS: %s ===\n", s3ep)
|
||||
addrs, err := net.LookupHost(s3ep)
|
||||
if err != nil {
|
||||
fmt.Fprintf(w, "DNS ERROR: %v\n", err)
|
||||
} else {
|
||||
for _, a := range addrs {
|
||||
fmt.Fprintf(w, " %s\n", a)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "\n=== TCP dial: %s:443 ===\n", s3ep)
|
||||
conn, err := net.DialTimeout("tcp", s3ep+":443", 5*time.Second)
|
||||
if err != nil {
|
||||
fmt.Fprintf(w, "TCP ERROR: %v\n", err)
|
||||
} else {
|
||||
fmt.Fprintf(w, "TCP OK: %s -> %s\n", conn.LocalAddr(), conn.RemoteAddr())
|
||||
conn.Close()
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "\n=== S3 BucketExists ===\n")
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 10*time.Second)
|
||||
defer cancel()
|
||||
_, err = s3Client.BucketExists(ctx, bucketName)
|
||||
if err != nil {
|
||||
fmt.Fprintf(w, "S3 ERROR: %v\n", err)
|
||||
} else {
|
||||
fmt.Fprintf(w, "S3 OK: bucket %s accessible\n", bucketName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,6 @@ func main() {
|
||||
http.Handle("/", http.HandlerFunc(rootHandler))
|
||||
http.HandleFunc("/healthz", healthzHandler)
|
||||
http.HandleFunc("/readyz", readyzHandler)
|
||||
http.HandleFunc("/debug", debugHandler)
|
||||
|
||||
port := os.Getenv("PORT")
|
||||
if port == "" {
|
||||
|
||||
Reference in New Issue
Block a user