From c9b7532339890d6bda287d23f129677cbabeefb0 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Thu, 13 Feb 2025 15:03:23 +0800 Subject: [PATCH] {http,ssh}_server.go: Add debug logs for incoming requests --- http_server.go | 4 ++++ ssh_server.go | 4 +++- diff --git a/http_server.go b/http_server.go index 917d68cef114fc7a0042ad47d9075b79d70708c6..5970cf78682df90b5a9f5fe31e08967257ff6a63 100644 --- a/http_server.go +++ b/http_server.go @@ -6,11 +6,15 @@ "fmt" "net/http" "strconv" "strings" + + "go.lindenii.runxiyu.org/lindenii-common/clog" ) type http_router_t struct{} func (router *http_router_t) ServeHTTP(w http.ResponseWriter, r *http.Request) { + clog.Debug("Incoming HTTP: " + r.RemoteAddr + " " + r.Method + " " + r.RequestURI) + segments, _, err := parse_request_uri(r.RequestURI) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) diff --git a/ssh_server.go b/ssh_server.go index e841e65b7c8d69b05add3961351f59881b871a64..8cea1a985ecc3e85161311dcb273d9f95d8b3a92 100644 --- a/ssh_server.go +++ b/ssh_server.go @@ -5,6 +5,7 @@ "fmt" "net" "os" "os/exec" + "strings" glider_ssh "github.com/gliderlabs/ssh" "go.lindenii.runxiyu.org/lindenii-common/clog" @@ -39,7 +40,8 @@ var client_public_key_string string if client_public_key != nil { client_public_key_string = string(go_ssh.MarshalAuthorizedKey(client_public_key)) } - _ = client_public_key_string + + clog.Debug("Incoming SSH: " + session.RemoteAddr().String() + " " + strings.TrimSuffix(client_public_key_string, "\n") + " " + session.RawCommand()) cmd := session.Command() -- 2.48.1