Removed manually inputting IP

This commit is contained in:
Mike Raunsbæk 2018-06-15 09:18:19 +02:00
parent eca444b9cc
commit 469dde3614
1 changed files with 1 additions and 12 deletions

View File

@ -53,17 +53,7 @@ func New(db database.Client) *Server {
}
func ipFromRequest(header string, r *http.Request) (net.IP, error) {
var remoteIP string
if r.URL != nil && remoteIP == "" {
host := filepath.Base(r.URL.Path)
ip := net.ParseIP(host)
if ip != nil {
remoteIP = ip.String()
}
}
if remoteIP == "" {
remoteIP = r.Header.Get(header)
}
remoteIP := r.Header.Get(header)
if remoteIP == "" {
host, _, err := net.SplitHostPort(r.RemoteAddr)
if err != nil {
@ -282,7 +272,6 @@ func (s *Server) Handler() http.Handler {
// JSON
r.Route("GET", "/", s.JSONHandler).Header("Accept", jsonMediaType)
r.Route("GET", "/json", s.JSONHandler)
r.RoutePrefix("GET", "/json/", s.JSONHandler)
// CLI
r.Route("GET", "/", s.CLIHandler).MatcherFunc(cliMatcher)