small pixel drawing of a pufferfish j3s.sh

add some shitty lil ip tools
Jes Olson j3s@c3f.net
Fri, 18 Feb 2022 00:59:21 -0500
commit

64b50d2247c8f41457bb0a449567470c0ab876c6

parent

9e62d7e32aba0595933ec4d65efc9989ab03e9db

3 files changed, 21 insertions(+), 0 deletions(-)

jump to
M main.gomain.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.htmltemplates/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}}