mirror of
				https://github.com/byReqz/probehost2.git
				synced 2025-11-04 00:11:30 +00:00 
			
		
		
		
	change x-forwarding flag
This commit is contained in:
		
							
								
								
									
										6
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								main.go
									
									
									
									
									
								
							@@ -16,13 +16,13 @@ var logstdout = log.New()
 | 
				
			|||||||
var logfile = log.New()
 | 
					var logfile = log.New()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var listenport int
 | 
					var listenport int
 | 
				
			||||||
var usexforwardedfor bool
 | 
					var disablexforwardedfor bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func init() {
 | 
					func init() {
 | 
				
			||||||
  var logfilepath string
 | 
					  var logfilepath string
 | 
				
			||||||
  flag.StringVarP(&logfilepath, "logfilepath", "o","probehost2.log", "sets the output file for the log")
 | 
					  flag.StringVarP(&logfilepath, "logfilepath", "o","probehost2.log", "sets the output file for the log")
 | 
				
			||||||
  flag.IntVarP(&listenport, "port", "p", 8000, "sets the port to listen on")
 | 
					  flag.IntVarP(&listenport, "port", "p", 8000, "sets the port to listen on")
 | 
				
			||||||
  flag.BoolVarP(&usexforwardedfor, "use-x-forwarded-for", "x", true, "specifies whether to show x-forwarded-for or the requesting IP")
 | 
					  flag.BoolVarP(&disablexforwardedfor, "disable-x-forwarded-for", "x", false, "specifies whether to show x-forwarded-for or the requesting IP")
 | 
				
			||||||
  flag.Parse()
 | 
					  flag.Parse()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  logstdout.SetFormatter(&log.TextFormatter{
 | 
					  logstdout.SetFormatter(&log.TextFormatter{
 | 
				
			||||||
@@ -98,7 +98,7 @@ func prerunner(req *http.Request, cmd string, cmdopts map[string]string, default
 | 
				
			|||||||
  var res string
 | 
					  var res string
 | 
				
			||||||
  var args []string
 | 
					  var args []string
 | 
				
			||||||
  var remoteaddr string
 | 
					  var remoteaddr string
 | 
				
			||||||
  if req.Header.Get("X-Forwarded-For") != "" && usexforwardedfor != false {
 | 
					  if req.Header.Get("X-Forwarded-For") != "" && disablexforwardedfor != true {
 | 
				
			||||||
    remoteaddr = req.Header.Get("X-Forwarded-For")
 | 
					    remoteaddr = req.Header.Get("X-Forwarded-For")
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    remoteaddr = req.RemoteAddr
 | 
					    remoteaddr = req.RemoteAddr
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user