mirror of
https://github.com/ginuerzh/gost.git
synced 2024-04-21 12:31:34 +00:00
fix HTTP Host header
This commit is contained in:
@@ -128,14 +128,14 @@ func (h *httpHandler) handleRequest(conn net.Conn, req *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
host := req.Host
|
||||
// try to get the actual host.
|
||||
if v := req.Header.Get("Gost-Target"); v != "" {
|
||||
if h, err := decodeServerName(v); err == nil {
|
||||
host = h
|
||||
req.Host = h
|
||||
}
|
||||
}
|
||||
|
||||
host := req.Host
|
||||
if _, port, _ := net.SplitHostPort(host); port == "" {
|
||||
host = net.JoinHostPort(host, "80")
|
||||
}
|
||||
@@ -152,7 +152,6 @@ func (h *httpHandler) handleRequest(conn net.Conn, req *http.Request) {
|
||||
log.Logf("[http] %s -> %s\n%s", conn.RemoteAddr(), conn.LocalAddr(), string(dump))
|
||||
}
|
||||
|
||||
req.Host = host
|
||||
req.Header.Del("Gost-Target")
|
||||
|
||||
resp := &http.Response{
|
||||
@@ -305,6 +304,8 @@ func (h *httpHandler) authenticate(conn net.Conn, req *http.Request, resp *http.
|
||||
|
||||
// probing resistance is enabled
|
||||
if ss := strings.SplitN(h.options.ProbeResist, ":", 2); len(ss) == 2 {
|
||||
resp.StatusCode = http.StatusServiceUnavailable // default status code
|
||||
|
||||
switch ss[0] {
|
||||
case "code":
|
||||
resp.StatusCode, _ = strconv.Atoi(ss[1])
|
||||
|
||||
Reference in New Issue
Block a user