fix: query param cause 404 notfound
							parent
							
								
									96209b847a
								
							
						
					
					
						commit
						95bca77f37
					
				| 
						 | 
				
			
			@ -57,6 +57,7 @@ func main() {
 | 
			
		|||
		Addr:    flagAddr,
 | 
			
		||||
		Handler: Middleware(g),
 | 
			
		||||
	}
 | 
			
		||||
	klog.Info("gterm starting at ", flagAddr)
 | 
			
		||||
	err := server.ListenAndServe()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
| 
						 | 
				
			
			@ -71,12 +72,14 @@ func Middleware(next http.Handler) http.Handler {
 | 
			
		|||
				log.Error(err)
 | 
			
		||||
			}
 | 
			
		||||
		}()
 | 
			
		||||
		ip := ksrv.GetIP(r)
 | 
			
		||||
		if flagAllowIP != "" {
 | 
			
		||||
			if !ksrv.MatchIPGlob(ksrv.GetIP(r), flagAllowIP) {
 | 
			
		||||
			if !ksrv.MatchIPGlob(ip, flagAllowIP) {
 | 
			
		||||
				w.WriteHeader(http.StatusForbidden)
 | 
			
		||||
				w.Write([]byte("permission denied"))
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		next.ServeHTTP(w, r)
 | 
			
		||||
		log.Debug(ip, " ", r.URL.String())
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue