Update https.go

pull/825/head
bboysoul 2021-06-29 11:47:40 +08:00 committed by GitHub
parent a8a2369629
commit 6e44f6e05a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 14 deletions

View File

@ -104,7 +104,7 @@ func (https *HttpsServer) NewHttps(l net.Listener, certFile string, keyFile stri
func (https *HttpsServer) handleHttps(c net.Conn) {
hostName, rb := GetServerNameFromClientHello(c)
var targetAddr string
r := buildMyHttpsRequest(hostName,c)
r := buildHttpsRequest(hostName)
var host *file.Host
var err error
if host, err = file.GetDb().GetInfoByHost(hostName, r); err != nil {
@ -125,7 +125,7 @@ func (https *HttpsServer) handleHttps(c net.Conn) {
if targetAddr, err = host.Target.GetRandomTarget(); err != nil {
logs.Warn(err.Error())
}
common.ChangeHostAndHeader(r, host.HostChange, host.HeaderChange, c.RemoteAddr().String(), https.addOrigin)
logs.Trace("new https connection,clientId %d,host %s,remote address %s", host.Client.Id, r.Host, c.RemoteAddr().String())
https.DealClient(conn.NewConn(c), host.Client, targetAddr, rb, common.CONN_TCP, nil, host.Flow, host.Target.LocalProxy)
}
@ -185,15 +185,3 @@ func buildHttpsRequest(hostName string) *http.Request {
r.Host = hostName
return r
}
// addheader req
func buildMyHttpsRequest(hostName string, c net.Conn) *http.Request {
r := new(http.Request)
r.RequestURI = "/"
r.URL = new(url.URL)
r.URL.Scheme = "https"
r.Host = hostName
r.Header.Set("X-Forwarded-For", c.RemoteAddr().String())
r.Header.Set("X-Real-IP", c.RemoteAddr().String())
return r
}