Add configuration option: debug_http_headers

This commit is contained in:
Star Brilliant
2018-09-22 04:23:55 +08:00
parent ea0a769389
commit 6eb7b29142
4 changed files with 32 additions and 18 deletions

View File

@@ -220,6 +220,11 @@ func (c *Client) handlerFunc(w dns.ResponseWriter, r *dns.Msg, isTCP bool) {
panic("Unknown request Content-Type")
}
for _, header := range c.conf.DebugHTTPHeaders {
if value:= req.response.Header.Get(header); value != "" {
log.Printf("%s: %s\n", header, value)
}
}
if req.err != nil {
return
}

View File

@@ -30,15 +30,16 @@ import (
)
type config struct {
Listen []string `toml:"listen"`
UpstreamGoogle []string `toml:"upstream_google"`
UpstreamIETF []string `toml:"upstream_ietf"`
Bootstrap []string `toml:"bootstrap"`
Timeout uint `toml:"timeout"`
NoCookies bool `toml:"no_cookies"`
NoECS bool `toml:"no_ecs"`
NoIPv6 bool `toml:"no_ipv6"`
Verbose bool `toml:"verbose"`
Listen []string `toml:"listen"`
UpstreamGoogle []string `toml:"upstream_google"`
UpstreamIETF []string `toml:"upstream_ietf"`
Bootstrap []string `toml:"bootstrap"`
Timeout uint `toml:"timeout"`
NoCookies bool `toml:"no_cookies"`
NoECS bool `toml:"no_ecs"`
NoIPv6 bool `toml:"no_ipv6"`
Verbose bool `toml:"verbose"`
DebugHTTPHeaders []string `toml:"debug_http_headers"`
}
func loadConfig(path string) (*config, error) {

View File

@@ -30,15 +30,16 @@ import (
)
type config struct {
Listen []string `toml:"listen"`
Cert string `toml:"cert"`
Key string `toml:"key"`
Path string `toml:"path"`
Upstream []string `toml:"upstream"`
Timeout uint `toml:"timeout"`
Tries uint `toml:"tries"`
TCPOnly bool `toml:"tcp_only"`
Verbose bool `toml:"verbose"`
Listen []string `toml:"listen"`
Cert string `toml:"cert"`
Key string `toml:"key"`
Path string `toml:"path"`
Upstream []string `toml:"upstream"`
Timeout uint `toml:"timeout"`
Tries uint `toml:"tries"`
TCPOnly bool `toml:"tcp_only"`
Verbose bool `toml:"verbose"`
DebugHTTPHeaders []string `toml:"debug_http_headers"`
}
func loadConfig(path string) (*config, error) {

View File

@@ -112,6 +112,13 @@ func (s *Server) handlerFunc(w http.ResponseWriter, r *http.Request) {
const maxMemory = 32 << 20 // 32 MB
r.ParseMultipartForm(maxMemory)
}
for _, header := range s.conf.DebugHTTPHeaders {
if value:= r.Header.Get(header); value != "" {
log.Printf("%s: %s\n", header, value)
}
}
contentType := r.Header.Get("Content-Type")
if ct := r.FormValue("ct"); ct != "" {
contentType = ct