chore: trace show tracking ip
This commit is contained in:
		
							parent
							
								
									a4824ab93d
								
							
						
					
					
						commit
						f0e8f8fa94
					
				| @ -109,7 +109,7 @@ func post_tracking_handle(c *gin.Context, rtenv *RouteEnv) { | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	}  | 	}  | ||||||
| 	ip, _ := getIP(c.Request) | 	ip, _ := getIP(c.Request,true) | ||||||
| 	trackaction := &TrackAction{ | 	trackaction := &TrackAction{ | ||||||
| 		When: trackpost.When, | 		When: trackpost.When, | ||||||
| 		Where: trackpost.Where, | 		Where: trackpost.Where, | ||||||
|  | |||||||
							
								
								
									
										13
									
								
								logs.go
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								logs.go
									
									
									
									
									
								
							| @ -57,9 +57,16 @@ func setLog(cfg *cfg.Config) { | |||||||
| 	}) | 	}) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func getIP(r *http.Request) (string, error) { | func getIP(r *http.Request,show bool) (string, error) { | ||||||
| 	//Get IP from X-FORWARDED-FOR header | 	//Get IP from X-FORWARDED-FOR header | ||||||
| 	ips := r.Header.Get("X-FORWARDED-FOR") | 	ips := r.Header.Get("X-FORWARDED-FOR") | ||||||
|  | 	if show { | ||||||
|  | 		fmt.Println("X-Forwarded-For : ", ips) | ||||||
|  | 		ipreal := r.Header.Get("X-REAL-IP") | ||||||
|  | 		fmt.Println("X-REAL-IP : ", ipreal) | ||||||
|  | 		iprem, _, _ := net.SplitHostPort(r.RemoteAddr) | ||||||
|  | 		fmt.Println("RemoteAddr : ", iprem) | ||||||
|  | 	} | ||||||
| 	splitIps := strings.Split(ips, ",") | 	splitIps := strings.Split(ips, ",") | ||||||
| 	for _, ip := range splitIps { | 	for _, ip := range splitIps { | ||||||
| 		netIP := net.ParseIP(ip) | 		netIP := net.ParseIP(ip) | ||||||
| @ -88,7 +95,7 @@ func getIP(r *http.Request) (string, error) { | |||||||
| func logRequest(c *gin.Context,  rtenv *RouteEnv, run string, route string, info string, infoReq string, tkn string) { | func logRequest(c *gin.Context,  rtenv *RouteEnv, run string, route string, info string, infoReq string, tkn string) { | ||||||
| 	accept_langs := strings.Split(c.Request.Header.Get("Accept-Language"),";") | 	accept_langs := strings.Split(c.Request.Header.Get("Accept-Language"),";") | ||||||
| 	langs := strings.Split(accept_langs[0], ",") | 	langs := strings.Split(accept_langs[0], ",") | ||||||
| 	ip, _ := getIP(c.Request) | 	ip, _ := getIP(c.Request,false) | ||||||
| 	  // header, _ := ioutil.ReadAll(c.Request.Header) | 	  // header, _ := ioutil.ReadAll(c.Request.Header) | ||||||
|     //println(string(c.header)) |     //println(string(c.header)) | ||||||
| 		// println(c.Header) | 		// println(c.Header) | ||||||
| @ -125,7 +132,7 @@ func logRequest(c *gin.Context,  rtenv *RouteEnv, run string, route string, info | |||||||
| func requestInfo(c *gin.Context,  rtenv *RouteEnv, run string, route string, tkn string) LogInfo { | func requestInfo(c *gin.Context,  rtenv *RouteEnv, run string, route string, tkn string) LogInfo { | ||||||
| 	accept_langs := strings.Split(c.Request.Header.Get("Accept-Language"),";") | 	accept_langs := strings.Split(c.Request.Header.Get("Accept-Language"),";") | ||||||
| 	langs := strings.Split(accept_langs[0], ",") | 	langs := strings.Split(accept_langs[0], ",") | ||||||
| 	ip, _ := getIP(c.Request) | 	ip, _ := getIP(c.Request,false) | ||||||
|   return LogInfo{ |   return LogInfo{ | ||||||
|  		Run:    run, |  		Run:    run, | ||||||
|  		Route:   route,  |  		Route:   route,  | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user