diff --git a/.drone.yml b/.drone.yml index 1ef7073..6e4ba3e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,8 +14,7 @@ pipeline: - go build publish: image: plugins/docker - custom_dns: [ 8.8.8.8, 8.8.4.4 ] repo: deadbeef.codes:5000/mandelmap registry: deadbeef.codes:5000 -# auto_tag: true -# auto_tag_suffix: linux-rpi3 \ No newline at end of file + auto_tag: true + auto_tag_suffix: ${DRONE_COMMIT} \ No newline at end of file diff --git a/render.go b/render.go index 7536eb2..9199920 100644 --- a/render.go +++ b/render.go @@ -8,6 +8,7 @@ import ( "log" "math" "math/cmplx" + "net" "net/http" "runtime" "strconv" @@ -15,6 +16,9 @@ import ( "sync" "deadbeef.codes/steven/mandelmapper/palette" + "golang.org/x/image/font" + "golang.org/x/image/font/basicfont" + "golang.org/x/image/math/fixed" ) const ( @@ -116,6 +120,9 @@ func renderTile(w http.ResponseWriter, r *http.Request) { wg.Wait() + ip := GetOutboundIP() + + addLabel(img, 20, 30, fmt.Sprintf("%s", string(ip))) //addLabel(img, 20, 30, fmt.Sprintf("%s/%s/%s.png", components[1], components[2], components[3])) w.Header().Set("Content-Type", "image/png") png.Encode(w, img) @@ -195,7 +202,7 @@ func linearInterpolation(c1, c2, mu uint32) uint32 { } //Adds a text label to an image -/* + func addLabel(img *image.RGBA, x, y int, label string) { col := color.RGBA{255, 255, 255, 255} point := fixed.Point26_6{fixed.Int26_6(x * 64), fixed.Int26_6(y * 64)} @@ -208,4 +215,15 @@ func addLabel(img *image.RGBA, x, y int, label string) { } d.DrawString(label) } -*/ + +func GetOutboundIP() net.IP { + conn, err := net.Dial("udp", "8.8.8.8:80") + if err != nil { + log.Fatal(err) + } + defer conn.Close() + + localAddr := conn.LocalAddr().(*net.UDPAddr) + + return localAddr.IP +}