summaryrefslogtreecommitdiff
path: root/ip.go
blob: 7a4679f319520ffe8b55596508186dc0ce94eaf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package main

import (
	"io"
	"net/http"
	"strings"
)

func init() {
	http.HandleFunc("/ip",
		func(w http.ResponseWriter, r *http.Request) {
			ra := r.RemoteAddr
			if n := strings.Index(ra, ":"); n >= 0 {
				ra = ra[:n]
			}
			io.WriteString(w, ra)
		})
}