diff --git a/handler/http/handler.go b/handler/http/handler.go index 0473e22..08b9316 100644 --- a/handler/http/handler.go +++ b/handler/http/handler.go @@ -161,14 +161,19 @@ func (h *httpHandler) handleRequest(ctx context.Context, conn net.Conn, req *htt log.Debugf("%s >> %s", conn.RemoteAddr(), addr) resp := &http.Response{ - ProtoMajor: 1, - ProtoMinor: 1, - Header: h.md.header, + ProtoMajor: 1, + ProtoMinor: 1, + Header: h.md.header, + ContentLength: -1, } if resp.Header == nil { resp.Header = http.Header{} } + if resp.Header.Get("Proxy-Agent") == "" { + resp.Header.Set("Proxy-Agent", h.md.proxyAgent) + } + clientID, ok := h.authenticate(ctx, conn, req, resp, log) if !ok { return nil diff --git a/handler/http/metadata.go b/handler/http/metadata.go index 4f7b4e1..2ea951f 100644 --- a/handler/http/metadata.go +++ b/handler/http/metadata.go @@ -10,7 +10,8 @@ import ( ) const ( - defaultRealm = "gost" + defaultRealm = "gost" + defaultProxyAgent = "gost/3.0" ) type metadata struct { @@ -20,6 +21,7 @@ type metadata struct { hash string authBasicRealm string observePeriod time.Duration + proxyAgent string } func (h *httpHandler) parseMetadata(md mdata.Metadata) error { @@ -46,6 +48,11 @@ func (h *httpHandler) parseMetadata(md mdata.Metadata) error { h.md.observePeriod = mdutil.GetDuration(md, "observePeriod") + h.md.proxyAgent = mdutil.GetString(md, "http.proxyAgent", "proxyAgent") + if h.md.proxyAgent == "" { + h.md.proxyAgent = defaultProxyAgent + } + return nil }