mirror of
				https://github.com/byReqz/probehost2.git
				synced 2025-11-04 00:11:30 +00:00 
			
		
		
		
	add traceroute
This commit is contained in:
		
							
								
								
									
										16
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								main.go
									
									
									
									
									
								
							@@ -106,9 +106,25 @@ func mtr(w http.ResponseWriter, req *http.Request) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func traceroute(w http.ResponseWriter, req *http.Request) {
 | 
				
			||||||
 | 
					  geturl := strings.Split(req.URL.String(), "/")
 | 
				
			||||||
 | 
					  targets := strings.Split(geturl[2], ",")
 | 
				
			||||||
 | 
					  hosts := validatehosts(targets)
 | 
				
			||||||
 | 
					  var res string
 | 
				
			||||||
 | 
					  for _, host := range hosts {
 | 
				
			||||||
 | 
					    res = fmt.Sprint(res, runner(req.RemoteAddr, "traceroute", host), "\n")
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  if res == "" {
 | 
				
			||||||
 | 
					    fmt.Fprintln(w, http.StatusInternalServerError)
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    fmt.Fprint(w, strings.TrimSpace(res), "\n")
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func main() {
 | 
					func main() {
 | 
				
			||||||
  http.HandleFunc("/ping/", ping)
 | 
					  http.HandleFunc("/ping/", ping)
 | 
				
			||||||
  http.HandleFunc("/mtr/", mtr)
 | 
					  http.HandleFunc("/mtr/", mtr)
 | 
				
			||||||
 | 
					  http.HandleFunc("/tracert/", traceroute)
 | 
				
			||||||
  logstdout.Info("Serving on :", listenport)
 | 
					  logstdout.Info("Serving on :", listenport)
 | 
				
			||||||
  logfile.Info("Serving on :", listenport)
 | 
					  logfile.Info("Serving on :", listenport)
 | 
				
			||||||
  http.ListenAndServe(fmt.Sprint(":", listenport), nil)
 | 
					  http.ListenAndServe(fmt.Sprint(":", listenport), nil)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user