summaryrefslogtreecommitdiff
path: root/ip.go
diff options
context:
space:
mode:
Diffstat (limited to 'ip.go')
-rw-r--r--ip.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/ip.go b/ip.go
index 278d472..f3ec3f1 100644
--- a/ip.go
+++ b/ip.go
@@ -11,6 +11,16 @@ func init() {
}
func ip(w http.ResponseWriter, r *http.Request) {
- host, _, _ := net.SplitHostPort(r.RemoteAddr)
+ addr, _, err := net.SplitHostPort(r.RemoteAddr)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ fmt.Fprintln(w, addr)
+ host, err := net.LookupAddr(addr)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
fmt.Fprintln(w, host)
}