Skip to content

Commit

Permalink
filter proxy headers
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekg999 committed Sep 28, 2024
1 parent 58feffa commit 0b999e6
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions hook/handlers/index.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package handlers

import (
"fmt"
"io"
"net/http"
"strings"
Expand Down Expand Up @@ -29,15 +28,10 @@ func Index(w http.ResponseWriter, r *http.Request) {
body = []byte{}
}

headers := http.Header{}
for key := range response.Headers {
if strings.HasPrefix(key, "Cf-") || key == "Cdn-Loop" || key == "X-Real-IP" || key == "X-Forwarded-For" || key == "X-Forwarded-Proto" {
r.Header.Del(key)
}
}

for key, values := range r.Header {
for _, value := range values {
fmt.Println("Header:", key, value)
if !(strings.HasPrefix(key, "Cf-") || key == "Cdn-Loop" || key == "X-Real-IP" || key == "X-Forwarded-For" || key == "X-Forwarded-Proto") {
headers.Add(key, response.Headers[key])
}
}

Expand All @@ -47,7 +41,7 @@ func Index(w http.ResponseWriter, r *http.Request) {
Path: r.URL.Path,
Sender: r.Header.Get("X-Real-IP"),
Query: r.URL.Query(),
Headers: r.Header,
Headers: headers,
Body: string(body),
Time: time.Now(),
})
Expand Down

0 comments on commit 0b999e6

Please sign in to comment.