removed error checking from hostname to only return unknown host
Signed-off-by: Michael <michael.lindman@gmail.com>
This commit is contained in:
parent
9436e7359b
commit
b4aa90c793
|
@ -80,9 +80,5 @@ func (logger *Logger) AccessMessage(r *http.Request, statuscode int) {
|
|||
if err != nil {
|
||||
logger.Error.Warn(err)
|
||||
}
|
||||
hostname, err := nettools.Hostname(ip)
|
||||
if err != nil {
|
||||
logger.Error.Warn(err)
|
||||
}
|
||||
logger.Access.Infof("%s %v - %s %s %s", ip, hostname, r.Method, colour.Status(statuscode), html.EscapeString(r.URL.Path))
|
||||
logger.Access.Infof("%s %v - %s %s %s", ip, nettools.Hostname(ip), r.Method, colour.Status(statuscode), html.EscapeString(r.URL.Path))
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package nettools
|
|||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"log"
|
||||
"math/big"
|
||||
"net"
|
||||
|
@ -50,14 +49,10 @@ func Inet6AtonDecode(ipHex string) (ip net.IP) {
|
|||
}
|
||||
|
||||
// Hostname returns hostname
|
||||
func Hostname(ip net.IP) ([]string, error) {
|
||||
func Hostname(ip net.IP) (hostname string) {
|
||||
names, err := net.LookupAddr(ip.String())
|
||||
unknown := []string{"unknown host"}
|
||||
if err != nil {
|
||||
return unknown, err
|
||||
return "unknown host"
|
||||
}
|
||||
if len(names) == 0 {
|
||||
return unknown, fmt.Errorf("unknown hostname for %v", ip.String())
|
||||
}
|
||||
return names, nil
|
||||
return names[0]
|
||||
}
|
||||
|
|
Reference in New Issue