mirror of
https://github.com/skidoodle/ipinfo.git
synced 2025-02-15 08:29:17 +01:00
chore: remove trailing dots
This commit is contained in:
parent
d6a163628e
commit
a579c69595
1 changed files with 10 additions and 10 deletions
20
main.go
20
main.go
|
@ -187,15 +187,15 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||||
IPAddress = requestedThings[1]
|
IPAddress = requestedThings[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
if IPAddress == "" || IPAddress == "self" {
|
if IPAddress == "" || IPAddress == "self" {
|
||||||
if realIP := r.Header.Get("CF-Connecting-IP"); realIP != "" {
|
if realIP := r.Header.Get("CF-Connecting-IP"); realIP != "" {
|
||||||
IPAddress = realIP
|
IPAddress = realIP
|
||||||
} else if realIP := r.Header.Get("X-Forwarded-For"); realIP != "" {
|
} else if realIP := r.Header.Get("X-Forwarded-For"); realIP != "" {
|
||||||
IPAddress = strings.Split(realIP, ",")[0]
|
IPAddress = strings.Split(realIP, ",")[0]
|
||||||
} else {
|
} else {
|
||||||
IPAddress = extractIP(r.RemoteAddr)
|
IPAddress = extractIP(r.RemoteAddr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ip := net.ParseIP(IPAddress)
|
ip := net.ParseIP(IPAddress)
|
||||||
if ip == nil {
|
if ip == nil {
|
||||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||||
|
@ -253,7 +253,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
d := dataStruct{
|
d := dataStruct{
|
||||||
IP: ip.String(),
|
IP: ip.String(),
|
||||||
Hostname: hostname[0],
|
Hostname: strings.TrimSuffix(hostname[0], "."),
|
||||||
ASN: fmt.Sprintf("%d", asnRecord.AutonomousSystemNumber),
|
ASN: fmt.Sprintf("%d", asnRecord.AutonomousSystemNumber),
|
||||||
Organization: asnRecord.AutonomousSystemOrganization,
|
Organization: asnRecord.AutonomousSystemOrganization,
|
||||||
Country: cityRecord.Country.IsoCode,
|
Country: cityRecord.Country.IsoCode,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue