add some shitty lil ip tools
Jes Olson j3s@c3f.net
Fri, 18 Feb 2022 00:59:21 -0500
3 files changed,
21 insertions(+),
0 deletions(-)
M
main.go
→
main.go
@@ -8,7 +8,9 @@ "os"
"io" "path/filepath" "strings" + "fmt" "bytes" + "net" "git.j3s.sh/j3s.sh/feed" "github.com/SlyMarbo/rss"@@ -43,6 +45,7 @@ fs := http.FileServer(http.Dir("./static"))
http.Handle("/static/", http.StripPrefix("/static/", fs)) http.HandleFunc("/age.html", serveAge) + http.HandleFunc("/ip.html", ipHandler) http.HandleFunc("/review/", babyHandler) http.HandleFunc("/thought/", babyHandler) http.HandleFunc("/", serveTemplate)@@ -187,4 +190,14 @@
log.Printf("%+v", buf) tmpl.ExecuteTemplate(w, "layout", buf.String()) +} + +func ipHandler(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "text/plain") + ip, _, err := net.SplitHostPort(r.RemoteAddr) + if err != nil { + fmt.Fprintf(w, "bing bong, fuk ya life") + return + } + fmt.Fprintf(w, ip) }
M
templates/layout.html
→
templates/layout.html
@@ -42,6 +42,7 @@ <a href="/now.html">now</a>
<a href="/about.html">about</a> <a href="/reviews.html">reviews</a> <a href="/thoughts.html">thoughts</a> + <a href="/tools.html">tools</a> </p> <p> <a href="https://git.j3s.sh">git -></a>
A
templates/tools.html
@@ -0,0 +1,7 @@
+{{define "title"}}little silly tools{{end}} +{{define "body"}} +<p>heres some of my toolz</p> +<p><a href="/age.html">/age - age encryptor</a></p> +<p><a href="/feeds">/feeds - personal rss feed</a></p> +<p><a href="/ip.html">/ip - get ur public ip</a></p> +{{end}}