Skip to content

Commit a7189f3

Browse files
committed
Adding server ip recognition, new header image
1 parent 650b171 commit a7189f3

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

k8s/k8s.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,25 @@ package main
22

33
import (
44
"fmt"
5+
"net"
56
"net/http"
67
)
78

9+
func getServerIP() string {
10+
conn, err := net.Dial("udp", "8.8.8.8:80")
11+
if err != nil {
12+
panic(err)
13+
}
14+
defer conn.Close()
15+
return conn.LocalAddr().(*net.UDPAddr).IP.String()
16+
}
17+
818
func playHome(w http.ResponseWriter, r *http.Request) {
919
html := `<!DOCTYPE html><html><body><center>
10-
<img src="https://raw.githubusercontent.com/twogg-git/k8s-workshop/master/src/1.0.png">
11-
<h1 style="color:green">Playing with Kubernetes</h1>
12-
<h3 style="color:blue">Version: twogghub/k8s-workshop:1.0-baby</h3>
20+
<img src="https://raw.githubusercontent.com/twogg-git/k8s-workshop/master/src/1.1.png">
21+
<h1 style="color:blue">Playing with Kubernetes</h1>
22+
<h2 style="color:purple">Your server IP:` + getServerIP() + `</h2>
23+
<h3 style="color:green">Version: twogghub/k8s-workshop:1.1-rolling</h3>
1324
</center></body></html>`
1425
fmt.Fprintf(w, html)
1526
}

0 commit comments

Comments
 (0)