mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 16:00:25 +08:00 
			
		
		
		
	X-Forwarded-For中包含当前客户端的IP
This commit is contained in:
		@@ -1047,7 +1047,7 @@ func (this *HTTPRequest) requestRemoteAddr(supportVar bool) string {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// X-Forwarded-For
 | 
			
		||||
	forwardedFor := this.RawReq.Header.Get("X-Forwarded-For")
 | 
			
		||||
	var forwardedFor = this.RawReq.Header.Get("X-Forwarded-For")
 | 
			
		||||
	if len(forwardedFor) > 0 {
 | 
			
		||||
		commaIndex := strings.Index(forwardedFor, ",")
 | 
			
		||||
		if commaIndex > 0 {
 | 
			
		||||
@@ -1460,10 +1460,15 @@ func (this *HTTPRequest) setForwardHeaders(header http.Header) {
 | 
			
		||||
			if hasForwardHeader {
 | 
			
		||||
				header["X-Forwarded-For"] = []string{strings.Join(forwardedFor, ", ") + ", " + remoteAddr}
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			var clientRemoteAddr = this.requestRemoteAddr(true)
 | 
			
		||||
			if len(clientRemoteAddr) > 0 && clientRemoteAddr != remoteAddr {
 | 
			
		||||
				header["X-Forwarded-For"] = []string{clientRemoteAddr + ", " + remoteAddr}
 | 
			
		||||
			} else {
 | 
			
		||||
				header["X-Forwarded-For"] = []string{remoteAddr}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Forwarded
 | 
			
		||||
	/**{
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user